Selenium webdriver Robotframework Selenium2执行Javascript

Selenium webdriver Robotframework Selenium2执行Javascript,selenium-webdriver,robotframework,Selenium Webdriver,Robotframework,我将Robotframework与selenium2结合使用&试图在Firefox上执行Javascript。 我尝试了大量不同的语句,例如: Execute Javascript (function(){alert('hello'); return {'test':'hello'};})() 但它们都失败了,只有一个例外。我只是在Firefox(22和23)上遇到了问题,但是Chrome很好。这是我在使用pybot——loglevel debug运行时在log.html中看到的 KEY

我将Robotframework与selenium2结合使用&试图在Firefox上执行Javascript。 我尝试了大量不同的语句,例如:

Execute Javascript    (function(){alert('hello'); return {'test':'hello'};})()
但它们都失败了,只有一个例外。我只是在Firefox(22和23)上遇到了问题,但是Chrome很好。这是我在使用pybot——loglevel debug运行时在log.html中看到的

KEYWORD: Selenium2Library.Execute Javascript (function(){alert('hello'); return {'test':'hello'};})()
Documentation:  
Executes the given JavaScript code.
Start / End / Elapsed:  20130812 16:58:35.184 / 20130812 16:58:46.934 / 00:00:11.750
Expand AllKEYWORD: Selenium2Library.Capture Page Screenshot
16:58:35.185    INFO    Executing JavaScript:
(function(){alert('hello'); return {'test':'hello'};})()
16:58:35.185    DEBUG   POST http://127.0.0.1:54281/hub/session/df0916e9-1bf1-fa42-98c5-c3d7a981c096/execute {"sessionId": "df0916e9-1bf1-fa42-98c5-c3d7a981c096", "args": [], "script": "(function(){alert('hello'); return {'test':'hello'};})()"}
16:58:46.934    FAIL    WebDriverException
16:58:46.934    DEBUG   Traceback (most recent call last):
  File "<string>", line 2, in execute_javascript
  File "/Users/will/apps/OMERO.libs/lib/python2.6/site-packages/Selenium2Library/keywords/keywordgroup.py", line 12, in _run_on_failure_decorator
    return method(*args, **kwargs)
  File "/Users/will/apps/OMERO.libs/lib/python2.6/site-packages/Selenium2Library/keywords/_javascript.py", line 92, in execute_javascript
    return self._current_browser().execute_script(js)
  File "/Users/will/apps/OMERO.libs/lib/python2.6/site-packages/selenium/webdriver/remote/webdriver.py", line 397, in execute_script
    {'script': script, 'args':converted_args})['value']
  File "/Users/will/apps/OMERO.libs/lib/python2.6/site-packages/Selenium2Library/webdrivermonkeypatches.py", line 11, in execute
    result = self._base_execute(driver_command, params)
  File "/Users/will/apps/OMERO.libs/lib/python2.6/site-packages/selenium/webdriver/remote/webdriver.py", line 165, in execute
    self.error_handler.check_response(response)
  File "/Users/will/apps/OMERO.libs/lib/python2.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 158, in check_response
    raise exception_class(message, screen, stacktrace)
然后测试通过了,但我仍然没有真正执行javascript

另一个更新-我发现这个问题只影响Firefox22和23。如果我回到Firefox 21,那么它工作正常。

当我尝试时:

Execute Javascript    (function(){alert('hello'); return {'test':'hello'};})()
我在Firefox35中看到了警报弹出窗口

Execute Javascript    (function(){alert('hello'); return {'test':'hello'};})()