Create a Click class with 2 methods testClick1,testClick2 and Suite called ClickSuite.xml
Now make ClickTestSuite.xml
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
import com.thoughtworks.selenium.*;
import org.openqa.selenium.server.*;
import org.testng.annotations.*;
public class Click {
public Selenium selenium;
public SeleniumServer seleniumserver;
@BeforeClass
public void setUp() throws Exception {
RemoteControlConfiguration rc = new RemoteControlConfiguration();
seleniumserver = new SeleniumServer(rc);
selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://www.google.co.in/");
seleniumserver.start();
selenium.start();
}
@Test
public void testClick()throws Exception {
selenium.open("/");
selenium.windowMaximize();
selenium.click("link=regexp:Advanced [s|S]earch");
selenium.waitForPageToLoad("5000");
selenium.click("id=opt-icon");
System.out.println(selenium.getLocation());
selenium.click("link=Scholar");
Thread.sleep(10000);
}
@Test
public void testClick2() throws Exception {
selenium.open("/");
selenium.type("q", "selenium link locator");
selenium.click("btnG");
}
@AfterClass
public void tearDown()throws Exception {
selenium.stop();
seleniumserver.stop();
}
}
Now make ClickTestSuite.xml
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <suite name="ClickTestSuite" verbose="3"> <test name="testClick"> <classes> <class name="Click"></class> </classes> </test>
<test name="testClick2"> <classes> <class name="Click"></class> </classes> </test>
</suite>
No comments:
Post a Comment