有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Selenium如何在div中单击“p”标记

这是html。我需要点击“addBtn”

<div class="shuffle-container">
<p class="addBtn"></p>
<p class="removeBtn"></p >
</div>

驱动程序高亮显示与类“addBtn”相关的按钮,但没有发生单击事件

这是我的selenium代码:

driver.findElement(By.className("addBtn")).click();

共 (1) 个答案

  1. # 1 楼答案

    API开始:

    There are some preconditions for an element to be clicked. The element must be visible and it must have a height and width greater then 0. Since your p element has no content, the width/height is 0.