contains(., 'some text') 是指 Selenium 中使用的 xpath 中的内容 [英] What does contains(., 'some text') refers to within xpath used in Selenium
本文介绍了contains(., 'some text') 是指 Selenium 中使用的 xpath 中的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是 selenium 编码的新手,我看到几个 xpath 包含 (.,'followed by something') ., 指的是什么?
I am new to selenium coding, and I am seeing several xpaths that contain (.,'followed by something') what does the ., refer to?
推荐答案
.
字符="post-tag" title="show questions tagged 'xpath'" rel="tag">xpath 是 text()
例如,如果 WebElement 在 DOM 树 中表示为:
As an example if an WebElement is represented within the DOM Tree as:
<span>Use this payment method</span>
有效的定位器策略将是:
xpath 1:
//span[text()='Use this payment method']
xpath 2:
//span[contains(., 'Use this payment method')]
您可以在以下位置找到一些相关讨论:
You can find a couple of relevant discussions in:
- 如何定位按钮通过 Python 使用 Selenium 的元素
- 在获取所有链接时,忽略循环中的注销链接并继续在 selenium java 中导航
- xpath中的dot(.)如何在识别元素和匹配文本时采取多种形式
这篇关于contains(., 'some text') 是指 Selenium 中使用的 xpath 中的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文