You may run across errors saying “Element is not clickable at point (x,y). Other element would receive the click: <element>”. This is often due to a fixed element obstructing the element you’re attempting to click, such as a sticky navbar or violator.
webdriver.actions.scroll submodule includes the
scroll.into_view_fixed_nav() function, which scrolls an element into view
relative to a fixed object that may obstruct it. For example, suppose we want to
button_element, but it’s obstructed by a fixed navbar
... # Scroll element to the top of the screen, relative to the fixed nav scroll.into_view_fixed_nav(driver, button_element, nav_element) # Click the button button_element.click()
Despite the name, this function is not limited to objects fixed to the top of
the screen. Setting the optional parameter
align_to_top=False will scroll
the target element into view relative to a fixed element on the bottom of the
screen. E.g. suppose we want to click on
button_element, but it’s obstructed
violator_element which is fixed to the bottom of the screen:
... # Scroll element to the bottom of the screen, relative to the violator scroll.into_view_fixed_nav(driver, button_element, violator_element, align_to_top=False) # Click the button button_element.click()
For more information, see the API documentation for
By default, WebDriverTestCase assertion methods wait 10 seconds for the expected condition to occur before failing. There are some instances where the default assertion wait time might not be long enough for a slower site or page, causing tests to timeout prematurely. This default time can be overridden for a specific assertion, an entire test case, or for the entire test project.
Each of the WebDriverTestCase assertion methods
accepts an optional parameter
wait_timeout, which overrides the default
timeout for a single assertion. E.g.:
If there are many assertions in a test case that are timing out prematurely, you
can set the
DEFAULT_ASSERTION_TIMEOUT attribute, which will be used as the
default timeout value for all assertions in that class. E.g.:
class SlowPageTestCase(WebDriverTestCase): """Example test of a slow page""" SITE_URL = config.SiteConfig.SLOW_PAGE_URL # Set the default timeout for this class to 30 seconds DEFAULT_ASSERTION_TIMEOUT = 30 def test_something(self): """Test a thing""" ... # Will wait 30 seconds self.assertExists(element_locator) def test_something_else(self): """Test another thing""" ... # Will wait 30 seconds self.assertInvisible(element_locator) # wait_timeout parameter takes precedence self.assertUrlChange(expected_url, wait_timeout=10)
You can also set the default timeout for all test cases in a project by setting
class WebDriverConfig(config.WebDriverConfig): ... DEFAULT_ASSERTION_TIMEOUT = 30
As mentioned previously, this default can be overridden per-test case and per-assertion.
Browser-specific WebDrivers occasionally have bugs or quirks specific to them. You may notice that a test is failing in a specific browser due to an exception raised by the driver, rather than an assertion failing, which may be a sign that your test is using a feature that isn’t working or is handled differently in that browser.
Driver-specific issues can be difficult to pinpoint. If the test failure is only happening for a certain browser, or you notice a pattern of tests failing in a browser with similar exceptions, it can be useful to research that issue and see if it’s a known bug or if a workaround exists.
You may also want to check the links to each browser’s Selenium driver in the driver table to see if everything’s up-to-date or if the issue you’re experiencing is documented.
If a workaround can’t be found and the test failure seems to be a browser-specific driver issue, you can skip these tests for the problem browser. See Skipping tests for certain browsers for more info.
When troubleshooting a test, it can be useful to take screenshots to get a visual of the window during testing. This framework includes utilities for taking screenshots on test failure or at arbitrary points of a test. See the Screenshots documentation for details.
When troubleshooting, it can be helpful to pause test execution at certain
points review things step-by-step. A simple way to insert a pause is using
input() function. This function is meant to be used to prompt for
user input, but it can also be used to pause a test until hitting ‘Enter’,
allowing you to look at the browser window before continuing. E.g.:
... def test_pause_example(self): ... # This will pause test execution until you hit enter # NOTE: you don't need to pass any parameters to input, this is just what # will be printed to standard output input('Paused') ...
If the issue you’re encountering appears to be with
specifically (rather than with Selenium or a specific browser driver), you can
report the issue on GitHub. Before creating the issue:
Make sure you’re using the most up-to-date version of the
webdriver_test_toolspackage (e.g. run
pip install --upgrade webdriver_test_tools)
Check the open GitHub Issues to see if the issue has already been reported
If the issue hasn’t been reported yet but appears to be related to Selenium, check Selenium’s GitHub Issues to see if the issue has already been reported
If the issue isn’t reported there and appears to be specific to WebDriver Test Tools, open a new issue and fill out the required details, being as specific as possible.