嗯,我是第一次学习Python。我需要以下代码的帮助:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
class CursoAutomacao:
def __init__(self):
chrome_options = Options()
chrome_options.add_argument('--lang-pt-BR')
driver = webdriver.Chrome(executable_path=r'C:\Users\Daniel pc\Desktop\Tutorial chromeDriver\chromedriver.exe')
def Iniciar(self):
self.driver.get('https://www.mercadolivre.com.br')
curso = CursoAutomacao()
curso.Iniciar()
当我运行此代码时,会出现以下错误:NameError: **name 'driver' is not defined**.
会发生什么?我的Chrome窗口打开但很快关闭
提前感谢您的帮助
您需要在
init
方法中使用self.driver = ...
总体而言:
相关问题 更多 >
编程相关推荐