selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method": "id", "selector": "// input [contains (@id, [closed]

-5

When using the code:

self.browser.find_element_by_id("//input[contains(@id,'seq')]")

I get the error message:

selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"id","selector":"//input[contains(@id,'seq')]"}
Stacktrace:
    at FirefoxDriver.prototype.findElementInternal_ (file:///c:/users/rc01/appdata/local/temp/tmp_mrf3t/extensions/[email protected]/components/driver-component.js:10770)
    at fxdriver.Timer.prototype.setTimeout/<.notify (file:///c:/users/rc01/appdata/local/temp/tmp_mrf3t/extensions/[email protected]/components/driver-component.js:625)

    
asked by anonymous 24.08.2018 / 20:48

1 answer

1

This error means that at the time this line of code is running, the page does not contain any elements that match the criteria (element <input> with attribute id being 'seq' ).

A common cause for this problem is that modern pages do not load at once - they carry a minimal structure and create the rest of the elements dynamically via javascript code execution.

Maybe the page you're using has not yet finished executing part of the code that creates the element you want.

The solution in these cases is to wait for the page to load - either using time.sleep() or any of the % .

    
24.08.2018 / 21:44