首页 > 解决方案 > 硒 - 如何找到 xpath

问题描述

谁能帮我找到给定链接的正确 xpath注销

标签: seleniumselenium-webdriverselenium-chromedriver

解决方案


driver.findElement(By.xpath("//a[text()='Logout']"))

是一种方式。

driver.findElement(By.linkText("Logout"));

如果页面上有超过1 个 注销 链接,两者都可能有问题。

有关选择元素的更多资源:https ://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/By.html


推荐阅读