Java 包含多个条件的xpath,这些条件将包含';a';和';分区';标签
下面是完整的HTML标记,我想在其中使用带多个条件的xpathJava 包含多个条件的xpath,这些条件将包含';a';和';分区';标签,java,eclipse,selenium,webdriver,Java,Eclipse,Selenium,Webdriver,下面是完整的HTML标记,我想在其中使用带多个条件的xpath 请求 (020 ) 自动 一个标记位于div标记下面,因此您可以使用下面给出的相对xpath进行此操作: driver.findElement(By.xpath("//div[contains(@id,'5e9b7')]//a[contains(text(),'Compensatory-off Approval')]")) 与OP讨论后更新答案: List<WebElement> elementList = dri
请求
(020 )
自动
一个
标记位于div
标记下面,因此您可以使用下面给出的相对xpath进行此操作:
driver.findElement(By.xpath("//div[contains(@id,'5e9b7')]//a[contains(text(),'Compensatory-off Approval')]"))
与OP讨论后更新答案:
List<WebElement> elementList = driver.findElements(By.xpath("//div[contains(@id,'5e9b7')]//a[contains(text(),'Compensatory-off Approval')]"));
if(elementList.size()>0){
// Element is present
// Do the required operations here
}
List-elementList=driver.findElements(By.xpath(“//div[contains(@id,'5e9b7')]//a[contains(text(),'compensative-off-Approval')]);
if(elementList.size()>0){
//元素存在
//在此处执行所需的操作
}
我有一个包含几个文本标签和几个按钮的代码。我想验证上述条件是否为真,然后单击某个按钮。@vishalgupta您可以通过获取其列表大小来检查元素是否存在于页面上,然后您可以执行所需的操作。我已经在ans中添加了更新的代码,您可以检查一下