【发布时间】:2019-12-28 17:12:32
【问题描述】:
这是带有类名操作的按钮。我怎样才能只指向这个快餐栏类中的这个按钮。我需要 xpath。
<div class="snackbar-container snackbar-pos bottom-center" style="width: 475px; background: rgb(50, 50, 50); opacity: 1;" xpath="1">
<p style="margin: 0px; padding: 0px; color: rgb(255, 255, 255); font-size: 14px; font-weight: 300; line-height: 1em;">Show similar patients for Jerry Rocker</p>
<button class="action" style="color: rgb(76, 175, 80);">SHOW</button>
</div>
试过这个。 网页元素
snackbarButton=driver.findElement(By.xpath("//button[contains(@class,'action') and contains(@class,'snackbar-pos']"));
<div class="snackbar-container snackbar-pos bottom-center" style="width: 475px; background: rgb(50, 50, 50); opacity: 1;" xpath="1">
<p style="margin: 0px; padding: 0px; color: rgb(255, 255, 255); font-size: 14px; font-weight: 300; line-height: 1em;">Show similar patients for Jerry Rocker</p>
<button class="action" style="color: rgb(76, 175, 80);">SHOW</button>
</div>
【问题讨论】:
-
您好,欢迎来到 stackoverflow。这个问题确实需要您要查找的html示例。请阅读the article 了解一个最小的、可重现的示例
标签: java selenium xpath webdriverwait xpath-1.0