- mnsam
- Posts : 1
Join date : 2016-03-13
unable to switch to 'current active tab' in chrome using webdriver in java
Sun Mar 13, 2016 3:41 pm
I am unable to switch to the 'current active tab' in Chrome using WebDriver. I have tried the following:
We can switch to tab, however we do not know which one is the current active tab
I have tried driver.switchTo().activeElement() however it is of no help
I have tried driver.switchTo().Window(""), doesn't work
Tried the following snippet.
Set allWindowHandles = driver.getWindowHandles();
for (String windowHandle : allWindowHandles) {
if (!windowHandle.equals()) {
driver.switchTo().window(windowHandle);
}
}
However getting the current active tab handle is the issue.
We can switch to tab, however we do not know which one is the current active tab
I have tried driver.switchTo().activeElement() however it is of no help
I have tried driver.switchTo().Window(""), doesn't work
Tried the following snippet.
Set
for (String windowHandle : allWindowHandles) {
if (!windowHandle.equals(
driver.switchTo().window(windowHandle);
}
}
However getting the current active tab handle is the issue.
- murthiActive particpant
- Posts : 11
Join date : 2016-04-14
Location : Bangalore
Re: unable to switch to 'current active tab' in chrome using webdriver in java
Thu Apr 14, 2016 8:05 pm
Normally there will be only one tab and if you click on a click, it may open the new window or it may open in the same browser as new tab.
To switch to new window, you can use driver.switchTo().window().
To switch to new tab, you can can you use send keys with Ctrl + Tab.
driver.findElement(By.xpath("/html/body")).sendKeys(keys.chrod(keys.Ctrl+Keys.TAB));
I have used one of my test case. It worked. You can tried this way.
Regards,
Murthi. S
To switch to new window, you can use driver.switchTo().window().
To switch to new tab, you can can you use send keys with Ctrl + Tab.
driver.findElement(By.xpath("/html/body")).sendKeys(keys.chrod(keys.Ctrl+Keys.TAB));
I have used one of my test case. It worked. You can tried this way.
Regards,
Murthi. S
- vini546Active particpant
- Posts : 10
Join date : 2012-07-15
Location : Ahmedabad
Re: unable to switch to 'current active tab' in chrome using webdriver in java
Thu May 12, 2016 8:50 pm
Thanks mate. I've tried and it's working perfect.
- Vinay
- Vinay
Permissions in this forum:
You cannot reply to topics in this forum