Selenium
は、ユーザのようにブラウザ/ Webサイトを制御するツールです。ユーザーがページをクリックすることをシミュレートします。 Webアプリケーションの機能を理解して、テストを設定することができます。テストスイートのセットをテストスイートと一緒に実行します。 TestNG
は、テスト実行を管理するこの機能を提供します。
この単純なtutorialを読んで、TestNGテストスイートを設定することをお勧めします。
私は一度に
セレングリッドのすべてのテストケースを実行するには、並行してテストを実行するセレンスイートの一部です。あなたのセットアップベースclasssでドライバ
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 Test02 extends TestBase {
@Test
public void testLink()throws Exception {
// test goes here
}
}
上記と同様の方法でより多くのテストを追加することができます
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
}
}
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