Как взаимодействовать с IE iframe без идентификатора iframe - PullRequest
0 голосов
/ 02 октября 2019

Мне нужно нажать на div внутри iframe, чтобы начать загрузку. Мне трудно найти элемент iframe, так как у него нет идентификатора. Вот элемент iframe:

<iframe title="data visualization" src="https://sample.com" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" allowfullscreen="true" style="width: 100%; height: 100%; display: block; visibility: visible;" allowtransparency="true"></iframe>

И это элемент div внутри iframe:

<div tabindex="-1" class="tabToolbarButton tab-widget download" role="button" style="width: 95px; -ms-touch-action: none;" aria-label="Download">
    <span class="tabToolbarButtonImg tab-icon-download"></span>
    <span class="tabToolbarButtonText">Download</span>
</div>

1 Ответ

0 голосов
/ 02 октября 2019

Используйте один из его атрибутов. Например,

ie.document.querySelector("[title='data visualization']").contentDocument.querySelector(".tabToolbarButtonText").click 'change this end bit for the appropriate element to click

Возможно

ie.document.querySelector("[title='data visualization']").contentDocument.querySelector(".download").click 'change this end bit for the appropriate element to click

Или это src значение атрибута direct:

ie.Navigate "https://sample.com"

Современные браузеры оптимизированы для селекторов css так что этот метод быстрый. Использование querySelector также останавливается при первом совпадении, что снова приводит к повышению эффективности.

...