Currently i’m having problems with Appium. Working on a hybrid app and switched to a webview. The tests work if i use Thread.sleep, but when i use implicit wait it doesn’t.
public void setUp() throws Exception {
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "/src/testdata/");
File app = new File(appDir, "CordovaApp-debug.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("device", "Android");
capabilities.setCapability("deviceName","Motox");
capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.testing.Testing");
capabilities.setCapability("appActivity", "CordovaApp");
driver=new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
driver.manage().timeouts().implicitlyWait(60,TimeUnit.SECONDS);
@Test
public void ChangingLanguage() throws InterruptedException {
for (int i = 0; i < 20; i++) {
String nr = driver.getContextHandles().toString();
if (nr.contains("WEBVIEW")) {
driver.context("WEBVIEW_com.testing.Testing");
break;
}
else
{Thread.sleep(5000);}}
WelcomeView.HaveanAccount(driver).click();
Login.EmailBox(driver).sendkeys("[email protected]");
I’m getting a exception. org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 475 milliseconds
Even though i specificed that it should wait atleast 60 seconds. I tried testing a native app and there it was fine. It timed out after trying for 60 seconds. Any ideas or suggestions.