2

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

7
  • Have you tried setting the program to wait for 10 seconds? Sometimes elements take their time to load. Commented Sep 22, 2019 at 17:23
  • 1
    what is getWebElementByIdWithWaitToBeSeen? Commented Sep 22, 2019 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. Commented Sep 23, 2019 at 3:05
  • 1
    is there any frame/iframe on the page? Commented Sep 23, 2019 at 5: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 Commented Sep 23, 2019 at 5:41

1 Answer 1

2

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

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

1 Comment

how do you change the method? I provide an ID, but when debugging I see that the mechanism is "css selector"

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.