如果你想获取锚节点的 href 值并且类名不是动态的并且是唯一的,那么你可以这样做:
WebElement elemnent = driver.findElement(By.xpath("//div[@class='_6ks']/a"));
String url = elemnent.getAttribute("href");
System.out.println("=> The URL is : "+url);
如果上述方法不起作用,则以文本格式共享完整的 html 代码,以便我们轻松追踪该元素。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句