[英]selenium.webdriver.chrome.webdriver' has no attribute 'ChromeOptions in Python Robotframework
I am trying write function in python to avoid SSL certiicate error and chrome unpacked extension.我正在尝试在 python 中编写函数以避免 SSL 证书错误和 chrome 解包扩展。 But I am keep getting an issue in ChromeOptions.
但是我在 ChromeOptions 中不断遇到问题。
Error : module 'selenium.webdriver.chrome.webdriver' has no attribute 'ChromeOptions错误:模块“selenium.webdriver.chrome.webdriver”没有属性“ChromeOptions”
Library imported库导入
from selenium import webdriver
from selenium.webdriver.chrome import webdriver
from selenium.webdriver.chrome.options import Options
def open2browser():
chromeOptions = webdriver.ChromeOptions()
chromeOptions.add_experimental_option('useAutomationExtension', False)
chromeOptions.add_argument('--ignore-certificate-errors')
EXE_PATH = r'C:\ABC\chromedriver.exe'
driver = webdriver.Chrome(executable_path=EXE_PATH, options=chromeOptions)
driver.get('www.google.com')
driver.maximize_window()
Root cause of this issue is the below import.此问题的根本原因是以下导入。
from selenium.webdriver.chrome import webdriver
your webdriver.Chrome
is using the import from this and it's causing the issue.您的
webdriver.Chrome
正在使用由此导入的内容,这导致了问题。 Ideally you just need from selenium import webdriver
import rest are not required in this case.理想情况下,您只需要
from selenium import webdriver
import rest 在这种情况下是不需要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.