Can't locate textbox elements from login page

Image below is our example login page. I'm having issue locating the username and password elements.

This is the tag.

<input id="userId" class="Textbox required" type="text" placeholder="User Name" name="_ssoUser"/>

Login page

Below are the codes that I've tried but still no luck to solve it.

driver.findElement(By.name("_ssoUser")).sendKeys(username);

driver.findElement(By.id("userId")).sendKeys(username);

driver.findElement(By.xpath(".//*[@id='userId']")).sendKeys(username);

Appreciate your help. Thank you.

Answers


First wait by using implicit wait

driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

After that see if there is a frame or not

driver.switchTo().frame(0);

You can handle frame by many ways. refer below:-

http://www.seleniumeasy.com/selenium-tutorials/how-to-work-with-iframes-in-selenium-webdriver

Note:- switch to frame first and then execute your rest of code.

Hope it will help you :)


look if you have frame if yes switch to it.

driver.switchTo().frame("<frameid> or <frame name>");

Need Your Help

How to display uploaded image using path in angularJS and MVC?

c# angularjs asp.net-mvc

I have uploaded an image using AngularJs on a particular path. Now I want to display uploaded Single image in a div from that path.

C# console application: reading data from xml file

c# xml console console-application

I am totally new to reading data from file, specially xml files.