Python: 3.11.1, ChromeDriver: 109.0.5414.74" /> Python: 3.11.1, ChromeDriver: 109.0.5414.74" /> Python: 3.11.1, ChromeDriver: 109.0.5414.74"/>

How to extract html input value by id with Selenium in Python

162 views Asked by At

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

1

There are 1 answers

0
vitaliis On BEST ANSWER

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")