I just encountered a new challenge on switching to a new window on
Yatra.com site through WebDriver. I have tried everything possible by the
focus get lost while clicking on the link to the new window. Nothing works
after this command and even no failure message from WebDriver's end. The
project still runs until I stop the execution manually.
I am unable to switch to the next window from the mouse over menu, Can
anyone please execute the below code and see if you are able to switch the
same also it would be really helpful if I can get a quick resolution since
I am working on this project and need to deliver it asap.
WebDriver driver = new FirefoxDriver();
driver.get("http://agents.yatra.com");
driver.manage().timeouts().implicitlyWait(20L, TimeUnit.SECONDS);
System.out.println("----------First Window----------");
Set<String> winids = driver.getWindowHandles();
Iterator<String> itrate = winids.iterator();
String first_window = itrate.next();// first window
System.out.println(first_window);
driver.findElement(By.xpath("html/body/div[2]/div/div[2]/div/div[3]/form/span[5]/input")).sendKeys("
salesdemo@yatraonline.com");
driver.findElement(By.xpath("html/body/div[2]/div/div[2]/div/div[3]/form/span[8]/input")).sendKeys("TSIYATRA2012");
driver.findElement(By.xpath("html/body/div[2]/div/div[2]/div/div[3]/form/span[10]/button")).click();
WebElement hotel
=driver.findElement(By.xpath("//*[@id='main-nav']/ul/li[5]/a"));
Actions action = new Actions(driver);
action.moveToElement(hotel).perform();
driver.findElement(By.xpath("//*[@id='holidays']/li[5]/a")).click();
// After clicking on this I am unable to find the window id for the next
window, this is what I have used
System.out.println("-------Second Window---------");
winids = driver.getWindowHandles();
itrate = winids.iterator();
System.out.println(itrate.next());
String second_window = itrate.next();// Second window
System.out.println(second_window);
driver.switchTo().window(second_window);
driver.findElement(By.xpath("//*[@id='country']")).sendKeys("India");
Thanks,
Rahul
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.