Selenium.common.exceptions.Nosuchelementexception: Message: Unable to locate element: {"method":"id","selector":"//input[contains(@id,

Asked

Viewed 2,376 times

-4

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)

inserir a descrição da imagem aqui

  • 2

    Your question received negative votes because you only showed an error that happens on your machine - it is not possible to reproduce it or verify why it occurs from the information you provided. I use Selenium here and it works perfectly, the problem is in the element you are trying to locate. See here https://answall.com/help/mcve how to ask good questions.

1 answer

1


This error means that at the moment that this line of code is running, the page does not contain any element that matches the criteria (element <input> attribute-ridden id availing '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 are using hasn’t finished executing the part of code that creates the element you want.

The solution in such cases is to wait for the page to load - be it using time.sleep() or any of the waiting functions of selenium.

  • I tested your idea in the code, but the error persists.

  • 2

    @alexjosesilva The error is absolute and definitive - the element does not exist. With the information you’ve given me, that’s all I can offer.

  • Grateful for the collaboration. Really: the element did not exist in the url informed in the search.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.