Last active
October 27, 2021 20:17
-
-
Save devhero/226f5299bd4aca1da2bb3c5b11ddbb47 to your computer and use it in GitHub Desktop.
selenium set attribute - http://stackoverflow.com/questions/25583641/set-value-of-input-instead-of-sendkeys-selenium-webdriver-nodejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# retrieve webelement | |
input = driver.find_element_by_xpath("//*[@name='fieldname']") | |
# set attribute from js script referencing webelement found in python code | |
driver.execute_script("arguments[0].setAttribute('value', 'new value!')", input); | |
# or | |
driver.execute_script("arguments[0].setAttribute('value', arguments[1])", input, 'new value!'); | |
# Code for File Upload | |
file_input = driver.find_element_by_id("uploadBtn") | |
file_input.send_keys("/absolute/path/to/file") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks