Selenium + firefox: empty execute_script arguments

I am trying to set the value of textarea using the javascript method instead of send_keys ().

As the documentation says, I should be able to pass webelement to execute_script as a parameter and access that parameter through an array of arguments . However, I checked in firefox js console that the arguments are Object, and it doesn’t matter that I set execute_script as an argument. arguments always empty.

 >>>> web = webdriver.Firefox() >>>> web.get("http://somepage.com") >>>> element = web.find_element_by_tag_name("textarea") >>>> web.execute_script("return typeof(arguments)", element) u'object' >>> web.execute_script("return arguments",element) [] 

Does anyone have experience with a similar topic? How can I put webElement as an argument for javascript?

Using Firefox 35.0, selenium 2.44.0.

+4
source share
2 answers

Here is the corresponding error: Firefox 35: Passing executeScript arguments does not work .

What was fixed in selenium 2.45 , which was released today, the selenium update package :

 pip install --upgrade selenium 

Old answer:

I was able to reproduce the problem using selenium==2.44.0 and Firefox 35.0 :

 >>> element = web.find_element_by_tag_name('textarea') >>> web.execute_script("return arguments",element) [] 

Firefox 34.0.5 to Firefox 34.0.5 solved the problem:

 >>> element = web.find_element_by_tag_name('textarea') [<selenium.webdriver.remote.webelement.WebElement object at 0x1022d1bd0>] 
+5
source

Selenium can no longer run javascript with the passed parameters in Firefox starting from version 35. Selenium was able to pass arguments through a kind of backdoor known as __exposedProps__. As part of a general tightening of the external bindings interface (and some of the work funded by all this money that they made from Google), they are deprecated and then removed that interface. Their intention was documented in a notice of refusal in mid-2014 . Selenium bug # 8390 covers it, but I think it took the development team by surprise, and I don’t see any action to switch to another interface, but I believe that WebIDL .

This does not affect other browsers, but Firefox is the fastest and easiest way to test with Selenium. For now, the best web tester for us is to simply switch to Firefox 34 and turn off automatic updates until a resolution is available.

+3
source

Source: https://habr.com/ru/post/1209872/


All Articles