Hi All Selenium Experts,

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.

Search Discussions

  • QuPi at Oct 1, 2012 at 2:38 am
    With this,
    "
    System.out.println("-------
    Second Window---------");
    winids = driver.getWindowHandles();
    itrate = winids.iterator();
    System.out.println(itrate.next());
    "

    Is there any new windowid has cached?

    Let's try following codes after "click" action and see how many windows
    could be cached.

    You may need to execute this before action click (if Modal dialog will
    prompt because of click):

    ((JavascriptExecutor)dr).executeScript("window.showModalDialog = function(
    sURL,vArguments, sFeatures) { window.open(sURL, 'modal', sFeatures); }");

    <here you do click>

    Set<String> whds = dr.getWindowHandles();
    System.out.println("number of windows: " + whds.size());
    System.out.println("list of windows: " + whds.toString());
    dr.switchTo().window(whds.toArray()[whds.size()-1].toString());


    On Sunday, September 30, 2012 3:31:32 PM UTC+7, rahul arora wrote:

    Hi All Selenium Experts,

    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("
    sale...@yatraonline.com <javascript:>");

    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.
    To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/EuiBJ8NoHxgJ.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupselenium-users @
categoriesselenium
postedSep 30, '12 at 8:31a
activeOct 1, '12 at 2:38a
posts2
users2
websiteseleniumhq.org

2 users in discussion

QuPi: 1 post Rahul arora: 1 post

People

Translate

site design / logo © 2022 Grokbase