selenium - 硒 - 如何找到 xpath
问题描述
谁能帮我找到给定链接的正确 xpath注销
解决方案
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
推荐阅读
- python - AttributeError:“_io.TextIOWrapper”对象没有属性“rpartition”
- reactjs - 为什么我的本地存储在页面刷新后没有保存
- python - 神经网络攻击傻瓜(FGSM)
- microsoft-graph-api - 通过 msgraph 搜索 Sharepoint 列表和文档
- java - 如何根据选择的主题显示不同的启动画面?
- php - 在 Laravel 中生成上传视频的缩略图
- vb.net - 动态文本框颜色变化
- java - Kd 树级顺序遍历
- fortran - 使用 OpenMP 并行的矩阵乘法不会提高执行时间
- java - 可以在 ANT 任务的类路径中引用 Spring Boot jar 中的类吗?