Issue
I want to find value but value is always changing. And name="customerNum" is unique. So I want to use that 2 tag. But when I try, I got error. What is the way to use this 2 tag with "and" maybe.
<div class="gtstep-input-inner">
<input name="customerNum" type="text">
<input type="hidden" value="638367795">
</div>
Solution
x = driver.find_element(By.XPATH, "//input[@type='hidden']").get_attribute('value')
print(x)
Output:
638367795
Process finished with exit code 0
As you said the value changes, it will fetch the value at that point in time (when the line is executed)
If you just want to get that element and not the value in it, then use this:
driver.find_element(By.XPATH, "//input[@type='hidden']")
As per your html in your query, this works to get the input element that has value attribute, i.e., the second input element
Answered By - Anand Gautam
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.