Reputation: 11
So I have the driver open chrome to a webpage and then make it click a button which open a second window.
driver.get("https://web.com");
driver.findElement(webdriver.By.id('button')).click();
How do i switch the driver control to the new window? I wanted to try:
driver.switchTo().window('windowName');
but i can't figure out name/id of the new window in chrome. I have looked up example but they are all written for Java and other language. I am using javascript(node) webdriverjs.
Upvotes: 1
Views: 878
Reputation: 134
The command driver.getAllWindowHandles()
will help you out in getting the name of the window. Check out the API Reference Docs for more commands/info.
Upvotes: 1