I am facing some difficulties scraping a website which uses react.js
and not sure why this is happening.
This is the html of the website:
What I wi
Seems you were close. While using find_element_by_class_name()
you can't pass multiple classes and you are allowed to pass only one classname, i.e. only only one among either of the following:
play-pause-button
btn
btn-naked
On passing multiple classes through find_element_by_class_name()
you will face Message: invalid selector: Compound class names not permitted
As an alternative, as the element is an Angular element, to click()
on the element you have to induce WebDriverWait for the element_to_be_clickable()
and you you can use either of the following Locator Strategies:
Using CSS_SELECTOR
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.play-pause-button.btn.btn-naked")))click()
Using XPATH
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='play-pause-button btn btn-naked']")))click()
Note : You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC