Skip to content

Instantly share code, notes, and snippets.

@devhero
Last active October 27, 2021 20:17
Show Gist options
  • Save devhero/226f5299bd4aca1da2bb3c5b11ddbb47 to your computer and use it in GitHub Desktop.
Save devhero/226f5299bd4aca1da2bb3c5b11ddbb47 to your computer and use it in GitHub Desktop.
# 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")
@rakaar
Copy link

rakaar commented Aug 15, 2020

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment