Selenium Script Explanation
Here we can see the code for simple login and logout functionality with comments and the explanation of code.
import com.thoughtworks.selenium.DefaultSelenium; //Selenium package
//Class name[class name should equal to program name]
public class Login {
//creating a method
public static void Login_results() throws Exception
{
/*Defining the selenium method if you want to declare Default selenium outside the method you need to declare as public
public static DefaultSelenium selenium=new DefaultSelenium("localhost",4444,"*iehta","http://");
localhost—serverHost
4444 --- serverport
Iehta ----- browserstart command(we can use *firefox also)
http:// ---browser URL(Here we can give full URL of site) */
DefaultSelenium selenium=new DefaultSelenium("localhost", 4444, "*iehta", "http://");
//this command will start the selenium
selenium.start();
//to open the URL
selenium.open("http://test2.xyzt.com");
//Maximizes the window
selenium.windowMaximize();
//to read user name
selenium.type("name=login[username]", "dnr5dnr@gmail.com");
//to read password
selenium.type("name=login[password]", "mourya");
//click login button
selenium.click("send2");
//waits until the page loads
selenium.waitForPageToLoad("50000");
//click the link sign out
selenium.click("link=Sign Out");
// print message
System.out.println("Login and Log out success");
}
public static void main(String[] args) throws Exception{
Login_results();
}
}
Is there any reference book available for studding the Selenium?
ReplyDeleteHi I have tried this error coming "Editor does not contain a main type"
ReplyDeleterefered me or give me the name of selenium rc book....................................
ReplyDeletebased on functionality testing on web applications
hi can you tell me the selenium command to run n number of inputs at a time threw selenium
ReplyDeletemichael kors outlet online
ReplyDeletefred perry clothing
coach outlet online
coach outlet
michael kors outlet clearance
coach outlet
true religion outlet store
uggs outlet
coach outlet online
supreme hoodie
chenminghui2018427
Pandora Jewelry
ReplyDeletePandora Jewelry Outlet
Pandora Jewelry
Kyrie Shoes
Air Jordan 9
Pandora Jewelry Outlet
Air Jordan
Jordan 11
Nike Air Max 270
Retro Jordan 11
Latrice20181016