Skip to main content
replaced http://sqa.stackexchange.com/ with https://sqa.stackexchange.com/
Source Link

I wrote a javascript snippet as follows after reading replies from the webdriver google group:

wd.execute_script("document.getElementById('allImages').value = '../uploads/b31f8a31-9d4e-49a6-b613-fb902de6a823.jpg';")

Or as SamSam suggested in the comment:

image = wd.find_element_by_id("allImages")
wd.execute_script("arguments[0].value = 'foo.jpg';", image) 

Answer from the webdriver google group:

Using the "execute_script" method is the recommended approach in this case.

No, none in WebDriver, since it aims to imitate a user and a user cannot set attributes directly.

I wrote a javascript snippet as follows after reading replies from the webdriver google group:

wd.execute_script("document.getElementById('allImages').value = '../uploads/b31f8a31-9d4e-49a6-b613-fb902de6a823.jpg';")

Or as Sam suggested in the comment:

image = wd.find_element_by_id("allImages")
wd.execute_script("arguments[0].value = 'foo.jpg';", image) 

Answer from the webdriver google group:

Using the "execute_script" method is the recommended approach in this case.

No, none in WebDriver, since it aims to imitate a user and a user cannot set attributes directly.

I wrote a javascript snippet as follows after reading replies from the webdriver google group:

wd.execute_script("document.getElementById('allImages').value = '../uploads/b31f8a31-9d4e-49a6-b613-fb902de6a823.jpg';")

Or as Sam suggested in the comment:

image = wd.find_element_by_id("allImages")
wd.execute_script("arguments[0].value = 'foo.jpg';", image) 

Answer from the webdriver google group:

Using the "execute_script" method is the recommended approach in this case.

No, none in WebDriver, since it aims to imitate a user and a user cannot set attributes directly.

Adding alternative code as suggested in the comment.
Source Link

I wrote a javascript snippet as follows after reading replies from the webdriver google group:

wd.execute_script("document.getElementById('allImages').value = '../uploads/b31f8a31-9d4e-49a6-b613-fb902de6a823.jpg';")

Or as Sam suggested in the comment:

image = wd.find_element_by_id("allImages")
wd.execute_script("arguments[0].value = 'foo.jpg';", image) 

Answer from the webdriver google group:

Using the "execute_script" method is the recommended approach in this case.

No, none in WebDriver, since it aims to imitate a user and a user cannot set attributes directly.

I wrote a javascript snippet as follows after reading replies from the webdriver google group:

wd.execute_script("document.getElementById('allImages').value = '../uploads/b31f8a31-9d4e-49a6-b613-fb902de6a823.jpg';")

Answer from the webdriver google group:

Using the "execute_script" method is the recommended approach in this case.

No, none in WebDriver, since it aims to imitate a user and a user cannot set attributes directly.

I wrote a javascript snippet as follows after reading replies from the webdriver google group:

wd.execute_script("document.getElementById('allImages').value = '../uploads/b31f8a31-9d4e-49a6-b613-fb902de6a823.jpg';")

Or as Sam suggested in the comment:

image = wd.find_element_by_id("allImages")
wd.execute_script("arguments[0].value = 'foo.jpg';", image) 

Answer from the webdriver google group:

Using the "execute_script" method is the recommended approach in this case.

No, none in WebDriver, since it aims to imitate a user and a user cannot set attributes directly.

Source Link
user1411110
  • 957
  • 4
  • 9
  • 20

I wrote a javascript snippet as follows after reading replies from the webdriver google group:

wd.execute_script("document.getElementById('allImages').value = '../uploads/b31f8a31-9d4e-49a6-b613-fb902de6a823.jpg';")

Answer from the webdriver google group:

Using the "execute_script" method is the recommended approach in this case.

No, none in WebDriver, since it aims to imitate a user and a user cannot set attributes directly.