【问题标题】:Cannot input text (email) with Selenium无法使用 Selenium 输入文本(电子邮件)
【发布时间】:2021-05-03 21:22:49
【问题描述】:

我正在尝试使用带有 Selenium 的机器人来输入电子邮件和密码。使用百思买的网站。

这是我目前拥有的代码块:

browser.find_element_by_xpath("/input[@id='fld-e']").send_keys("EMAIL@gmail.com")

然而,当我实际运行程序时,并没有发送任何输入。这是附加到电子邮件块的 HTML 代码,以及我从 chrome 扩展中提取的 XPath: 我试过使用 .find_element_by_class_name("fld-e")

<input class="tb-input " type="email" autocomplete="off" id="fld-e" name="fld-e" placeholder="" required="" value="">

/html/body/div[@class='cia-app-container']/div[@class='cia-actual-full-page-wrapper lv']/section[@class='cia size-l cia--two-column-v2']/main[@class='cia-wrapper container']/div[@class='cia-wrapper__main']/div[@class='cia-content js-cia-content']/div[@class='cia-main-container']/div[@class='cia-settings-container']/div/div[@class='cia-signin']/form[@class='cia-form ']/div[@class='cdi-input cdi-wrapped-text']/div[@class='tb-input-wrapper   tb-input-wrapper-full-width']/input[@id='fld-e']

任何帮助将不胜感激,谢谢!

【问题讨论】:

标签: python python-3.x selenium selenium-chromedriver


【解决方案1】:

试试这个 xpath:

driver.find_element_by_xpath("//input[@type='email']")

如果它不起作用,请在您的问题中添加更多您正在使用的 html 代码。 您也可以尝试driver.find_element_by_id("fld-e"),但我怀疑它是否有效。

另外,等到该字段可点击。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多