简体   繁体   中英

How to open chrome driver (Using Selenium Webdriver) in foreground. By default its opening in background with no focus

I've been using chrome driver (with selenium wedriver), so far it never caused any issue, now for some requirement it has to be in foreground with focus on it. How can I make sure it is in the foreground?

Just immediately after navigating to your test URL, Maximize and Switch To the new window. It will come in the fore ground (provided you don't interfere with your mouse ;)

    browser.navigate().to(test_URL);
    browser.manage().window().maximize();
    browser.switchTo().window(browser.getWindowHandle());

Finally I found the answer from one of the post, it worked for me, URL:

Bring the Firefox Browser to Front using selenium Java (Mac OSX)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM