I’m using selenium and beautiful soup with python 3.6. I have page source like the example below. I’m trying to locate the element maybe using the input id and then I want to return the value “5”. I’ve tried the code below but it isn’t working, can anyone suggest how to do this? Any tips are greatly appreciated.

code:

driver.find_element_by_id('UserMaximumFileCount’).Value()

# tstsoup = BeautifulSoup(driver.page_source)

# tstsoup.find_all('value',{'id':'UserMaximumFileCount'})

# driver.findElement(By.id("input_name")).getAttribute("value")

source:

<input id="UserMaximumFileCount" name="UserMaximumFileCount" type="hidden" value="5">

2 Answers

2
supputuri On Best Solutions

Here is the code to get the value using selenium

driver.find_element_by_id('UserMaximumFileCount’).get_attribute('value')
0
Kajal Kundu On

Use Get_attribute value

driver.find_element_by_id("UserMaximumFileCount").get_attribute('value')

Or You can use JavaScripts Executor.

element=driver.find_element_by_name("UserMaximumFileCount")
print(driver.execute_script("return arguments[0].value;", element))