0

I am using Angular Js application. And auotmating using selenium and Java.Whenever I try clicking on on button getting exception as.

 Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Element <button .</button> is not clickable at point (502, 85). Other element would receive the click: <div class="col-sm-12 move-buttons">...</div>

Tried many option but none worked. Any solution is welcomed. Thanks in Advance.!! This is the div which looks like

    <div class="col-sm-1">
<div class="row zhide-buttons" xpath="1"> 
  <div class="col-sm-12 move-buttons"> 
   class="btn btn-primary move-button ng-scope" ng-disabled=""> <i class="fa fa-plus fa-2x"></i> </button><!-- end ngIf: 

   <i class="fa fa-minus fa-2x"></i> </button>
  </div> 
 </div>

I tried using with xpath 1.//div[contains(@class,'col-sm-1')]//button[1] 2.//i[@class='fa fa-plus fa-2x'] 3.using the x,y coordainate using Action Class

wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[contains(@class,'col-sm-1')]//button[1]")));

Here is my sample code

WebElement element= driver.findElement(By.xpath("//div[contains(@class,'col-sm-1')]//button[1]"));

js.executeScript("arguments[0].scrollIntoView(true);",element);
js.executeScript("arguments[0].click();", element); 

Also I tried normal locating element and clicking onto it. This also gives same error.

So ultimately I am not able to click on this button

Rahul
  • 1
  • 1

1 Answers1

1

Have you tried using Action Class -

WebElement element = driver.findElement(By("element"));
Actions action = new Actions(driver);
action.moveToElement(element).click().perform();

or

WebElement elementToClick = driver.findElement(By.xpath("Your xpath"));((JavascriptExecutor)driver).executeScript("window.scrollTo("+elementToClick.getLocation().x+","+elementToClick.getLocation().y+")"); elementToClick.click();

or

WebDriverWait wait = new WebDriverWait(driver, TIME_IN_SECONDS);
wait.until(ExpectedConditions.elementToBeClickable(By.className("element-class-name")));
  • Thanks for you response. code worked for me using code snippet below .js.executeScript("window.scrollBy(1000,document.body.scrollHeight)"); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); WebElement addXYZ = driver.findElement(By.xpath("//i[@class='fa fa-plus fa-2x']")); JavascriptExecutor jse2 = (JavascriptExecutor)driver; jse2.executeScript("arguments[0].scrollIntoView()", addXYZ); – Rahul May 15 '20 at 13:58