Selenium freezes after waiting for element (Python) -
we're using python bindings of selenium , django-selenium (seleniumtestcase) doing selenium tests. on our tested page there html elements created after seconds delay. want wait them , continue test. waiting works, every command after wait call fails:
class sometestcase(seleniumtestcase): def test_something(self): ... (some testing code works) self.driver.wait_element_present('span.available') # works self.driver.wait_element_present('span.connected') # works, self.driver.find_element_by_css_selector('body') # fails
i debugged through selenium code , found out "find_element_by_css_selector" internally posts http request selenium server (as on every "check if xxx there" command):
http://127.0.0.1:42735/hub/session/<session-id>/element
but request returns status code 500 , response text:
{ "status": 13, "value": { "message": "json.parse: unexpected non-digit", "stacktrace": [ { "methodname": "dispatcher.executeas/<", "filename": "file:///tmp/tmpnut34u/extensions/fxdriver@googlecode.com/components/driver_component.js", "linenumber": 7354 }, { "methodname": "resource.prototype.handle", "filename": "file:///tmp/tmpnut34u/extensions/fxdriver@googlecode.com/components/driver_component.js", "linenumber": 7516 }, { "methodname": "dispatcher.prototype.dispatch", "filename": "file:///tmp/tmpnut34u/extensions/fxdriver@googlecode.com/components/driver_component.js", "linenumber": 7463 }, { "methodname": "webdriverserver/<.handle", "filename": "file:///tmp/tmpnut34u/extensions/fxdriver@googlecode.com/components/driver_component.js", "linenumber": 10152 }, { "filename": "file:///tmp/tmpnut34u/extensions/fxdriver@googlecode.com/components/httpd.js", "linenumber": 1935 }, { "methodname": "serverhandler.prototype.handleresponse", "filename": "file:///tmp/tmpnut34u/extensions/fxdriver@googlecode.com/components/httpd.js", "linenumber": 2261 }, { "methodname": "connection.prototype.process", "filename": "file:///tmp/tmpnut34u/extensions/fxdriver@googlecode.com/components/httpd.js", "linenumber": 1168 }, { "methodname": "requestreader.prototype._handleresponse", "filename": "file:///tmp/tmpnut34u/extensions/fxdriver@googlecode.com/components/httpd.js", "linenumber": 1616 }, { "methodname": "requestreader.prototype._processbody", "filename": "file:///tmp/tmpnut34u/extensions/fxdriver@googlecode.com/components/httpd.js", "linenumber": 1464 }, { "methodname": "requestreader.prototype.oninputstreamready", "filename": "file:///tmp/tmpnut34u/extensions/fxdriver@googlecode.com/components/httpd.js", "linenumber": 1333 } ] } }
as result whole test run blocks , aborted after default timeout. according https://code.google.com/p/selenium/wiki/jsonwireprotocol status 13 means "unknownerror" not make things more clear ;-)
has discovered this, too? there way solve this? not know exact cause be, our page structure clean html code. suggestions!
late party, but--
wait_element_present not selenium binding. it's custom class library called mydriver https://django-selenium.readthedocs.org/en/latest/#mydriver-class
selenium explicit waits more simple function: http://selenium-python.readthedocs.org/waits.html#explicit-waits
find_element_by_css_selector selenium binding webdriver, , mydriver not have method name.
to use custom classes run selenium webdriver, you'll need use methods provides (or write own). in case, mydriver has method called find accepts css selector argument , returns element, accomplishes wanted find_element_by_css_selector. https://github.com/dragoon/django-selenium/blob/master/django_selenium/testcases.py
Comments
Post a Comment