How to bring selenium browser to the front?

后端 未结 6 666
旧时难觅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:14

    Now I don't do python, but how I got around this in Groovy was the following:

    browser.js."alert()"
    webdriver.switchTo().alert().accept()
    

    I called the javascript alert function which brought the window to the foreground then I dismissed the alert with webdriver.switchTo().alert().accept(). Hopefully there is something similar in Python.

    Hope this helps!

提交回复
热议问题