Handle notifications in Python + Selenium Chrome WebDriver

后端 未结 4 1362
醉酒成梦
醉酒成梦 2020-12-03 19:07

How can Selenium Chrome WebDriver notifications be handled in Python?

Have tried to dismiss/accept alert and active element but seems notif

4条回答
  •  有刺的猬
    2020-12-03 19:51

    The answer above from Dec '16 didn't work for me in August 2020. Both Selenium and Chrome have changed, I believe.

    I'm using the binary for Chrome 84, which is listed as the current version, even though there's a binary for Chrome 85 available from selenium.dev. I have to presume that's a beta since I have no other info on that.

    I only have a partial answer so far, but I believe the following two lines are in the right direction. They're as far as I've gotten tonight. I have a test window that I've opened to Facebook and have the exact window shown in the Question. The code given in pythonjar's answer from Dec 30 '16 above produced error messages for me. These code lines worked without error, so I believe this is the right track.

    >>> from selenium.webdriver import ChromeOptions
    >>> chrome_options = ChromeOptions()
    

    I'll update this tomorrow, if I get time to work on it.

    Sorry for the partial answer. I hope to complete it soon. I hope this helps. If you get there first, please let me know.

提交回复
热议问题