windows 它只进入浏览器.get()

brccelvz  于 2023-11-21  发布在  Windows
关注(0)|答案(1)|浏览(191)

当我运行我写的代码时,它只将browser.get('https://www.instagram.com/accounts/password/reset/')输入到我在这里指定的web。没有任何变化,

username_input = driver.find_element_by_name('username')
NameError: name 'driver' is not defined. Did you mean: 'webdriver'?

字符串
会是什么原因呢?我写的代码:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
browser = webdriver.Firefox()
browser.get('https://www.instagram.com/accounts/password/reset/')
sleep(2)

username_input = driver.find_element_by_name('username')
username_input.send_keys(username)
username_input.send_keys(Keys.ENTER)
sleep(2)

email_input = driver.find_element_by_name('email')
email_input.send_keys(Keys.ENTER)
sleep(2)

driver.quit()
username = '...'
email = '...'
reset_instagram_password(username, email)

iyr7buue

iyr7buue1#

你在变量"browser = webdriver.Firefox()"中获取webdriver,但是在搜索元素时,你使用的是"username_input = driver.find_element_by_name('username')"
改成跟着...

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
driver = webdriver.Firefox()
driver.get('https://www.instagram.com/accounts/password/reset/')
sleep(2)

username_input = driver.find_element_by_name('username')
username_input.send_keys(username)
username_input.send_keys(Keys.ENTER)
sleep(2)

email_input = driver.find_element_by_name('email')
email_input.send_keys(Keys.ENTER)
sleep(2)

driver.quit()
username = '...'
email = '...'
reset_instagram_password(username, email)

字符串

相关问题