1
我是selenium webdriver的新手,我剛安裝了eclipse kelpler的TestNG插件,現在當我試着用TestNG來執行我的代碼時,我能夠看到代碼出現在@BeforeTest下,但是@Test註解下的代碼沒有被執行。 下面是代碼我已經寫了:TestNG沒有在selenium webdriver的Test註釋裏面執行方法
import java.util.List;
import java.util.Set;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.Wait;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
public class Survey_Fill {
WebDriver driver;
@BeforeTest
public void start(){
driver= new FirefoxDriver();
org.openqa.selenium.Dimension d = new org.openqa.selenium.Dimension(1360, 1200);
driver.manage().window().setSize(d);
}
@Test
public void test(){
System.out.println("hello");
}
}
這裏是TestNG的結果給出的輸出:
[TestNG] Running:
C:\Users\User\AppData\Local\Temp\testng-eclipse--1183478272\testng-customsuite.xml
===============================================
Default test
Tests run: 0, Failures: 0, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 0, Failures: 0, Skips: 0
===============================================
[TestNG] Time taken by [email protected]: 35 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 0 ms
[TestNG] Time taken by [email protected]: 164 ms
[TestNG] Time taken by [email protected]: 257 ms
[TestNG] Time taken by [email protected]: 0 ms
[TestNG] Time taken by [email protected]: 13 ms
請讓我知道,我已經在這裏做了錯誤。 謝謝。