Python 在firefox中处理Selenium中的弹出窗口
我正在使用Selenium制作一个火种自动刷卡。 我使用firefox浏览器运行脚本,脚本是用python编写的。 我想处理弹出窗口,但无法处理它。 我使用了driver.switch_to.alert.accept(),但它返回的异常“引发异常”类(消息、屏幕、堆栈跟踪)Python 在firefox中处理Selenium中的弹出窗口,python,selenium,selenium-webdriver,Python,Selenium,Selenium Webdriver,我正在使用Selenium制作一个火种自动刷卡。 我使用firefox浏览器运行脚本,脚本是用python编写的。 我想处理弹出窗口,但无法处理它。 我使用了driver.switch_to.alert.accept(),但它返回的异常“引发异常”类(消息、屏幕、堆栈跟踪) selenium.common.exceptions.NoAlertPresentException:Message:“在打开页面之前,您可以尝试在选项中设置首选项。 试试这个: geo_location = webdriv
selenium.common.exceptions.NoAlertPresentException:Message:“在打开页面之前,您可以尝试在选项中设置首选项。 试试这个:
geo_location = webdriver.FirefoxOptions()
geo_location.set_preference('geo.prompt.testing', True)
geo_location.set_preference('geo.prompt.testing.allow', True)
# This will mock a certain location:
geo_location.set_preference('geo.provider.network.url',
'data:application/json,{"location": {"lat": 10.0, "lng": 10.0}, "accuracy": 100.0}')
# Pass options into the profile and open your page
driver = webdriver.Firefox(options=geo_location)
driver.get('https://tinder.com/app/recs')
我希望这有帮助,它对我有用。祝你好运 在打开页面之前,您可以尝试在选项中设置首选项。 试试这个:
geo_location = webdriver.FirefoxOptions()
geo_location.set_preference('geo.prompt.testing', True)
geo_location.set_preference('geo.prompt.testing.allow', True)
# This will mock a certain location:
geo_location.set_preference('geo.provider.network.url',
'data:application/json,{"location": {"lat": 10.0, "lng": 10.0}, "accuracy": 100.0}')
# Pass options into the profile and open your page
driver = webdriver.Firefox(options=geo_location)
driver.get('https://tinder.com/app/recs')
我希望这有帮助,它对我有用。祝你好运 您可以检查并尝试可能的解决方案。谢谢,但我正在查找python代码及其用java编写的链接。您可以检查并尝试可能的解决方案。谢谢,但我正在查找python代码及其用java编写的链接。