Unable to assign id properties to a known id type on my website (HTML based) for selenium based web tests


I have tried to use the following line of code while setting up for selenium webdriver GUI tests for my website shasthonet.com.

WebElement UserName = driver.findElement(By.id(“UserName”));

The goal with these lines is to basically assign a username nafis 123 to the username field in the website www.shasthonet.com

However, I repeatedly get the following error

Exception in thread “main” org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {“method”:”id”,”selector”:”UserName”}
(Session info: chrome=50.0.2661.94)
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 10.0 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 35 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: ‘2.53.0’, revision: ’35ae25b’, time: ‘2016-03-15 16:57:40′

I have tried to look up the html file in my website. It hasn’t been so helpful in providing any ideas to map the correct category for user name field.

I would appreciate if anyone can help me with this ? Thank you


Hi Nafis
try this as username field dont have an is assigned to it
WebElement UserName = driver.findElement(By.name(“UserCode”));

on May 9, 2016.
Add Comment
2 Answer(s)

It seems you are missing the basic chapters of selenium. You have to read on it and you can start from here

Virender Singh Professor Answered on May 8, 2016.
Add Comment

Hi Ankit

Thanks for ur response. Yes that did work. Although I am a bit surprised. So, now, for passwords and other info. following the name  string seems to be an ideal solution.

Hi Virender
Thanks for your advice. I have reviewing the  link you sent me from the beginning in a step by step mode b4 I got stuck and wrote in this forum. Thanks again.


nafis123 Default Answered on May 9, 2016.

you can always check for for available locators
but your preference should be

on May 9, 2016.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.