0

I have a question regarding selenium, I try to fill a form, and the id of the input text is: //input[@id='company']. In selenium I get an error about this element not found:

Sun Sep 22 18:13:27 IDT 2019:ERROR: no such element: Unable to locate element: {"method":"id","selector":"//input[@id='company']"}
  (Session info: chrome=76.0.3809.132)
  (Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 6.1.7601 SP1 x86_64)

This is the page element enter image description here

This is my method

public static void inputValueById(String input,String id)
    {
        WebElement element = getWebElementByIdWithWaitToBeSeen(id);
        element.click();
        element.clear();
        element.sendKeys(input);
    }

the problem is that selenium not find the element, it finds it in the dev tools as you can see

DebanjanB
  • 118,661
  • 30
  • 168
  • 217
Bastian
  • 686
  • 16
  • 41
  • Have you tried setting the program to wait for 10 seconds? Sometimes elements take their time to load. – jamesfdearborn Sep 22 '19 at 17:23
  • 1
    what is `getWebElementByIdWithWaitToBeSeen`? – Moshe Slavin Sep 22 '19 at 21:07
  • 2
    there might be 2 reasons why it's failing in the script. 1) your script might be trying to locate the element even before the page loaded the element or 2) the element might be present in the iframe. – supputuri Sep 23 '19 at 03:05
  • 1
    is there any frame/iframe on the page? – yudi2312 Sep 23 '19 at 05:12
  • I try to wait 22 seconds and still not found, even I see the page loaded. getwebElementbyudwithwait - it just wait until the id is seen, and it waits for 22 seconds and still not found the element – Bastian Sep 23 '19 at 05:41
  • no Iframe in the page – Bastian Sep 23 '19 at 06:36
  • Have you tried, capture a screenshot at the moment of error thrown and check element is visible or not ? may be out of area, may be because of i frame, etc can be happen. – Devdun Sep 23 '19 at 07:42

1 Answers1

0

This error message...

Sun Sep 22 18:13:27 IDT 2019:ERROR: no such element: Unable to locate element: {"method":"id","selector":"//input[@id='company']"}
  (Session info: chrome=76.0.3809.132)
  (Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 6.1.7601 SP1 x86_64)

...implies that the ChromeDriver was unable to locate the desired element.

There are a couple of things which you need to take care:

  • The Locator Strategy which you have used isn't the id, but it's the
  • Though you are using chrome=76.0 but chromedriver=2.36 is too old.

Solution

DebanjanB
  • 118,661
  • 30
  • 168
  • 217