Selenium – Chrome driver, element is not clickable at point.

While automating a website I’ve stumbled acorss a problem that seemed only to happen on Chrome browser alone.

The problem was that, after finding a webelement that I wanted to click, the chrome driver threw out: “Element is not clickable at point (x, y)” . The thing is that it happened only on Chrome, for example using gecko-driver I had no problems with finding that element and clicking on it.

Seems like it is a known bug, where if the element is behind or under another element chrome driver tries to click in the middle of it and it fails.

The solution was found here:

https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/2766

Solution that worked for me:

WebElement button = driver.findElement(By.id("buttonID"));

((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", button);

button.click();

Selenium 3 – Gecko driver, Firefox Browser

After upgrading from Selenium 2.x to Selenium my tests stopped to work. The error that I was getting was this:

java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property;

After taking a look at change log I’ve discovered that the support of Firefox browser is now through the Gecko driver. That was a new thing for me, so after googling around and trying to solve the issue, this was what I’ve found.

Adding this helped me solve the problem:

System.setProperty("webdriver.gecko.driver","path of geckodriver");
WebDriver driver = new FirefoxDriver();

 

Selenium – How to grab Dojo listboxes

Lately I was writing automation tests for a web applications that was using Dojo Toolkit. One of the problems that I’ve encountered was that I was not able to select an item from what seemed like a regular dropdown menu. With normal dropdowns that have “select” tag in html Selenium has a simple way to grab them

Select dropdown = new Select(driver.findElement(By.id("identifier")));

and you can select the values either by

dropdown.selectByVisibleText("TEST ");

or by index

dropdown.selectByIndex(1);

But when I was digging deeper it seemed like the dojo element handled “dropdowns” in a different way. They are tables with only one row but many columns. The problem comes when you try to select the values in them.

When you go through the elements in the table one by one and print out the text of each item in the table the getText() method prints either “null” or an empty string. The solution to this problem is that the elements found in that table are found under dijitMenuItemLabel class and in my case had an id attirbute with

In my case I wanted my code to be flexible and select always the last item in the dropdown menu. The idea behind the next code snippet is that it cycles through an array of all the elements that i found previous, matches them by the id of the element and does something based on which element it matches.

In this case if it finds an element that has an attribute id that contains “Select” it goes in to this:

// find the dropdown button e being an element that we currently going through
WebElement dropDownButton = driver.findElement(By.xpath("//table[@id='" + e.getAttribute("id") + "']/tbody/tr/td"));
// click on it
dropDownButton.click();
// find all of the elements inside the dropdown menu,
List<WebElement> test = driver.findElements(By.xpath("//td[contains(@id, 'text')]"));
// find the last element in the dropdown list and click on it,
test.get(test.size() - 1).click();