【问题标题】:Message: no such element: Unable to locate element: {"method":"css selector","selector":"[name="uID"]"}消息:没有这样的元素:无法找到元素:{"method":"css selector","selector":"[name="uID"]"}
【发布时间】:2020-09-16 02:37:33
【问题描述】:

我用python构建自动登录程序 但是,我什么都不知道

那么,在这种情况下我该怎么办?

html代码

<input type="text" name="uID" value="" class="form-control input-lg" placeholder="ID" autocomplete="off" required="" tabindex="1">

我的代码

my_id2 = 'id'
my_pw2 = 'password'

driver.find_element_by_name('uID').send_keys(my_id2)
driver.find_element_by_name('uPW').send_keys(my_pw2)

错误消息

NoSuchElementException
    Message: no such element: Unable to locate element: {"method":"css selector","selector":"[name="uID"]"}
      (Session info: chrome=85.0.4183.102)

【问题讨论】:

  • 您好,请问有什么问题吗?
  • 尝试使用 xpath 或 css 选择器

标签: python selenium automation


【解决方案1】:

如果你想使用定位你的元素使用这个

#css
driver.find_element_by_css('input[name=\'uID\']'.send_keys(my_pw2)

#or

#xpath
driver.find_element_by_xpath('//input[@name,\'uID\']'.send_keys(my_pw2)

driver.find_element_by_name 用于查找填充了“value”属性的元素。

【讨论】:

    猜你喜欢
    • 2020-03-18
    • 2021-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-20
    • 1970-01-01
    • 2020-09-30
    相关资源
    最近更新 更多