I’m pulling my hair out here - have been trying to get this to work for weeks. I currently have a SwipeableWebDriver class and a Test class.
Here’s some things that I can do:
- Connect to my device (Android S3)
- Access Chrome browser
- Find a URL
- Connect to URL
- Interact with webelements
I cannot use any of the TouchScreen methods. I get a variety of errors, ranging from “WebDriverException: Not yet implemented” to “NullPointerException”.
I cannot get this to work with RemoteWebDriver or AppiumDriver. I have to have the functionality to be able to tap on the screen and swipe as I’m testing HTML5 games.
This is my SwipeableWebDriver method:
public class SwipeableWebDriver extends RemoteWebDriver implements HasTouchScreen {
RemoteTouchScreen touch;
public SwipeableWebDriver(URL remoteAddress, Capabilities desiredCapabilities) {
super(remoteAddress, desiredCapabilities);
touch = new RemoteTouchScreen(getExecuteMethod());
}
@Override
public TouchScreen getTouch() {
return touch;
}
}
And this is my main Test class:
public class AppiumDriverTest {
WebDriver driver;
TouchActions action;
@Before
public void setUp() throws Exception {
killDriver();
System.out.println(">> Desired Caps");
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.BROWSER_NAME, "Chrome");
cap.setCapability("platformName", "Android");
cap.setCapability("deviceName", "GT-I9300");
cap.setCapability("rotatable", "true");
driver = new SwipeableWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
action = new TouchActions(driver);
}
@After
public void tearDown() throws Exception {
driver.quit();
}
@Test
public void testRun() throws Exception {
System.out.println(">> Driver to URL");
driver.get("http://stackoverflow.com/");
System.out.println(">> Swipe Attempt");
action.down(300,200)
.flick(0,10)
.release()
.perform();
}
Any help would be greatly appreciated, else I run the risk of murdering a coworker!
Thanks,
Rori