简体   繁体   English

Selenium + firefox:空的execute_script参数

[英]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.0Firefox 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.

相关问题 Python Selenium如何在带参数的JavaScript元素上执行execute_script - Python selenium how to execute execute_script on a JavaScript element with arguments 带换行符的 selenium execute_script - selenium execute_script with newlines Python和Selenium以“execute_script”来解决“ElementNotVisibleException” - Python and Selenium To “execute_script” to solve “ElementNotVisibleException” Selenium 中的 execute_script() 有什么作用 - What does execute_script() in Selenium does Seleneium 异常 - arguments[0].click 不是在 Selenium Python 中使用 execute_script() 的函数 - Seleneium exceptions - arguments[0].click is not a function using execute_script() in Selenium Python 通过Selenium和Python通过WebDriver实例调用execute_script()方法时,arguments [0]是什么? - What is arguments[0] while invoking execute_script() method through WebDriver instance through Selenium and Python? selenium.common.exceptions.WebDriverException:消息:未知错误:arguments [0] .click不是在Selenium Python中使用execute_script()的函数 - selenium.common.exceptions.WebDriverException: Message: unknown error: arguments[0].click is not a function using execute_script() in Selenium Python JavaScript单击在控制台中有效,但在Selenium execute_script中无效 - JavaScript click works in console but not inside Selenium execute_script 更改 src 属性 execute_script selenium python - Change src attribute execute_script selenium python 如何在 Selenium Python execute_script 中获取返回元素的值? - How to get value of returned element in Selenium Python execute_script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM