Javascript Web元素单击被Selenium中的另一个Web元素阻挡

Javascript Web元素单击被Selenium中的另一个Web元素阻挡,javascript,selenium,selenium-webdriver,Javascript,Selenium,Selenium Webdriver,我无法单击WebElement(按钮),因为它被圆圈隐藏。(叠加) 如何点击按钮 注意-001可以移动圆圈元素。我可以移动圆圈,但有时它会出现在按钮后面 注意-002:我不想使用JavaScript按钮单击功能。(JavascriptExecutor/.executeScript()/.execute()) 如何知道圆圈何时在按钮后面 谢谢大家 Selenium只能复制用户的功能。实际上,用户无法与隐藏元素交互。因此,如果不使用javascript,就不可能单击隐藏按钮 在这种情况下,如果要使

我无法单击
WebElement
(按钮),因为它被圆圈隐藏。(叠加)

如何点击按钮

注意-001可以移动圆圈元素。我可以移动圆圈,但有时它会出现在按钮后面

注意-002:我不想使用JavaScript按钮单击功能。(
JavascriptExecutor
/
.executeScript()
/
.execute()

如何知道圆圈何时在按钮后面


谢谢大家

Selenium只能复制用户的功能。实际上,用户无法与隐藏元素交互。因此,如果不使用javascript,就不可能单击隐藏按钮

在这种情况下,如果要使用javascript:


您可以执行以下操作:

public void foo(){
  try{
     button.click();
  }catch(Exception e){
   /**If I remember correctly, it will be an ElementNotVisible or ElementNotClickable Exception.
   *
   *Here you can move the circle element, possibly using a drag and drop
   *method of the Actions class then click the element one more time.
   */
     actions.dragAndDropBy(circleElement, xOffset, yOffset).perform();
     button.click();
  }
}

public boolean foo(){
  try{
     button.click();
     return true;
  }catch(Exception e){
     return false;
  }
}

public void bar(){
  if(!foo()){
     actions.dragAndDropBy(circleElement, xOffset, yOffset).perform();
     button.click();       
  }
}
public boolean foo(){
  try{
     button.click();
     return true;
  }catch(Exception e){
     return false;
  }
}

public void bar(){
  if(!foo()){
     actions.dragAndDropBy(circleElement, xOffset, yOffset).perform();
     button.click();       
  }
}