I’m trying to run a Hybrid application through the Genymotion Emulator with Appium 1.3.4.1.
Started the appium server and eclipse.
Now the emulator is running but in eclipse console an error message is displayed
Randomly I am getting these four errors:
- A new session could not be created. (Original error: UiAutomator quit before it successfully launched)
- A new session could not be created. (Original error: Screen did not unlock)
- A new session could not be created. (Original error: Android device not found)
- A new session could not be created. (Original error: Activity used to start app doesn’t exist or cannot be launched! Make sure it exists and is a launchable activity)
Then I start the emulator manually and then I click the run button in eclipse.
By that time am not getting the above error message: It is going in to webview content but not able to find the element.
The error message is:
Exception in thread “main” 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: 15.45 seconds
Appium Settings:
Override Existing session = false
Here is my code
public static void main(String[] args) throws InterruptedException, ExecuteException, IOException {
// TODO Auto-generated method stub
String deviceName = "Google Nexus 5 - 4.4.4 - API 19 - 1080x1920";
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName","Google Nexus 5 - 4.4.4 - API 19 - 1080x1920");
capabilities.setCapability("platformVersion", "4.4.4");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app","D:/SOFTWARES/Apks/Hybrid.apk");
**Starting the thirdy party genymotion emulator from the code.**
DefaultExecutor executor = new DefaultExecutor();
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
CommandLine launchEmul = new CommandLine("C:/Program Files/Genymobile/Genymotion/player");
launchEmul.addArgument("--vm-name");
launchEmul.addArgument("\""+deviceName+"\"");
executor.setExitValue(1);
executor.execute(launchEmul, resultHandler);
Thread.sleep(40);
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
System.out.println("SetUp is successful and Appium Driver is launched successfully");
Login();
}
public static void Login() throws InterruptedException
{
**Trying to do the login process in the Webview application**
Set<String> contextNames = driver.getContextHandles();
for (String contextName : contextNames) {
System.out.println(contextName);
if (contextName.contains("WEBVIEW")){
System.out.println("Application Loaded");
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.findElement(By.id("txtUserName")).clear();
driver.findElement(By.id("txtUserName")).sendKeys("[email protected]");
driver.findElement(By.id("txtPassword")).clear();
driver.findElement(By.id("txtPassword")).sendKeys("test1");
driver.findElement(By.id("btnLogin")).click();
}
}
The error is occuring when it is starting to find the txtUserName field
Before 3 days this same code worked very well. But now it is not working. I need some suggestions .