N
N
Nikita Vereshchagin2020-02-25 05:22:27
Python
Nikita Vereshchagin, 2020-02-25 05:22:27

PYTHON SELENIUM How to activate non-clickable element?

<a href="#" id="workButton0" style="margin-left: 7px;">НАЖАТЬ</a>
<a href="#" id="workButton1" style="margin-left: 7px; display: none;">НАЖАТЬ</a>
<a href="#" id="workButton2" style="margin-left: 7px;">ЗАКРЫТЬ</a>


There are such elements. The buttons change places once in a while.

For example:

workButton0 is
PRESS workButton1 is PRESS hidden
workButton2 is CLOSE

after a minute

workButton0 is PRESS hidden workButton1
is CLOSE
workButton2 is PRESS

etc..

by id it makes no sense for me to search, then how to find an element by text? And how to click on it, because I swore that it was not possible due to the lack of a link.

By XPath, the element is in the browser, but not in the WebDriver. When print, I get either [] or emptiness.

XPath is found only with ctrl+F in code view, but XPath Helper does not see (NULL), plus it does not highlight the element in any way

SOLUTION FOUND!

The button was in a frame, it was necessary to go to the frame. Further from the sheet, only select the visible element)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
coderisimo, 2020-02-25
@Tesold

can be searched by text using xpath

buttons = driver.find_elements_by_xpath("//*[contains(text(), 'TEXT')]")
for btn in buttons:
    btn.click()

if you need to get only visible elements -
is_displayed()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question