Cannot get to Input element value, please help

45 views
Skip to first unread message

Sergey Birger

unread,
May 14, 2021, 1:11:51 AM5/14/21
to Selenium Users
Hello,
I am trying to extract the value stored in the form field through Selenium Webdriver using Python, and even though I can see the value on the screen ("sHO_SB51_Upscore" in the image below), as you can see in Inspect Element window below it, there is nothing like this in HTML--no value, no attribute to pull out. How does this value get rendered?

snap_screen_20210513235555.png

If I try
test = driver.find_element_by_id("txtNewRuleName").text
it comes back as blank ('').

I can click on the field just fine, eg
test = driver.find_element_by_xpath("//input[@id='txtNewRuleName']").click()
but how to I get the value stored in the field of this form?

Thanks!

Sergey Birger

unread,
May 14, 2021, 1:37:11 AM5/14/21
to Selenium Users
Never mind, found solution myself using a tip on another forum:
                test = driver.find_element_by_xpath("//input[@id='txtNewRuleName']").get_attribute("value")
or
                test = driver.find_element_by_id("txtNewRuleName").get_attribute("value")
does the job.

That said,  if anyone has any idea how I can get to the attribute not present in Inspect Element HTML, I'd appreciate it. 
Is there a reliable way to see all attributes I can pull for the element?

Márton Karczub

unread,
May 18, 2021, 5:44:36 AM5/18/21
to Selenium Users
Similar happened to me some days ago. In my case the value was reflected in an ancestor (wrapper) element of the input from where it can be got by attribute. Hope this helps someone :)
Reply all
Reply to author
Forward
0 new messages