Selenium Simple Examples - Java (Selenium RC)
1.Open Google website , type any word and click on search button
import com.thoughtworks.selenium.DefaultSelenium;
public class GoogleSearch
{
public static void main(String[] args)
{
DefaultSelenium ds=new DefaultSelenium("localhost",8888,"*firefox","http://www.google.co.in/");
ds.start();
ds.windowMaximize();
ds.open("/");
ds.type("q", "india");
ds.click("btnK");
}
}
2.Open Gmail website , give username and password.Click on Sign in button
import com.thoughtworks.selenium.DefaultSelenium;
public class GmailLogin_Selenium
{
public static void main(String[] args) throws Exception
{
DefaultSelenium ds=new DefaultSelenium("localhost",8888,"*firefox","http://www.gmail.com");
ds.start();
ds.windowMaximize();
ds.open("/");
ds.type("Email", "<username>");
ds.type("Passwd", "<pwd>");
ds.click("signIn");
}
}
3.Open YahooMail,Sing In and Check whether the sign in is happened or not
import com.thoughtworks.selenium.DefaultSelenium;
public class YahooMail_isText_Selenium
{
public static void main(String[] args) throws Exception
{
DefaultSelenium ds=new DefaultSelenium("localhost",8888,"*firefox","http://www.yahoomail.com");
ds.start();
ds.windowMaximize();
ds.open("/");
ds.type("login", "<username>");
ds.type("passwd", "<pwd>");
ds.click(".save");
Thread.sleep(10000);
if(ds.isTextPresent("Sign Out")) {
System.out.println("Signin is Success") ;
} else {
System.out.println("Signin is not Success") ;
}
}
}
1.Open Google website , type any word and click on search button
import com.thoughtworks.selenium.DefaultSelenium;
public class GoogleSearch
{
public static void main(String[] args)
{
DefaultSelenium ds=new DefaultSelenium("localhost",8888,"*firefox","http://www.google.co.in/");
ds.start();
ds.windowMaximize();
ds.open("/");
ds.type("q", "india");
ds.click("btnK");
}
}
2.Open Gmail website , give username and password.Click on Sign in button
import com.thoughtworks.selenium.DefaultSelenium;
public class GmailLogin_Selenium
{
public static void main(String[] args) throws Exception
{
DefaultSelenium ds=new DefaultSelenium("localhost",8888,"*firefox","http://www.gmail.com");
ds.start();
ds.windowMaximize();
ds.open("/");
ds.type("Email", "<username>");
ds.type("Passwd", "<pwd>");
ds.click("signIn");
}
}
3.Open YahooMail,Sing In and Check whether the sign in is happened or not
import com.thoughtworks.selenium.DefaultSelenium;
public class YahooMail_isText_Selenium
{
public static void main(String[] args) throws Exception
{
DefaultSelenium ds=new DefaultSelenium("localhost",8888,"*firefox","http://www.yahoomail.com");
ds.start();
ds.windowMaximize();
ds.open("/");
ds.type("login", "<username>");
ds.type("passwd", "<pwd>");
ds.click(".save");
Thread.sleep(10000);
if(ds.isTextPresent("Sign Out")) {
System.out.println("Signin is Success") ;
} else {
System.out.println("Signin is not Success") ;
}
}
}
No comments:
Post a Comment