Невозможно найти элемент -> щелкните его правой кнопкой мыши -> наведите указатель мыши на контекстное меню, чтобы экспортировать отчет - Использование Selenium Webdriver для python - PullRequest
0 голосов
/ 14 июля 2020

[изображение DOM] [1] ``

//<tr id="hdr_506dbfe0db0e1c9018490ad4e2961934" class="" style="">
<th aria-hidden="true" class="" style=";"></th>
<th name="search" class=" list-decoration-table" style=";">
    <span class="sr-only">Actions</span>
</th>
<th name="number" class="text-align-left list_header_cell list_hdr" 
glide_label="Number"></th>

headers = browser.find_element_by_name ('number') # Эта ошибка исключена

header2 = browser.browser.find_elements_by_tag_name ('th') # это возвращает идентификатор элемента, поэтому не знаю, извлекается ли требуемая информация или нет


Requirement-I need to find the element 'number' right click on it, to open the context menu and hover till the bottom of it, which opens up another context menu to export a report in .xlsx format.

The web page is completely dynamic so @id doesn't work as it changes at every session. I am using selenium webdriver for chrome.

Any guidance on this would be really appreciated. 

I am pretty new to coding, so Pardon me if the way of asking the question is wrong. I will improve as per the guidance of the experts of the forum


  [1]: https://i.stack.imgur.com/m1MaI.png

1 Ответ

0 голосов
/ 14 июля 2020

Во-первых, если html attribute нравится @id меняется на каждой сессии. Вместо этого вам нужно использовать Xpath.

Во-вторых, если это динамическая c веб-страница, некоторые элементы html отображаются и доступны только тогда, когда вы выполняете какое-либо действие. Решение здесь в том, что вам нужно только подождать, когда элемент станет доступен, используя WebDriverWait https://selenium-python.readthedocs.io/waits.html

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...