0

I am working on an automation of a prestashop module.

There is a button that I cannot click on it.

Here is the screenshot and the xpath address element :

enter image description here

Here is the code to click on the button :

driver.findElement(By.xpath("//div[@id='seosa-excel']/div[@class='seosaexcel-content ng-scope']/div[@class='content ng-scope']/combinations-export-templates-form/form[@class='ng-pristine ng-valid ng-scope ng-valid-required']/div[@class='right-column ng-scope ng-isolate-scope']/div[@class='ng-scope'][3]/div[@class='text-right submit-group ng-scope']/button[@class='btn btn-success ng-scope']")).click();

And here is the error message after compilation :

Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Element <button ng-if="templateForm.selectedTemplate !== null" ng-disabled="!templateForm.form.$pristine" type="btn" ng-click="templateForm.export()" class="btn btn-success ng-scope" translate="...">Export</button> is not clickable at point (1848, 909). Other element would receive the click: <div id="footer" class="bootstrap">...</div>

And here is the html code matching the "export" button :

<button ng-if="templateForm.selectedTemplate !== null" ng-disabled="!templateForm.form.$pristine" type="btn" ng-click="templateForm.export()" class="btn btn-success ng-scope xh-highlight" translate="Export">Export</button>

I tried everything I can, but nothing works. It just doesn't click on the button.

Thank you in advance for your advices. Good day to everyone.

2 Answers2

0

In this case, you can try clicking with Js:

IJavaScriptExecutor ex = (IJavaScriptExecutor)Driver;
ex.ExecuteScript("arguments[0].click();", elementToClick);

or using Action:

WebElement button= driver.findElement(By.xpath("\\\zzzz"));
Actions actions = new Actions(driver);
actions.moveToElement(element);
actions.perform();

You are facing this probably because you have a loading on top of your button or it is not enabled.

g__n
  • 179
  • 2
  • 12
0

I guess you need to try one of the next two options:

1- Update the driver.

2- Scroll to the element first to make it clickable:

WebElement button= driver.findElement(By.xpath("//button[text()='Export']"));
IJavaScriptExecutor ex = (IJavaScriptExecutor)driver;
ex.ExecuteScript("arguments[0].scrollIntoView(), button);
button.click();

I hope it works for you.....

Walid Ahmed
  • 243
  • 1
  • 12