Wednesday, July 12, 2017

Multiple window examples


Click this link to start new Tab
Click this link to start new Tab
Click this link to start new Tab
Click this link to start Session in same window

9 comments:

  1. public class GmailChild_parentWindow {

    public static void main(String[] args) throws InterruptedException {
    // TODO Auto-generated method stub

    System.setProperty("webdriver.gecko.driver","C:\\geckodriver-v0.17.0-win64\\geckodriver.exe");

    WebDriver driver= new FirefoxDriver();
    driver.get("https://www.google.com/gmail/about/");
    driver.findElement(By.xpath("html/body/nav/div/a[3]")).click();
    String parent = driver.getWindowHandle();
    Set allwindows = driver.getWindowHandles();
    ArrayList tabs= new ArrayList<>(allwindows);
    System.out.println(driver.switchTo().window(tabs.get(1)));
    System.out.println(driver.getTitle());
    }

    }

    Unable to print the title plz help me

    ReplyDelete
  2. use wait statement like before capture the title thread.sleep(3000);

    ReplyDelete
  3. I really enjoy the blog.Much thanks again. Really Great selenium Online course Hyderabad

    ReplyDelete
  4. It's very informative post and i would like to suggest the best salesforce online training which is job oriented and 100% practical.

    ReplyDelete
  5. I really enjoy the blog.Much thanks again. Really Great selenium Online Training Bangalore

    ReplyDelete
  6. after I click the link to go to tab, if I want to switch over to parent, I'm doing driver.switchTo().window(parent); where parent is the handle of the parent tab. However, I do not see the focus going to the original tab. Focus is still at child tab. How can the focus go back to parent tab.

    ReplyDelete
  7. I have read your blog its very attractive and impressive. I like your blog selenium Online Training

    ReplyDelete