0
votes

Am Opening a page performing some actions on that and i am using this piece of code to open another link in the next tab

String url = "https://qa.logfireapps.com/lgf_700_qa_rf";

String args1 = String.format("window.open('%s', '%s');", url, "new");

((JavascriptExecutor) driver).executeScript(args1);

Then i need to switch between this two tabs.

I used driver.switchTo.window(parentWin);

I also used this code

List windowHandles1 = new ArrayList(driver.getWindowHandles()); driver.switchTo().window(windowHandles1.get(1));

Both of the cases did not work for me,but still the web driver code is running successfully without any errors even its not switching to first window.

I need to switch to the first tab,but all the actions are going on in the first tab but still in UI am seeing the second tab opened,It is not switching to the first tab but my whole webdriver code gets passed.

It is observed that switching problem happens only with this two sites 1) https://qa.logfireapps.com/lgf_700_qa/index/

2) https://qa.logfireapps.com/lgf_700_qa_rf

1
Did you try this (with the full loop and debug output)? stackoverflow.com/a/25530472/66686 - Jens Schauder
yes ,did not worked for me.Its working fine in firefox - Naveen Chettigari
Does chrome support switching between windows? - Naveen Chettigari
can you post the output of the debug statements? - Jens Schauder
its showing different objects for the tabs, I printed it using sysout. - Naveen Chettigari

1 Answers

0
votes

This was my solution to this using python. sorry no java example

def switch_to_new_window(driver, window):
    driver.switch_to_window(driver.window_handles[window])