Issue
I have an Appium test that I am trying to run against and Android Emulator using the stock browser. This test passes on iOS however on Android it fails half way between the test because Android seems a little more fussy about element locators than iOS.
Anyway my problem is that I would expect it to fail at this point because it can't find the element it tries to click, however the test then just hangs (for around 10 minutes when it is then killed by the socket timeout), and doesn't cause the test to fail. The emulator just stays open and the test looks like it's continuing to run.
I have the latest version of Appium installed via npm.
Here are my desired capabilities:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("browserName", "browser");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("takesScreenshot", true);
capabilities.setCapability("version", "5.1.1");
capabilities.setCapability("deviceName", "Android Emulator");
capabilities.setCapability("avd", "nexus5");
webDriver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),
capabilities);
My Appium log shows the following:
info: Got response with status 200: {"sessionId":"27038f591907917c7f2c1ce48db7d032","status":13,"value":{"message":"unknown error: Element is not clickable at point (342, 32). Other element would receive the click: <button class=\"butto...
info: <-- POST /wd/hub/session/27038f591907917c7f2c1ce48db7d032/element/0.9723546949680895-1/click 200 825.852 ms - 381
info: --> GET /wd/hub/session/27038f591907917c7f2c1ce48db7d032/screenshot {}
info: Proxying [GET /wd/hub/session/27038f591907917c7f2c1ce48db7d032/screenshot] to [GET http://127.0.0.1:9515/wd/hub/session/27038f591907917c7f2c1ce48db7d032/screenshot] with body: {}
info: [debug] Didn't get a new command in 30 secs, shutting down...
info: Shutting down appium session
info: Proxying [DELETE /] to [DELETE http://127.0.0.1:9515/wd/hub/session/27038f591907917c7f2c1ce48db7d032] with no body
I would expect my test to exit at this point due to it not being able to click the element. Could any one offer any advice?
Thanks
UPDATE
Added the code where I take a screenshot which looks like is what is making my test hang:
public void captureScreenshot(String methodName) {
try {
new File(screenshotDirectory).mkdirs();
String filename = methodName + ".png";
File screenshot = ((TakesScreenshot) webDriverService.getWebDriver()).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshot, new File(screenshotDirectory + filename));
} catch (Exception e) {
System.out.println(e.toString());
}
}
Solution
Managed to fix it had to use a slightly different piece of code to take a screenshot on android:
public void captureScreenshot(String methodName) {
try {
new File(screenshotDirectory).mkdirs();
String filename = methodName + ".png";
AppiumDriver webDriver = (AppiumDriver) webDriverService.getWebDriver();
webDriver.context("NATIVE_APP");
File screenshot = ((TakesScreenshot) webDriver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshot, new File(screenshotDirectory + filename));
} catch (Exception e) {
System.out.println(e.toString());
}
}
};
Answered By - Sam Eeles
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.