python机器人Instagram电子邮件

python机器人Instagram电子邮件,python,bots,instagram,Python,Bots,Instagram,我在一个Instagram账户创建者那里工作,我被卡住了。创建Instagram帐户时,您需要一封电子邮件。我使用ProtonMail,我使用Selenium来实现我的web自动化,但当我到达要求您输入所需用户名的步骤时,我的代码找不到该框。 现在,选择用户名框的代码如下所示: self.driver.find_element_by_id('username').send_keys(username) self.driver.find_element_by_id('password').send

我在一个Instagram账户创建者那里工作,我被卡住了。创建Instagram帐户时,您需要一封电子邮件。我使用ProtonMail,我使用Selenium来实现我的web自动化,但当我到达要求您输入所需用户名的步骤时,我的代码找不到该框。 现在,选择用户名框的代码如下所示:

self.driver.find_element_by_id('username').send_keys(username)
self.driver.find_element_by_id('password').send_keys(password)
self.driver.find_element_by_id('passwordc').send_keys(password)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate 
element: {"method":"css selector","selector":"[id="username"]"}
错误如下所示:

self.driver.find_element_by_id('username').send_keys(username)
self.driver.find_element_by_id('password').send_keys(password)
self.driver.find_element_by_id('passwordc').send_keys(password)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate 
element: {"method":"css selector","selector":"[id="username"]"}
但是用户名的id是正确的:

密码的两行代码也可以工作,但用户名不能


我试图通过用户名框的类名来查找用户名框,但它不起作用。

对于将来的protonmail问题。这是一个不同的
iframe
,这就是通常方法不起作用的原因。我们需要切换
iframe

    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    
    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_argument("start-maximized")
    # chrome_options.add_argument('disable-infobars')
    driver = webdriver.Chrome(options=chrome_options, executable_path='C:/bin/chromedriver.exe')
    driver.get("https://protonmail.com/")
    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//a[@class='btn btn-default btn-short' and @href='signup']"))).click()
    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='row']//p[text()='Basic account with limited features']"))).click()
    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='btn btn-primary btn-lg pull-right' and @id='freePlan']"))).click()
    WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH, "//div[@class='usernameWrap']//iframe[@title='Registration form']")))
    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//input[@class='input' and @id='username']"))).send_keys("username")

您是否尝试过在浏览器inspect element JS控制台中使用JQuery来验证选择器?我尝试过您的代码,但仍然不起作用。错误为:selenium.common.exceptions.NoSuchElementException:Message:没有这样的元素:无法找到元素:{“方法”:“css选择器”,“选择器”:“.f0n8F”}我的用户名是ProtonMail而不是Instagram。@peterqiu确定..完成了。请检查。这是一个不同的
iframe
问题。