I’m trying to run a Webivew application through the appium server with eclipse (selelnium). Whenever I try to run, It works very well at the first time and it fails from the second time.
In the first time run, It enters the username, password and clicking the login button correctly.
But, When I run it for the second time I’m getting an error in eclipse console like
(Original error: Did not get session redirect from Chromedriver)
Then to make it run.
I need to manually close the chromedriver in task manager.
In Task Manager → Process–>chromedriver.exe (End the process)
After that If I run the code it works good.
So it works very well when I run the first time and in the second time it fails.
CODE
public class LoginPage {
static AppiumDriver driver = null;
public static void main(String[] args) throws InterruptedException, ExecuteException, IOException
{
String deviceName = "Google Nexus 5 - 4.4.4 - API 19 - 1080x1920";
String cmd = "C:\\Program Files\\Genymobile\\Genymotion\\player --vm-name \""+deviceName+"\"";
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(cmd);
System.out.println("SetUp is started");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("automationName","appium");
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/GOA.apk");
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");
Set<String> contextNames = driver.getContextHandles();
for (String contextName : contextNames)
{
System.out.println(contextNames);
driver.context(contextName);
if (contextName.contains("WEBVIEW"))
{
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.findElement(By.id("txtUserName")).sendKeys("[email protected]");
driver.findElement(By.id("txtPassword")).sendKeys("test1");
driver.findElement(By.id("btnLogin")).click();
}
}
}
}
How to resolve the issue…