Here is the sample HTML test.html:
<html>
<div class="h1 mb-4 font-weight-normal nh-read__title"> Test Title </div>
<html>
I tried to get the <div>
by selenium:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
import selenium.webdriver.support.expected_conditions as EC
driver = webdriver.Chrome()
driver.get("file://test.html")
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.CLASS_NAME, "h1 mb-4 font-weight-normal nh-read__title"))
)
The page loads instantly, however after 10 seconds, it raises a selenium.common.exceptions.TimeoutException
error.
I'm not sure what's wrong here since I can get any other element with this code (get by id, ...). I want to get the above <div>
by class name only.
The version of chromedriver and python I'm using is 111 and 3.10.