contains(., 'some text') 是指 Selenium 中使用的 xpath 中的内容 [英] What does contains(., 'some text') refers to within xpath used in Selenium

查看:33
本文介绍了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">xpathtext()

例如,如果 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:

    这篇关于contains(., 'some text') 是指 Selenium 中使用的 xpath 中的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆