如何使用Selenium WebDriver中的java在锚标记内单击属性为role =“button”的元素?
Ex:(a="#" class="xyz "role="button")
> (span class="ABC")close(/span)
> (/a)
我只想点击此关闭按钮,但不使用范围文本。
答案 0 :(得分:1)
使用xpath或css选择器
Xpath -
//a[@role = 'button']
Css - a[role = 'button']
答案 1 :(得分:0)
参考下面的代码,
WebElement element = driver.findElement(By.xpath("//a[@role = 'button']"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);