【问题标题】:Using the OR logical function in the "starts with" condition for finding the xpath在“开始于”条件下使用 OR 逻辑函数来查找 xpath
【发布时间】:2019-12-17 20:55:04
【问题描述】:

我使用下面的 X-path 根据起始条件提取 Web 元素

//a[starts-with(@href,'https://test-abc-eu.softcore.com')]

我想通过向搜索添加逻辑 OR 条件来扩大搜索范围。任何以

开头的东西
//a[starts-with(@href,'https://test-abc-eu.softcore.com')]
//a[starts-with(@href,'https://test-abc.softcore.com')]

有点像

//a[starts-with(@href,'https://test-abc-eu.softcore.com' or @href,'https://test-abc.softcore.com')]

这可能吗? 任何帮助,将不胜感激。 谢谢。

【问题讨论】:

标签: python python-3.x selenium selenium-webdriver xpath


【解决方案1】:

正确的语法是:

//a[starts-with(@href,'http://test-abc.softcore.com') or starts-with(@href,'https://test-abc-eu.softcore.com')]

演示:

如您所见,两个链接都匹配。

参考资料:

【讨论】:

    猜你喜欢
    • 2021-10-08
    • 2021-11-10
    • 1970-01-01
    • 2018-05-04
    • 2015-01-05
    • 1970-01-01
    • 2018-08-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多