Home > Software design >  How to extract html input value by id with Selenium in Python
How to extract html input value by id with Selenium in Python

Time:01-31

How can I extract the value 4 using elementId maxId in Python.

<input type="hidden" id="maxId" value="4">

Python: 3.11.1, ChromeDriver: 109.0.5414.74

CodePudding user response:

Most probably it would be enough to get the value attribute:

from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome(executable_path='path_to_your_driver')
driver.get("your site")
// Add wait here

driver.find_element(By.ID, "maxId").get_attribute("value")
  • Related