Selenium 数据提供者的实现面临的问题

Selenium 数据提供者的实现面临的问题,selenium,appium,Selenium,Appium,当我试图在excel工作表中实现DATAPROVIDER,并希望在appium中执行程序时,我面临以下问题,但面临问题 将错误视为--: 请帮我解决同样的问题 enter code here 如果要传递所有参数,请使用以下数据提供程序代码: @DataProvider(name = "ProcurementLead") public Object[][] Procurement() throws IOException { return new Object[][] { // first

当我试图在excel工作表中实现
DATAPROVIDER
,并希望在
appium
中执行程序时,我面临以下问题,但面临问题

将错误视为--:

请帮我解决同样的问题

enter code here

如果要传递所有参数,请使用以下数据提供程序代码:

@DataProvider(name = "ProcurementLead") 
public Object[][] Procurement() throws IOException { 
return new Object[][] {
// first set of values
{"LeadStatus","CustomerName","MobileNO","EmailID","CustomerAddress","pincode","City", "ManufacturedYear", "ManufacturedMonth", "Colour", "KMs", "Owner", "LeadSource", "Make", "ModelAndVariant", "CustomerExpct", "BuyingQuote","RegdYear","RegdMonth","RegdNo", "Insurance", "RefSource", "ExecInfo", "StockVinNo"},

// second set of values
{"LeadStatus","CustomerName","MobileNO","EmailID","CustomerAddress","pincode","City", "ManufacturedYear", "ManufacturedMonth", "Colour", "KMs", "Owner", "LeadSource", "Make", "ModelAndVariant", "CustomerExpct", "BuyingQuote","RegdYear","RegdMonth","RegdNo", "Insurance", "RefSource", "ExecInfo", "StockVinNo"}

}
}
如果要添加更多的数据集,可以添加它

还注意到您使用了显式等待以及Thread.sleep()。 不建议使用Thread.sleep()。 相反,您可以使用隐式等待


下次在发布问题之前,请仔细阅读stackoverflow问题发布指南。因此,您的问题很容易阅读。

当您从外部文件获取的数据与您在测试中提到的数据类型不匹配时,会出现数据提供程序不匹配

为了解决此问题,您可以使用以下方法:

在以下方法中使用数据提供程序: @测试(dataProvider=“login”,dataProviderClass=DataGenerators.class) public void tc_001_login_功能(字符串uname、字符串pass、字符串expectedText)引发异常

现在,只需注释此方法中的每一个代码,并打印您正在获取的值,如下所示:

System.out.println( uname + pass +  expectedText);

现在运行该方法,您将能够找出哪个参数与您的外部文件不同。

下面是我的代码---:@DataProvider(name=“ProcurementLead”)public Object[][]Procurement()抛出IOException{return new Object[][{“LeadStatus”},{“CustomerName”},{“MobileNO”},{“EmailID”}{“CustomerAddress”}、{“pincode”}、{“City”}、{“ManufacturedYear”}、{“ManufacturedMonth”}、{“Color”}、{“KMs”}、{“Owner”}、{“LeadSource”}、{“Make”}、{“ModelAndVariant”}、{“CustomerExpect”}、{“BuyingQuote”}}@Test(dataProvider=“ProcurementLead”)公共无效测试(字符串LeadStatus、字符串CustomerName、字符串MobileNO、字符串EmailID、字符串CustomerAddress、字符串pincode、字符串City、字符串ManufacturedYear、字符串ManufacturedMonth、字符串颜色、字符串KMs、字符串所有者、字符串LeadSource、字符串Make、字符串ModelAndVariant、字符串CustomerExpct、字符串BuyingQuote、字符串RegdYear、字符串RegdMonth、 String RegdNo,String Insurance,String RefSource,String ExecInfo,String StockVinNo)抛出InterruptedException,IOException{mobileeelement email=driver.findElement(By.id(“com.mfcwl.mfc_dealer:id/email”);Thread.sleep(4000);WebDriverWait wait=new WebDriverWait(driver,10);wait.unt(ExpectedConditions.visibilityOf(email));布尔值isElementPresent=email.isDisplayed();System.out.println(isElementPresent);Thread.sleep(4000);driver.findElementById(“com.mfcwl.mfc_经销商:id/email”).clear();driver.findElementById(“com.mfcwl.mfc_经销商:id/email”).sendKeys(“newgen”);log.info(“输入的ID”);driver.findElement(By.ID(“com.mfcwl.mfc_经销商:ID/密码”)).clear();driver.findElement(By.ID(“com.mfcwl.mfc_经销商:ID/密码”)。sendKeys(“super123”);log.info(“输入的密码”);driver.findElement(By.ID()com.mfcwl.mfc_dealer:id/email_sign_in_button”)。单击();//登录请使用该按钮将您的代码添加到问题中。然后您可以删除注释。非常感谢,这很有效,我在代码中应用了相同的逻辑。
System.out.println( uname + pass +  expectedText);