Selenium
은 사용자와 같이 브라우저/웹 사이트를 제어하는 툴입니다. 그것은 사용자가 페이지를 클릭하는 것을 시뮬레이션합니다. 웹 응용 프로그램의 기능을 알면 테스트를 설정할 수 있습니다. 이제 일련의 테스트 케이스 즉 테스트 스위트를 실행하십시오. TestNG
은 테스트 실행을 관리하는이 기능을 제공합니다.
이 간단한 tutorial을 읽고 TestNG 테스트 세트를 설정하는 것이 좋습니다.
나는
셀레늄 그리드 병렬로 테스트를 실행하는 셀레늄 스위트의 일부인 한 번에 모든을 testcases을 실행합니다. 기본 클래스의 사용
public class TestBase {
protected ThreadLocal<RemoteWebDriver> threadDriver = null;
@BeforeMethod
public void setUp() throws MalformedURLException {
threadDriver = new ThreadLocal<RemoteWebDriver>();
DesiredCapabilities dc = new DesiredCapabilities();
FirefoxProfile fp = new FirefoxProfile();
dc.setCapability(FirefoxDriver.PROFILE, fp);
dc.setBrowserName(DesiredCapabilities.firefox().getBrowserName());
threadDriver.set(new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), dc));
}
public WebDriver getDriver() {
return threadDriver.get();
}
@AfterMethod
public void closeBrowser() {
getDriver().quit();
}
}
을에서 당신은 설치 드라이버는 샘플 테스트의 예는 다음과 같습니다
public class Test01 extends TestBase {
@Test
public void testLink()throws Exception {
getDriver().get("http://facebook.com");
WebElement textBox = getDriver().findElement(By.xpath("//input[@value='Name']"));
// test goes here
}
}
당신은
public class Test02 extends TestBase {
@Test
public void testLink()throws Exception {
// test goes here
}
}
TestNG를 구성 위와 같이 유사한 방법으로 검사를 더 추가 할 수 있습니다
testng.xml
<suite name="My Test Suite">
<suite-files>
<suite-file path="./testFiles.xml" />
</suite-files>
testFiles.xml
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Parallel test runs" parallel="tests" thread-count="2">
<test name="T_01">
<classes>
<class name="com.package.name.Test01" ></class>
</classes>
</test>
<test name="T_02">
<classes>
<class name="com.package.name.Test02" ></class>
</classes>
</test>
<!-- more tests -->
</suite>
내가 testng.xml를 변환하는 방법을 알고 있지만 내가 주석에 혼란을했습니다 – SenthilKumarP