Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium+firefox: empty execute_script arguments

I'm trying to set textarea value using javascript instead send_keys() method.

As documentation says, I should be able to pass webelement to execute_script as parameter and refer to this parameter via arguments array. However, I've checked in firefox js console, that arguments is Object and it doesn't matter what i put as execute_script argument - arguments is always an empty object.

>>>> 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)
[]

Anyone has any experience with similarly subject? How can I put webElement as argument for javascript?

Using Firefox 35.0, selenium 2.44.0.

like image 514
ASmith78 Avatar asked Feb 12 '23 03:02

ASmith78


1 Answers

Here is the relevant bug: Firefox 35: Passing arguments to executeScript isn't working.

Which was fixed in selenium 2.45 which was released today, upgrade selenium 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)
[]

Downgrading to Firefox 34.0.5 solved the issue:

>>> element = web.find_element_by_tag_name('textarea')
[<selenium.webdriver.remote.webelement.WebElement object at 0x1022d1bd0>]
like image 169
alecxe Avatar answered Feb 13 '23 21:02

alecxe