私は、SeleniumとJavaを使用してWebアプリケーションテストスイートを設定しようとしています。私はsrc以下の3つのパッケージ別のパッケージからwebdriverを呼び出してください
- オブジェクトを作成するつもりです - 試験方法に使用
- テスト - - 私が作成したタスク]の下でテスト
に使用私のページに使用
protected void verifyNumberOfElements(By selector, int expectedsize){
int size = driver.findElements(selector).size();
log.info("INFO: Verifying the number of elements is "+expectedsize+"");
Assert.assertEquals(size, expectedsize);
log.info("PASS: The number of elements returned was "+expectedsize+" ");
}
public static void verifyText(By selector, String expectedtext){
//verify that the expected text is present
String actualtext = driver.findElement(selector).getText();
Assert.assertEquals(actualtext, expectedtext);
log.info("PASS: "+expectedtext+" was present and verified");
}
protected void verifyElement(By selector){
//Verify that a certain selector is present in the page
smartSleep(selector);
boolean isPresent = driver.findElements(selector).size() > 0;
Assert.assertEquals(isPresent, true);
log.info("PASS: Element was found");
boolean notPresent = driver.findElements(selector).size() > 0;
Assert.assertEquals(notPresent, false);
log.info("FAIL: Element was NOT found");
}
、私はテスト機能のABCのためのABCと呼ばれるクラスを作成します。私は以下のようないくつかの基本的なステップを持っています。
verifyText(PageObjects.ItemText, "Multiple Choice - Single Answer Radio - Vertical");
verifyText(PageObjects.Progress_PercentComplete, "0%");
私はウェブドライブを作成する場所がわかりません。私は多くのテストクラスを作成し、Tasksパッケージで作成されたメソッドを呼び出せるようにしたい。私はTasksからクラスをインポートする必要があることを知っていますが、Webdriver作成部分を理解することはできません。タスクパッケージとテストパッケージの両方がドライバを参照するので、どうすればこの問題を解決できますか? Tasks.CommonTasks、またはTests.ABCで作成する必要がありますか?
ローカルマシンではなくSauceLabsに接続するテストも必要です。