background image
<< What is Selenium? | A few Selenese commands >>

Java Test example

<< What is Selenium? | A few Selenese commands >>
Java Test example
public void
testGoogleTestSearch()
throws
Exception
{
selenium
.open(
"http://www.google.com/webhp"
);
assertEquals(
"Google",
selenium
.getTitle());
selenium
.type(
"q"
,
"Selenium OpenQA"
);
selenium
.click(
"btnG
");
selenium
.waitForPageToLoad(
"5000"
);
assertEquals(
"Selenium OpenQA - Google Search"
,
selenium
.getTitle());
}
Java SetUp/TearDown example
public void
setUp()
throws
Exception
{
selenium
=
new
DefaultSelenium(
"localhost"
,
4444
,
"*chrome"
,
"http://www.google.com"
);
selenium
.start();
}
public void
tearDown()
throws
Exception
{
selenium
.stop();
}