[英]Selenium+firefox: empty execute_script arguments
I'm trying to set textarea
value using javascript instead send_keys() method. 我正在尝试使用javascript而不是send_keys()方法设置textarea
值。
As documentation says, I should be able to pass webelement to execute_script as parameter and refer to this parameter via arguments
array. 正如文档所说,我应该能够将webelement传递给execute_script作为参数,并通过arguments
数组引用此参数。 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. 但是,我已经在firefox js控制台中检查过, arguments
是Object,并且我将它作为execute_script参数放置并不重要 - arguments
始终是一个空对象。
>>>> 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? 如何将webElement作为javascript的参数?
Using Firefox 35.0, selenium 2.44.0. 使用Firefox 35.0,selenium 2.44.0。
Here is the relevant bug: Firefox 35: Passing arguments to executeScript isn't working . 以下是相关的错误: Firefox 35:将参数传递给executeScript不起作用 。
Which was fixed in selenium 2.45 which was released today, upgrade selenium package : 这是在今天发布的硒2.45中修复的, 升级硒包 :
pip install --upgrade selenium
Old answer: 老答案:
I was able to reproduce the problem using selenium==2.44.0
and Firefox 35.0
: 我能够使用selenium==2.44.0
和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: 降级到Firefox 34.0.5
解决了这个问题:
>>> element = web.find_element_by_tag_name('textarea')
[<selenium.webdriver.remote.webelement.WebElement object at 0x1022d1bd0>]
Selenium can no longer execute javascript with passed parameters in Firefox, as of version 35. Selenium has been able to pass in arguments via a kind of backdoor known as __exposedProps__. 在版本35中,Selenium无法再使用Firefox中传递的参数执行javascript .Selenium已经能够通过一种称为__exposedProps__的后门传递参数。 As part of an overall tightening up of the external bindings interface (and some busywork, financed by all of that money they made from Google), they deprecated, and then removed, this interface. 作为整体收紧外部绑定界面的一部分(以及一些繁忙的工作,由他们从谷歌提供的所有资金资助),他们弃用,然后删除了这个界面。 Their intention was documented in a deprecation notice in mid-2014 . 他们的意图记录在2014年中期的弃用通知中 。 Selenium bug #8390 covers it, but I take it this caught the dev team by surprise and I don't see any activity to migrate to another interface yet, which I presume will be WebIDL . Selenium bug #8390涵盖了它,但我认为这让开发团队感到意外,我没有看到任何活动迁移到另一个界面,我认为这将是WebIDL 。
It doesn't affect other browsers, but Firefox is by far the quickest and easiest method of testing with Selenium. 它不会影响其他浏览器,但Firefox是迄今为止使用Selenium进行测试的最快捷,最简单的方法。 Currently, the best option for us web testers is to just downgrade to Firefox 34 and turn off automatic updates until a resolution is available. 目前,我们网络测试人员的最佳选择是降级到Firefox 34并关闭自动更新,直到有可用的分辨率。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.