A
A
Andrey Chekhovich2021-02-04 12:55:10
Python
Andrey Chekhovich, 2021-02-04 12:55:10

Why can't I click on a button in Selenium?

Here is my code:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("https://www.instagram.com/accounts/login/")
# Ввод почты
mail = input('Почта:')
mail_input = driver.find_element_by_xpath("/html/body/div[1]/section/main/div/div/div[1]/div/form/div/div[1]/div/label/input")
mail_input.send_keys(mail)
# Ввод пароля
password = input('Пароль:')
password_input = driver.find_element_by_xpath("/html/body/div[1]/section/main/div/div/div[1]/div/form/div/div[2]/div/label/input")
password_input.send_keys(password)
# Клик по кнопке "Войти" UPD: Тут я остановился. Я начал другую версию, она находится в файле sys2.py
click_ = driver.find_element_by_css_selector(".L3NKy").click()
click_.click()


Answer:
Почта:[email protected]
Пароль:lalala
Traceback (most recent call last):
  File "F:\selenium_yandex_search\sys.py", line 17, in <module>
    click_.click()
AttributeError: 'NoneType' object has no attribute 'click'

Why does he say that this attribute does not exist? Is it written all over the Internet that this is how it should work?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MinTnt, 2021-02-04
@t1m0xa

And so, it is clearly seen that

click_ = driver.find_element_by_css_selector(".L3NKy").click()

At the end of this line there is click()
And what do we see on the next line:
click_.click()

The program reads this as something like
driver.find_element_by_css_selector(".L3NKy").click().click()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question