如何获取锚href属性 shown in below screen shot using selenium in Java

问题描述 投票:-2回答:1

如何获取锚href属性中显示在下面的屏幕在Java中使用硒拍

enter image description here

java selenium selenium-webdriver
1个回答
2
投票

如果你想获取锚节点href的值和类名是不是动态的,它是独一无二的,那么你可以做象下面这样:

WebElement elemnent = driver.findElement(By.xpath("//div[@class='_6ks']/a"));
String url = elemnent.getAttribute("href");
System.out.println("=> The URL is : "+url);

如果上面的一个不工作,然后在文本格式共享完整的HTML代码,以便它会很容易让我们跟踪该元素。

© www.soinside.com 2019 - 2024. All rights reserved.