Ive been working on the following code in which i try to scrape data from a dynamic website(constantly live changing herokuapp website which displays data taken from a sensor).
While looking for some information i try to use selenium but i doesnt seem to work for me. The following part of the code works well:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome('chromedriver', chrome_options=chrome_options)
driver.get("https://lambda-app-eia.herokuapp.com/")
Now the error appears right here
element = driver.find_element(By.CLASS_NAME, "MuiTypography-root MuiTypography-h4 css-2voflx")
I dont really have experience working with these types of libraries so any help would be highly appreciated.
I am using google colab btw
CodePudding user response:
You are using the class name MuiTypography-root MuiTypography-h4 css-2voflx
which has multiple spaces in it,however in Selenium spaces are not allowed in the class name, you can convert this to CSS selector like below:
element = driver.find_element(By.CSS_SELECTOR, ".MuiTypography-root.MuiTypography-h4.css-2voflx")
Always check in the dev tool whether the locator is unique or not.
Hope this helps.