Vighnesh
Vighnesh

Reputation: 31

How to bring the browser window to front which is opened by selenium web driver

Browser chrome will be opened by selenium and executing some operations, but its seems to be not bring to front even it focused. How can i make this chrome window bring to front?

Upvotes: 1

Views: 2828

Answers (2)

undetected Selenium
undetected Selenium

Reputation: 193218

Here is what you need to do:

  1. Before you switch to any other window opened store the parent window handle in a String: String parent_window = driver.getWindowHandle();

  2. Switch to any other window & perform your actions.

  3. Finally, switch back to the parent window through the parent window handle stored in a String: driver.switchTo().window(parent_window);

  4. Perform the rest of your operations and call driver.quit();

Let me know if this Answers your question.

Upvotes: 2

Syed Sarek
Syed Sarek

Reputation: 413

Set this

System.setProperty("webdriver.chrome.driver", "path of the exe file\\chromedriver.exe");

and then add this line

WebDriver driver=new ChromeDriver();

Upvotes: 0

Related Questions