Issue
I am trying to set input field of a Modal Form using Python's Selenium
Here's how the form's input looks like :
<input step="any" class="input" placeholder="0" value="">
I set the input value with this script:
script = "document.querySelector("input.input").value='1'"
driver.execute_script(script)
time.sleep(3)
My script does enter input value in the field but it remains there only for 3 Seconds and that too due time.sleep(3)
, otherwise it resets instantly to 0.
How can I set it to remain there and not to reset?
When I try normally on a HTML page, it does not resets. It does so only on that web page.
Kindly help
Solution
wait=WebDriverWait(driver, 10)
url='https://zapper.fi/?protocol=sushiswap&contractAddress=0xe62ec2e799305e0d367b0cc3ee2cda135bf89816&modal=invest&target=%2Finvest'
driver.get(url)
elem=wait.until(EC.element_to_be_clickable((By.CLASS_NAME,"input")))
elem.send_keys('1')
Send keys didn't change back after a few seconds.
Import:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
Outputs:
Answered By - Arundeep Chohan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.