我创建了两个类,它们在 selenium 中从不同的 Excel 工作表读取数据 那么如何创建对象并使用 java 调用第二个类而不从脚本中提供任何数据。
在第二类中有参数。我想从 Excel 工作表中获取这些数据而不从类文件中提供任何数据。当我创建如下代码时,它没有正确运行。它显示了这个错误:
"Cannot inject @Test annotated Method [successfullycreaterate]
with [class java.lang.String, class java.lang.String, class java.lang.String,
class java.lang.String, class java.lang.String, class java.lang.String,
class java.lang.String, class java.lang.String, class java.lang.String,
class java.lang.String]."
第一类
@Test(dataProvider = "excelData")
public void read(String username,String password) throws InterruptedException {
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
//handle popup window
Set<String> windowId = driver.getWindowHandles(); // get window id of current window
Iterator<String> itererator = windowId.iterator();
String mainWinID = itererator.next();
String newAdwinID = itererator.next();
driver.switchTo().window(newAdwinID);
System.out.println(driver.getTitle());
Thread.sleep(3000);
WebDriverWait wait=new WebDriverWait(driver,3);
WebElement uname= wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath( "//input[@id='j_username']")));
uname.sendKeys(username);
WebElement pwd= wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath( "//*[@id=\"j_password\"]")));
pwd.sendKeys(password);
WebElement login= driver.findElement(By.xpath("//*[@id=\"btnLogin\"]"));
login.click();
}
@Test
public void successfullycreaterate(String rateplan, String date, String hotel, String datevalidfrm, String datevalidto, String ratecatagory, String setcurrency, String taxlevel, String channel, String childlevel) throws IOException, InterruptedException {
CreateRate execute=new CreateRate();
execute.successfullyCreate(rateplan, date, hotel, datevalidfrm, datevalidto, ratecatagory, setcurrency, taxlevel, channel, childlevel);
}
}
阿晨1998
相关分类