attributeError:' bool'对象没有属性' click'
我正在尝试在Moodle上自动化登录过程,但是当我尝试在用户名中找到并发送钥匙时 这是我的代码:
from selenium.webdriver.common.by import By
import webbrowser
from selenium import webdriver
driver = webdriver.Chrome(r'D:\Install\chromedriver_win32\chromedriver.exe')
driver.get("https://lms.jspmrscoe.edu.in/?redirect=0")
username = driver.find_element(By.NAME, 'username').is_displayed()
username.Click()
username.send_keys("name*emphasized text*")
该代码可以正常工作直到查找元素,但是当我尝试通过.click()单击它时,它显示错误是这样的:
AttributeError: 'bool' object has no attribute 'Click'
i'm trying to automate a login process on moodle but when i try to find and send keys in the username feild is thsows me error
here is my code:
from selenium.webdriver.common.by import By
import webbrowser
from selenium import webdriver
driver = webdriver.Chrome(r'D:\Install\chromedriver_win32\chromedriver.exe')
driver.get("https://lms.jspmrscoe.edu.in/?redirect=0")
username = driver.find_element(By.NAME, 'username').is_displayed()
username.Click()
username.send_keys("name*emphasized text*")
the code works fine till the finding of the element but when i try to click on it by .click() it shows a error is like this:
AttributeError: 'bool' object has no attribute 'Click'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在此行中:
is_displayed()
函数被调用。这返回
true
或false
- 布尔值。您不能在
.click()
函数用户名
上调用函数,因为布尔值没有该功能In this line:
the
is_displayed()
function is called.This returns
True
orFalse
- a boolean.You cannot call the
.Click()
function onusername
since booleans don't have that function您正在调用单击布尔值,这是解决方案:
You are calling Click on a Boolean, here is the solution: