使用正则表达式在 XPath 中查找特定模式。

huangapple go评论77阅读模式
英文:

Finding a specific pattern using regex in xpath

问题

我想使用正则表达式在xpath中查找特定文本。

这是我的xpath:

locator://*[@class = 'android.widget.TextView' and contains(@text,'PriceBottomBarDialog-selector')]

这个"PriceBottomBarDialog-selector"保持不变,开头的文本会不断改变。有谁可以帮忙提供正则表达式模式?

谢谢

英文:

I want to find a specific text using regex in a xpath.

This is my xpath:

locator: //*[@class = 'android.widget.TextView' and contains(@text,'PriceBottomBarDialog-selector')]

This "PriceBottomBarDialog-selector" remains constant, the beginning text keeps changing. Can anyone please help with the regex pattern?

Thank you

答案1

得分: 1

你已经接近成功了。你需要修复[tag:xpath]部分,并且可以使用定位策略

  • Xpath:

    定位器://*[@class = 'android.widget.TextView' and contains(.,'PriceBottomBarDialog-selector')]
    
英文:

You were close. You need to fix up the [tag:xpath] and you can use the Locator Strategy:

  • Xpath:

    locator: //*[@class = 'android.widget.TextView' and contains(.,'PriceBottomBarDialog-selector')]
    

huangapple
  • 本文由 发表于 2020年8月15日 05:57:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/63420491.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定