如何在google-chrome-devtools中通过XPath搜索span元素

问题描述 投票:0回答:2

我正在尝试搜索下面的HTML:

<span data-login="true" class="button-tab-links--gray hide-for-medium-only"> Olá, Visitante</span>

运用

//span[@class="button-tab-links--gray hide-for-medium-only"]

在谷歌浏览器上搜索元素但不起作用。我需要改变什么?

Chrome dev tool screenshot of element

selenium google-chrome selenium-webdriver xpath google-chrome-devtools
2个回答
0
投票

如果你想要找到的只是字符串“Ola Visitante”,你可以尝试使用以下方法搜索:

//span[contains(text(), 'Ola Visitante')]

0
投票

根据图像中的这三个(3)信息:

hidden_elements

所需的元素在<iframe>

要通过<span>在XPath中搜索元素,您必须选择所需的<iframe>,单击当前顶部选中的元素。

© www.soinside.com 2019 - 2024. All rights reserved.