Selenium 1.3
Selenium 1.3
Selenium 1.3
<classes>
<class name="com.techbeamers.TestA"/>
<class name="com.techbeamers.TestB"/>
<class name="com.techbeamers.TestC"/>
</classes>
</test>
</suite>
• Create a new java project in eclipse(“TestNG_Demo”)
• Add the TestNG library to your java project(right click on project “TestNG_Demo”->Build Path-
>Add Libraries)
• Choose TestNG and Finish.
• Right Click on the Package ”TestNG_Demo” ->New-> others.
•
• Add the selenium jar file in your package->right click on the project->build path->configuration-
>libraries ->add external jar.
• Keep the chromedriver.exe in the same folder “TestNG_Demo” and provide the path.
• Provide the xml file to the project->right click on the project “testNG_Demo”->import->xml->xml
catalog->import the xml file where you have stored (TestNG_Demo folder)
• Code
package com.techbeamers.com;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@Test
public void MyFirstTestNGTestCase() throws InterruptedException {
String title = driver.getTitle();
System.out.print("Current page title is : " + title);
WebElement user = driver.findElement(By.name("userName"));
user.sendKeys("test");
WebElement pwd = driver.findElement(By.name("password"));
pwd.sendKeys("test");
WebElement signin = driver.findElement(By.name("login"));
signin.click();
Thread.sleep(1000);
System.out.print("\n'SUCCESSFUL EXECUTION!!!");
}
public void invokeBrowser() {
System.setProperty("webdriver.chrome.driver","C:\\Users\\De
ll\\Desktop\\JAVACODE\\chromedriver.exe");
driver.manage().window().maximize();
driver.get("http://newtours.demoaut.com/");
}
public void cleaupProc() {
System.out.print("\nBrowser close");
driver.quit();
}
@AfterMethod
public void afterMethod() {
}