【发布时间】:2021-03-29 14:46:42
【问题描述】:
HTML元素的代码如下:
<input aria-label="Phone number, username, or email" aria-required="true" autocapitalize="none" autocorrect="off" maxlength="75" name="username" type="text" class="_2hvTZ pexuQ zyHYP" value="">
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: [name="username"]
执行此代码时出现上述错误:
from selenium.webdriver import Firefox
class Efrit:
#Initializing the bot
def __init__(self, username, password):
self.username = username # it could also be e-mail or phone number
self.password = password
#Credentials to log into Instagram:
def log(self):
driver = Firefox('/usr/local/bin')
driver.get("https://www.instagram.com/")
username_location = driver.find_element_by_name('username')
password_location = driver.find_element_by_name('password')
bot = Efrit('test, 'test')
bot.log()
【问题讨论】:
-
登录表单不在页面源中。你需要wait
标签: python python-3.x selenium selenium-webdriver geckodriver