Код: Выделить всё
driver = webdriver.Chrome()
wait = WebDriverWait(driver, 30)
page = driver.get(electric_meter)
user_name ="xxxx"
pw = "xxxx"
wait.until(EC.element_to_be_clickable((By.NAME, "username"))).send_keys(user_name)
sleep(0.11)
wait.until(EC.element_to_be_clickable((By.NAME, "password"))).send_keys(pw)
sleep((0.21))
wait.until(EC.element_to_be_clickable((By.XPATH, "//*[@id='loginForm']/div[4]/button"))).click()
Код: Выделить всё
print(driver.find_element(By.CLASS_NAME, "MeterReadingHistory__content").get_attribute("textContent"))
Код: Выделить всё
Good to know: If you've just submitted a reading, we've got it - it just might take a little while to show up. Perhaps try again tomorrow.DateReading7th Oct 2024Your reading252046th Oct 2024Your reading251984th Oct 2024Your reading251863rd Oct 2024Your...

< /p>
Итак, MeterReadingHistory__content работает, но я хочу, чтобы, когда я пытаюсь извлечь текст из MeterReadingHistorystyled__StyledReadingsContainer-sc-1mqak03-0.cEwaaW, я получаю AttributeError: объект 'NoneType' не имеет атрибут 'get_attribute'
Что мне не хватает?
Изменить
У меня также есть попробовал получить xpath из Chrome, как показано ниже, но снова выдает ту же ошибку нетипа
Код: Выделить всё
print(driver.find_element(By.XPATH, "//*[@id='account-management']/div/section/div/div[2]/div/div[3]/div[1]/div[3]")).get_attribute("textContent")
Подробнее здесь: https://stackoverflow.com/questions/790 ... g-selenium