AttributeError: 'bool' object has no attribute 'Click'

Issue

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'

Solution

In this line:

username = driver.find_element(By.NAME, 'username').is_displayed()

the is_displayed() function is called.

This returns True or False – a boolean.

You cannot call the .Click() function on username since booleans don’t have that function

Answered By – The Thonnu

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published