|
21 | 21 | import com.google.common.collect.ImmutableMap;
|
22 | 22 | import io.appium.java_client.internal.JsonToMobileElementConverter;
|
23 | 23 | import org.openqa.selenium.*;
|
| 24 | +import org.openqa.selenium.html5.Location; |
| 25 | +import org.openqa.selenium.html5.LocationContext; |
24 | 26 | import org.openqa.selenium.remote.*;
|
| 27 | +import org.openqa.selenium.remote.html5.RemoteLocationContext; |
25 | 28 |
|
26 | 29 | import javax.xml.bind.DatatypeConverter;
|
27 | 30 | import java.net.URL;
|
|
33 | 36 | import static io.appium.java_client.MobileCommand.*;
|
34 | 37 |
|
35 | 38 | public class AppiumDriver extends RemoteWebDriver implements MobileDriver, ContextAware, Rotatable, FindsByIosUIAutomation,
|
36 |
| - FindsByAndroidUIAutomator, FindsByAccessibilityId { |
| 39 | + FindsByAndroidUIAutomator, FindsByAccessibilityId, LocationContext { |
37 | 40 |
|
38 | 41 | private final static ErrorHandler errorHandler = new ErrorHandler(new ErrorCodesMobile(), true);
|
39 | 42 | private URL remoteAddress;
|
40 | 43 | private ComplexFind complexFind;
|
| 44 | + private RemoteLocationContext locationContext; |
| 45 | + private ExecuteMethod executeMethod; |
41 | 46 |
|
42 | 47 | public AppiumDriver(URL remoteAddress, Capabilities desiredCapabilities){
|
43 | 48 |
|
44 | 49 | super(remoteAddress, desiredCapabilities);
|
45 | 50 | this.setElementConverter(new JsonToMobileElementConverter(this));
|
46 | 51 |
|
| 52 | + this.executeMethod = new AppiumExecutionMethod(this); |
47 | 53 | this.remoteAddress = remoteAddress;
|
48 | 54 | complexFind = new ComplexFind(this);
|
| 55 | + locationContext = new RemoteLocationContext(executeMethod); |
49 | 56 |
|
50 | 57 | ImmutableMap.Builder<String, CommandInfo> builder = ImmutableMap.builder();
|
51 | 58 | builder
|
@@ -93,6 +100,10 @@ protected Response execute(String command) {
|
93 | 100 | return execute(command, ImmutableMap.<String, Object>of());
|
94 | 101 | }
|
95 | 102 |
|
| 103 | + @Override |
| 104 | + public ExecuteMethod getExecuteMethod() { |
| 105 | + return executeMethod; |
| 106 | + } |
96 | 107 |
|
97 | 108 | /**
|
98 | 109 | * Reset the currently running app for this session
|
@@ -626,6 +637,16 @@ public List<WebElement> findElementsByAccessibilityId(String using) {
|
626 | 637 | return findElements("accessibility id", using);
|
627 | 638 | }
|
628 | 639 |
|
| 640 | + @Override |
| 641 | + public Location location() { |
| 642 | + return locationContext.location(); |
| 643 | + } |
| 644 | + |
| 645 | + @Override |
| 646 | + public void setLocation(Location location) { |
| 647 | + locationContext.setLocation(location); |
| 648 | + } |
| 649 | + |
629 | 650 | private TouchAction createTap(WebElement element, int duration) {
|
630 | 651 | TouchAction tap = new TouchAction(this);
|
631 | 652 | return tap.press(element).waitAction(duration).release();
|
|
0 commit comments