1

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?

Vighnesh
  • 31
  • 1
  • 5
  • 1
    Provide more info: 1. What are your testing steps? 2. What worked for you? Show code. 3. Where are you stuck? 4. Show error stacktrace. 5. Provide relevant HTML DOM. – undetected Selenium May 03 '17 at 10:16
  • @Dev Actually chrome window has opened and working well as i scripted. but if i switch to any other window opened, i need this chrome window bring to front which means always this chrome window should be in front until i call driver.quit(); – Vighnesh May 03 '17 at 10:28

2 Answers2

2

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.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

Set this

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

and then add this line

WebDriver driver=new ChromeDriver();
Syed Sarek
  • 373
  • 2
  • 12