基本上,我是一名 QA,最近构建了一个具有基本方法的框架,这将使我们的测试人员可以轻松地调用和编写单行代码。 我的任务是为这些方法编写单元测试用例。
Google/youtube 谈论了很多关于 JUnit 的内容,但我不明白像这样的方法的单元测试用例是如何的
public void iType(WebElement ele, String data, String elementName) {
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.visibilityOf(ele));
wait.until(ExpectedConditions.elementToBeClickable(ele));
ele.clear();
ele.sendKeys(data);
}
最佳答案
在单元测试中,您可以像从打算使用该方法的代码中调用该方法一样。您需要创建有效的参数以传递到该方法中。然后使用这些参数调用该方法。最后验证调用该方法后的结果是否正确。
关于java - 如何为 native Selenium 方法编写单元测试用例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60081152/