I'm new to python and selenium. I want to click on the get_likes_button
and I need to send the value = 1803345990687013485 when doing that.
Here's the HTML
<form action="" method="post" accept-charset="utf-8"><span style="font-size: 14px;">
<i class="fa fa-heart" style="color: #F12938;"></i> 20 </span>
<input type="hidden" value="1803345990687013485" name="id">
<button class="btn btn-primary pull-right" type="submit" name="submit"
id="get_likes_button"> Get Likes </button> </form></b>
Here's the code
driver.find_element_by_xpath("//input[@name='id']").send_key('1803345990687013485')
driver.find_element_by_id('get_likes_button').submit()
I get the following message
Exception: Message: Element not visible.
This error message...
Exception: Message: Element not visible.
...implies that the desired element is not visible.
The main issue is the <input>
tag is having an attribute type="hidden"
.
To send the character sequence 1803345990687013485 to the input field and invoke click()
on the button you can use the following solution:
driver.execute_script("document.getElementsByName('id')[0].setAttribute('type','text')")
driver.find_element_by_xpath("//input[@name='id']").send_key('1803345990687013485')
driver.find_element_by_xpath("//button[@class='btn btn-primary pull-right' and @id='get_likes_button']").click()