无法为以下场景找到XPATH
我想从页面获取所有活跃的奖金计划,但问题是总共有三种情形:
- 计划处于激活状态且没有Modified或 Added关键字(包含该关键字的元素根本不会出现)
```html
STI FY26 Non-standard Incentive - AMS APJ Temporary Employees
``` 2.计划处于激活状态,包含Modified或 Added关键字(包含该关键字的元素会出现)。你可以看到下面文本为(空)的div元素存在,同时文本为Removed的 span元素也存在
```html
(empty)
Removed
``` 3.计划未激活/已移除(包含Added或 Modified关键字的元素现在已被移除)。你可以看到该计划仍处于激活状态,因为文本为added关键字的span元素存在,文本为removed或(空)的文本不存在
```html
STI FY26 PfR HPE
Added
```
我想获取未被移除的活跃计划。上述给出的HTML树结构无法得到正确的XPath。
页面上存在多条计划,我只想选择所有活跃的计划,而不选已移除的计划
我已经尝试了以下XPath,但都不起作用
//div[@data-automation-id='decorationWrapper']//not(.//div[@data-automation-id='deltaviewContainer']/span/span[text()='Removed'])
//div[@data-automation-id='decorationWrapper']//div[not(.//div[@data-automation-id='wd-NoValuePresentPlaceholder'])]
//span[@data-automation-id='deltaviewLabel']/span[text()='Added' or text()='Modified']
解决方案
我不太明白你想要表达的意思,但看起来你把 not 当作节点名称使用了,而不是取反。
//div[@data-automation-id='decorationWrapper']//not(.//div[@data-automation-id='deltaviewContainer']/span/span[text()='Removed'])
~~~~~
请改用下面这个:
//div[@data-automation-id='decorationWrapper'
and not(.//div[@data-automation-id='deltaviewContainer']/span/span[text()='Removed'])]
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。