org.sitoolkit.wt.domain.evidence.appium.AndroidHybridElementPositionStrategy Maven / Gradle / Ivy
package org.sitoolkit.wt.domain.evidence.appium;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.sitoolkit.wt.domain.evidence.ElementPositionStrategy;
import org.sitoolkit.wt.domain.evidence.selenium.ElementPositionSupport2;
import io.appium.java_client.AppiumDriver;
public class AndroidHybridElementPositionStrategy implements ElementPositionStrategy {
@Override
public void init(ElementPositionSupport2 eps, WebDriver driver) {
AppiumDriver appiumDriver = (AppiumDriver) driver;
String context = appiumDriver.getContext();
// BasePosition
appiumDriver.context("NATIVE_APP");
WebElement baseElement = appiumDriver.findElementByClassName("android.webkit.WebView");
eps.setBasePosition(baseElement.getLocation());
Dimension dim = baseElement.getSize();
appiumDriver.context(context);
// Scale
WebElement htmlElement = appiumDriver.findElementByTagName("body");
double scale = (double) dim.getWidth() / htmlElement.getSize().getWidth();
eps.setScale(scale);
}
@Override
public Point getCurrentBasePosition(WebDriver driver, WebElement currentFrame) {
return new Point(0, 0);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy