尝试用铬python在覆盆子Pi上使用硒

2024-06-15 02:50:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试在我的树莓pi上使用selenium,它连接到我的爱洛摄像头的监视器上,但代码在raspberry pi上不起作用。虽然我已经在我的windows机器上测试了代码,而且它还在工作。我可以在raspberry pi上运行chrome驱动程序,但当我试图配置chromeoption时,问题就来了。我遇到了一个我无法理解的错误。代码如下:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

driver = webdriver.Chrome('/usr/lib/chromium-browser/chromedriver') 
#driver = webdriver.Chrome(chromedriver)

chrome_options = Options()
prefs = {
    "profile.default_content_setting_values.plugins": 1,
    "profile.content_settings.plugin_whitelist-flash-player": 1,
    "profile.content_settings.exceptions.plugins.*,*.per_resource.adobe-flash-player": 1,
    "PluginsAllowedForUrls": "https://arlo.netgear.com/#/login"

    }
chrome_options.add_experimental_option("prefs", prefs)
chrome_options.add_argument("--kiosk") # full screen


self.driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get('https://arlo.netgear.com/#/login')
'''
my username and password for accessing arlo website
'''
username = driver.find_element_by_id('userId')
password = driver.find_element_by_id('password')
username.send_keys('enter your user name here')
password.send_keys('password ')

driver.find_element_by_id('loginButton').click()

这是错误回溯:

^{pr2}$

Tags: 代码driverseleniumpiusernamepasswordcontentfind