Jefflee0915
Jefflee0915

Reputation: 183

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

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

Upvotes: 1

Views: 196

Answers (1)

vitaliis
vitaliis

Reputation: 4212

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

Upvotes: 1

Related Questions