2

In Selenium I am trying to locate an element. But getting the below error:

org.openqa.selenium.WebDriverException: Element is not clickable at point (1009.25, 448.183349609375). Other element would receive the click: <rect data-sdf-index="7" height="390" width="420" class="aw-relations-noeditable-area"></rect> (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 12 milliseconds

Getting this error in firefox. But its working successfully in Chrome browser. Is anyone having solution for it?

I already tried help from this post:-Selenium "Element is not clickable at point" error in Firefox but not able to get the result.

I have written below code:

public void createPortOnSelectedNode( String nodeName ) {
    ISingleLocator m_nodeContainer = m_nodePage.getNodeContainer();
    WebElement node = m_nodePage.getNode( m_nodeContainer, nodeName ).getElement();
    Actions action = new Actions(DefaultDriver.getWebDriver());
    action.moveToElement(node, 40, 0);
    action.click();
    action.perform();
}
Community
  • 1
  • 1
Avinash Jadhav
  • 1,243
  • 2
  • 12
  • 20
  • u tried using javascript executor? – noor Apr 22 '16 at 12:45
  • try to add few seconds to wait before clicking on required element – Andersson Apr 22 '16 at 12:48
  • @noor Here how can I used javascript executor as I don't have exact webelement. I am moving from one element to (40 ,0) location where there is no any webelement. And after performing click operation there one WebElement will create. – Avinash Jadhav Apr 22 '16 at 12:59
  • @Anderson is there another way without using Thread.Sleep( ) method? – Avinash Jadhav Apr 22 '16 at 13:01
  • @noor If I move cursor over there (40,0) one rect element is displayed else nothing has been displayed.Therefore I moving to that location to select that element. – Avinash Jadhav Apr 22 '16 at 13:07
  • @AvinashJadhav, check this http://www.seleniumhq.org/docs/04_webdriver_advanced.jsp#explicit-waits Use `wait.until(EC.element_to_be_clickable((By.ID,'someid')))` method – Andersson Apr 22 '16 at 13:53
  • if ur WebElement node is null, than action or javascript executor will not work...but if node is not null, i think .. action or javascript may work. so make sure node is not null by using anderson wait strategy. – noor Apr 22 '16 at 14:19
  • @noor my webElement is not null but still its getting failed – Avinash Jadhav Apr 25 '16 at 05:53

2 Answers2

2

Hi the above error comes under such scenario where Your webdriver script performs the action but the element on which you want to do operation is not properly loaded inside the DOM i.e its position is not fixed inside the DOM tree (also note selenium is able to perform its action because element is available inside the DOM hence webdriver only looks for the presence of element inside the DOM and not its position inside the DOM)

So how to overcome this issue

   1.Give time to DOM to properly give positions to its element.

and that can be achieved by :

1.Instead of performing operation's directly at the target area try to do some extra/false 
activity with webdriver which will give time for DOM to position all of his elements
2.apply Thread.sleep().
3. also if you are running your test in smaller window size then set the size to maximum it 
will also help

i have not included any code cause the link that you have refer in the question contains ample amount of work regarding that so i decided to make everybody underrated why this error occurs. thanks hope this helps

Rajnish Kumar
  • 2,828
  • 5
  • 25
  • 39
  • please make me understand what your scenario is the only i can suggest some extra activity – Rajnish Kumar Apr 25 '16 at 05:58
  • There is one rectangle which is nothing but the node as mentioned in code. Now side of the rectangles are disabled initially, Disable means you can see these sides but not able to perform any action on it.So I made some changes so that when I move the cursor over there you will find small square box over there and if you move the cursor from there that squares gets hidden. Now in my code using moveElement() I move to that position .When I Click on side of the rectangle then that small square box should appear .But am getting this error as mentioned above – Avinash Jadhav Apr 25 '16 at 06:20
  • 1
    instead of using MoveElement() directly please perform some other functionality first on the page like you can count total number of links available ob the page or menu item something like that after that use MoveElement() – Rajnish Kumar Apr 25 '16 at 06:37
  • I counted the number "g" element before that function but still giving the same result – Avinash Jadhav Apr 25 '16 at 06:55
  • ok can you perform a functionality which according to you takes some time i guess counting g element is not talking enough time – Rajnish Kumar Apr 25 '16 at 06:57
  • Can you suggest the functionality which takes enough time? – Avinash Jadhav Apr 25 '16 at 07:08
0

Have you tried to click directly using Javascript? In python I use

driver.execute_script("arguments[0].click();", elt)

In Java it should look like executeScript instead...

JulienD
  • 7,102
  • 9
  • 50
  • 84