Python 使用Selenium时Firefox出现系统扩展权限提示问题
我的目标是在运行Python Selenium脚本时安装Firefox扩展。我需要用预装的扩展测试我的网页(它可以是插件商店的任何扩展) 我尝试执行的解决方案是通过Selenium进入插件商店并单击“添加到Firefox”按钮来安装该扩展: 但问题是Firefox请求权限。这是一个确认提示,我需要同意继续安装: 我无法通过Selenium单击“添加”按钮。此外,我看不到这个弹出窗口的HTML代码 因此,我看到了3种可能的变体来执行它,但我不知道如何执行Python 使用Selenium时Firefox出现系统扩展权限提示问题,python,selenium,selenium-webdriver,firefox,firefox-addon,Python,Selenium,Selenium Webdriver,Firefox,Firefox Addon,我的目标是在运行Python Selenium脚本时安装Firefox扩展。我需要用预装的扩展测试我的网页(它可以是插件商店的任何扩展) 我尝试执行的解决方案是通过Selenium进入插件商店并单击“添加到Firefox”按钮来安装该扩展: 但问题是Firefox请求权限。这是一个确认提示,我需要同意继续安装: 我无法通过Selenium单击“添加”按钮。此外,我看不到这个弹出窗口的HTML代码 因此,我看到了3种可能的变体来执行它,但我不知道如何执行 如何使用Selenium单击按钮 如何禁
def install_addon(self):
self.driver.execute_script("window.open('');") # open new tab
self.driver.switch_to.window(self.driver.window_handles[1])
self.driver.get('https://addons.mozilla.org/en-US/firefox/addon/extension/')
self.driver\
.find_element_by_class_name("InstallButtonWrapper")\
.find_element_by_class_name("AMInstallButton-button")\
.click()