How to bring selenium browser to the front?

后端 未结 6 671
旧时难觅i
旧时难觅i 2021-02-08 06:24

if the browser window is in bg, then this line doesn\'t work.

from selenium import webdriver

from selenium.webdriver.common.keys import Keys
from selenium.webd         


        
6条回答
  •  梦如初夏
    2021-02-08 07:25

    This is a complete hack, but it worked for me using IE, selenium remote driver in Windows 7.

    driver.get("about:blank")  
    driver.minimize_window()  
    driver.maximize_window()  
    driver.minimize_window()  
    driver.maximize_window()  
    

    I send a blank page, then minimize and maximize twice. It seems to result in the newly created IE having foreground focus.

提交回复
热议问题