最佳答案
我可以编写和执行 Selenium 脚本,而不需要任何特殊的测试框架,但是我想使用 JUnit 5(因为我们与其他工具有依赖关系) ,而且我在使用 JUnit 4时从未见过这样的错误 org.junit.jupiter.api.extension.ParameterResolutionException
。
现在是 JUnit 5和 我在谷歌上搜索了一下,想得到一些想法,但无法解决这个问题。
使用 JUnit 5
、 Eclipse 4.8
和 Selenium
测试脚本:
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
public class loginTest {
public WebDriver driver = null;
public loginTest(WebDriver driver) {
this.driver=driver;
}
@BeforeEach
public void setUp() throws Exception {
driver.get("google.com");
System.out.println("Page title is: " + driver.getTitle());
}
@Test
public void test() {
// some action here I have in original script
System.out.println("Page title is: " + driver.getTitle());
}
@AfterEach
public void tearDown() throws Exception {
driver.quit();
}
}
堆栈跟踪:
异常: 在可执行文件[ public login.loginTest (org.openqa.selenium. WebDriver)]中没有为参数[ org.openqa.selenium. WebDriver arg0]注册参数。 参数(ExecutableInvoker.java: 191)