3

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

  1. Maximize Window

    driver.manage.window.maximize
    
  2. 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?

5
  • If you look at the exception, it should tell you the HTML of the other element would receive the click. What element is it? Do you recognize that element? Maybe it's some popup div that''s covering the element you want or ? Commented Jul 6, 2016 at 0:40
  • I do see it. Its the logo on top of the screen. It doesnt make sense that its clicking there. Also the coordinates its clicking on are (100,12) which is top left I believe? Theres not where the intended link is Commented Jul 6, 2016 at 1:59
  • That's a useful bit of info. Now you should check your locator and make sure it's getting the element you want. It may not be specific enough and finding more than one element. You can print outerHTML to see the HTML of the element to make sure it's the right one and adjust the locator, as needed. Commented Jul 6, 2016 at 13:10
  • @JeffC I am new to selenium webdriver and ruby. Could you please tell me how I can print outerhtml? Is it through javascript? Commented Jul 6, 2016 at 13:22
  • I don't know Ruby but you want to get the attribute "outerHTML" of the element. If you google some you should find it. Commented Jul 6, 2016 at 13:29

2 Answers 2

3

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...:)

Sign up to request clarification or add additional context in comments.

Comments

0

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!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.