How to send text to an input element with type attribute as hidden using python and selenium
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()
For clicking on Get Likes button you can use this code :
get_likes = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "get_likes_button")))
After that if input type changed from type='hidden'
, you can interact with input field as :
input_field = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.NAME, "id")))
It's quite strange to see HTML like this :
<input name="id">
By the way, hope this will help.
Try below snippet. Hope this will help you.
WebDriver driver = new FirefoxDriver();driver.navigate().to(URL); JavascriptExecutor javascriptExecuter = (JavascriptExecutor)driver;javascriptExecuter.executeScript("document.getElementsByName('id')[0].value='452525252525';");driver.findElement(By.id("get_likes_button")).submit();