-1

I am following a guide on youtube to build a scraper of the website which requires login. However I am facing a problem with the login button click.

Here is the code so far I am using. It open the website, however it does not press the login button.

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

from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(ChromeDriverManager().install())

url = "https://www.URL.COM"
username = 'username'
password = 'password'

driver.get(url)

driver.find_element_by_class_name("login-top ng-scope").click()

The inspect of the login button looks like this:

enter image description here

Any suggestions how to solve the problem?

doviis
  • 51
  • 1
  • 6
  • Does this answer your question? [Compound class names not permitted error Webdriver](https://stackoverflow.com/questions/32043877/compound-class-names-not-permitted-error-webdriver) – JaSON Oct 27 '20 at 15:05
  • Update the title with the question (current title is senseless and doesn't reflect the issue) and add exception log to problem description as it's quite broad – JaSON Oct 27 '20 at 15:11

2 Answers2

1

It seems Synchronization issue.

Induce WebDriverWait() and wait for element_to_be_clickable() and use the following css selector.

driver.get("https://www.heo.com/")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.login-top.ng-scope > p.log"))).click()

You need to import below libraries.

from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
KunduK
  • 32,888
  • 5
  • 17
  • 41
0

You can use find_element_by_xpath instead find_element_by_class_name. Xpath for your case will look like this: //div[@data-ng-click='showLogin()']/p.

Code example:

driver.find_element_by_xpath("//div[@data-ng-click='showLogin()']/p").click()
Evgeniy Chiruk
  • 358
  • 1
  • 10
  • Hi, thanks for the comment. I got the same error as previous times. Uploaded photo here due to lack of characters to paste here. https://ibb.co/tL1Qp3t – doviis Oct 27 '20 at 14:20