小编Raf*_*ini的帖子

使用 Selenium 和 Python 查找存在 data-tb-test-id 属性而不是 id 的元素

我正在尝试使用 Selenium 查找元素,但没有找到。请遵循 HTML 代码:

\n\n
<div aria-disabled="false"\n     data-tb-test-id="DownloadCrosstab-Button"\n     role="button"\n     tabindex="0"\n     style="font-size: 12px; font-weight: normal; color: rgba(0, 0, 0, 0.7); display: inline-block; padding: 0px 24px; position: relative; text-align: center; border-style: solid; border-width: 1px; border-radius: 1px; height: 24px; line-height: 22px; min-width: 90px; box-sizing: border-box; outline: none; white-space: nowrap; user-select: none; cursor: default; background-color: rgba(0, 0, 0, 0); border-color: rgb(203, 203, 203); margin-top: 8px; width: 100%; -webkit-tap-highlight-color: transparent;"\n>Tabela de refer\xc3\xaancia cruzada</div>\n
Run Code Online (Sandbox Code Playgroud)\n\n

我已经尝试过以下代码:

\n\n
x = browser.find_element_by_id("Downloadcrosstab")\nx = browser.find_element_by_link_text("Downloadcrosstab-Button")\nx = browser.find_element_by_class_name(\'Crosstab\')\n
Run Code Online (Sandbox Code Playgroud)\n\n …

python selenium xpath css-selectors webdriverwait

7
推荐指数
2
解决办法
4万
查看次数

标签 统计

css-selectors ×1

python ×1

selenium ×1

webdriverwait ×1

xpath ×1