【发布时间】:2021-06-05 22:35:07
【问题描述】:
我想使用 Selenium 自动登录网站 https://clientes.ecuabots.com/user/login
这是我的代码:
class EcuabotsTest(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome(executable_path='/mnt/c/Users/Barbara/Documents/Formación Continua/Selenium/chromedriver.exe')
driver = self.driver
driver.get('https://clientes.ecuabots.com/user/login')
driver.maximize_window()
#driver.implicitly_wait(15)
def test_search_email_input(self):
email_field = self.driver.find_elements_by_xpath('//*[@id="input-15"]')
email_field.clear()
email_field.send_keys('email@email.com)
if __name__ == "__main__":
unittest.main(verbosity=2)
但是当我尝试这种方式时出现错误:AttributeError 'list' object has no attribute send_keys
-
我尝试使用 email_field = self.driver.find_element_by_xpath('//[@id="input-15"]') (单数)但我收到此错误:selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素:{"method":"xpath","selector":"//[@id="input-15"]"
-
我尝试使用 id、CSS 选择器和完整 XPath 查找电子邮件输入,但它不起作用
-
我尝试使用 email_field[0].send_keys('email@email.com) 但我再次收到第一个错误
非常感谢您的帮助!
【问题讨论】:
标签: python python-3.x selenium selenium-webdriver selenium-chromedriver