D
D
Dmitry Prilepsky2021-07-04 22:46:00
Python
Dmitry Prilepsky, 2021-07-04 22:46:00

How to click on text with no elements to cling to?

There is text when clicked on which opens more text. Its code looks like this:

<span class="">
        <a id="id3cc" href="javascript:;">Текст</a>

        <div id="id3df">
            
        </div>
    </span>

I thought I could stick to the text (it doesn't change) and wrote the following:
button = driver.find_element_by_xpath('//a[contains(text(),"Текст") ]')
driver.execute_script("arguments[0].click();", button)

It works in the debugger but crashes with an error
no such element: Unable to locate element: {"method":"xpath","selector":"//a[contains(text(),"Показать контактную информацию") ]"}
  (Session info: headless chrome=89.0.4389.82)

when I run it without debugging (I tried setting time.sleep because I thought the page was not loading, but it didn't help)
How else can I click on this button?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mihoe9, 2021-09-12
@Mihoe9

Id is

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question