Meta -
OS: OSX
Selenium Version: 3.0+
Browser: Firefox
Browser Version: 47+
Python Version: 3.3, 3.4
Expected Behavior -
Selenium should be able to follow a redirect and verify html on each page once the redirect is completed.
ex -
beerdb_link = self.browser.find_element_by_id('beerdb')
beerdb_link.click()
self.browser.implicitly_wait(5)
page_heading = self.browser.find_element_by_tag_name('h1')
self.assertIn("Homebrew Materials Database", page_heading.text)
Actual Behavior -
I'm seeing some failures throughout my tests on different lines throwing selenium.common.exceptions.StaleElementReferenceException when checking for text after a redirect even after an implicitly_wait call. Each test failure is on one of 2 lines and does not fail consistently--
/Users/<User>/workspace/Envs/hashtagbrews/bin/python "/Applications/PyCharm 2.app/Contents/helpers/pycharm/django_test_manage.py" test functional_tests.test_simple_model_search.SimpleHopSearchTest.test_user_can_search_hops_page /Users/<User>/workspace/PycharmProjects/hashtagbrews
Testing started at 7:34 AM ...
Creating test database for alias 'default'...
Error
Traceback (most recent call last):
File "/Users/<User>/workspace/PycharmProjects/hashtagbrews/functional_tests/test_simple_model_search.py", line 40, in test_user_can_search_hops_page
self.assertIn("Homebrew Materials Database", page_heading.text)
File "/Users/<User>/workspace/Envs/hashtagbrews/lib/python3.4/site-packages/selenium/webdriver/remote/webelement.py", line 73, in text
return self._execute(Command.GET_ELEMENT_TEXT)['value']
File "/Users/<User>/workspace/Envs/hashtagbrews/lib/python3.4/site-packages/selenium/webdriver/remote/webelement.py", line 494, in _execute
return self._parent.execute(command, params)
File "/Users/<User>/workspace/Envs/hashtagbrews/lib/python3.4/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/Users/<User>/workspace/Envs/hashtagbrews/lib/python3.4/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: The element reference is stale. Either the element is no longer attached to the DOM or the page has been refreshed.
Destroying test database for alias 'default'...
Process finished with exit code 1
/Users/<User>/workspace/Envs/hashtagbrews/bin/python "/Applications/PyCharm 2.app/Contents/helpers/pycharm/django_test_manage.py" test functional_tests.test_simple_model_search.SimpleHopSearchTest.test_user_can_search_hops_page /Users/<User>/workspace/PycharmProjects/hashtagbrews
Testing started at 7:37 AM ...
Creating test database for alias 'default'...
Error
Traceback (most recent call last):
File "/Users/<User>/workspace/PycharmProjects/hashtagbrews/functional_tests/test_simple_model_search.py", line 49, in test_user_can_search_hops_page
page_heading = self.browser.find_element_by_tag_name('h1').text
File "/Users/<User>/workspace/Envs/hashtagbrews/lib/python3.4/site-packages/selenium/webdriver/remote/webelement.py", line 73, in text
return self._execute(Command.GET_ELEMENT_TEXT)['value']
File "/Users/<User>/workspace/Envs/hashtagbrews/lib/python3.4/site-packages/selenium/webdriver/remote/webelement.py", line 494, in _execute
return self._parent.execute(command, params)
File "/Users/<User>/workspace/Envs/hashtagbrews/lib/python3.4/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/Users/<User>/workspace/Envs/hashtagbrews/lib/python3.4/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: The element reference is stale. Either the element is no longer attached to the DOM or the page has been refreshed.
Destroying test database for alias 'default'...
Process finished with exit code 1
I was able to verify that this is working as expected on selenium 2.53 with Firefox 46.
Steps to reproduce -
Run the following test (with or without implicitly_waits):
import unittest
from selenium import webdriver
class TestSelenium(unittest.TestCase):
def setUp(self):
self.browser = webdriver.Firefox()
def tearDown(self):
self.webdriver.quit()
def test_selenium_redirects(self):
self.browser.get('http://www.w3schools.com')
self.browser.find_element_by_link_text('LEARN HTML').click()
h1_text = self.browser.find_element_by_tag_name('h1').text
self.assertIn('HTML', h1_text)
if __name__ == "__main__":
unittest.main()
Result:
selenium.common.exceptions.StaleElementReferenceException: Message: The element reference is stale...
Meta -
OS: OSX
Selenium Version: 3.0+
Browser: Firefox
Browser Version: 47+
Python Version: 3.3, 3.4
Expected Behavior -
Selenium should be able to follow a redirect and verify html on each page once the redirect is completed.
ex -
Actual Behavior -
I'm seeing some failures throughout my tests on different lines throwing
selenium.common.exceptions.StaleElementReferenceExceptionwhen checking for text after a redirect even after an implicitly_wait call. Each test failure is on one of 2 lines and does not fail consistently--I was able to verify that this is working as expected on selenium 2.53 with Firefox 46.
Steps to reproduce -
Run the following test (with or without implicitly_waits):
Result: