pythonseleniumcontenteditablewebdriverwaitnosuchelementexception

How to find the find the div element using Selenium and Python


Selenium is unable to find an element on a webpage, here is the python code

element = driver.find_element(By.CLASS_NAME, "_13NKt copyable-text selectable-text")

Here is an image of the element it is supposed to find, class highlighted

html code

And here is the important line of the error message:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"._13NKt copyable-text selectable-text"}
  (Session info: chrome=103.0.5060.134)

Solution

  • You have to take care of a couple of things here:


    Solution

    To identify the element you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following locator strategies: