Reputation: 169
I am getting an error
Element is not clickable at point (100,12). Other Element would receive this click
I did some research on the issue and here are the solutions I have tried
Maximize Window
driver.manage.window.maximize
Scroll into view
driver.execute_script("arguments[0].scrollIntoView(true);", element)
sleep(3)
None of these seem to work.
Here is the layout of the HTML
<body>
<div>
<div>
<div>
<ul>
<li> <a> Click me </a>
...
The way I get the element is
element = driver.find_element(:xpath, "//li/a[contains(text(), 'Click me')]"
Anyone know what I am doing wrong? What could I do more?
Upvotes: 3
Views: 1148
Reputation: 23805
In this case you should try to perform click
using .execute_script
as below :-
element = driver.find_element(:xpath, "//li/a[contains(text(), 'Click me')]")
driver.execute_script("arguments[0].click();", element)
Hope it will help you...:)
Upvotes: 3
Reputation: 21
If you're trying to click on the element using its coordinates, make sure you have the exact coordinates. You can try the code below:
ele = driver.find_element(:xpath, "//li/a[contains(text(), 'Click me')]"
int eleXCoordinate = ele.getLocation().getX();
int eleYCoordinate = ele.getLocation().getY();
Now use Robot class to first verify if the coordinates are correct
Robot robot = new Robot();
robot.mouseMove(dragElementXCoordinate, dragElementYCoordinate);
If mouse moves on to the element, you're good to go. Else try hit-and-trial to add some values to arrive at the exact coordinates. For eg.
Robot robot = new Robot();
robot.mouseMove(dragElementXCoordinate +310, dragElementYCoordinate +100);
Now that you can see on the screen that mouse moves over to the element, perform click
robot.mousePress(InputEvent.BUTTON1_MASK);
And then release the click
robot.mouseRelease(InputEvent.BUTTON1_MASK);
Hope this helps!
Upvotes: 0