日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網(wǎng)為廣大站長提供免費收錄網(wǎng)站服務,提交前請做好本站友鏈:【 網(wǎng)站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

本文介紹了Selify與TestNG和Java中的數(shù)據(jù)提供程序不匹配的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

這里遇到了一些問題,您能告訴我如何解決嗎?

下面是我讀取Excel的代碼

import java.io.IOException;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class ReadExcel {
    public String unicode;
    public String[][] readExcel() throws IOException {
        XSSFWorkbook excelObject = new XSSFWorkbook("./data/unicode1.xlsx");
        XSSFSheet excelSheet = excelObject.getSheet("Sheet1");
        
        int rows = excelSheet.getLastRowNum();
        int columns = excelSheet.getRow(0).getLastCellNum();
        
        String[][] data = new String [rows][columns];

        for (int i = 1; i <= rows; i++) {
            XSSFRow row = excelSheet.getRow(i);
            for (int j = 0; j < columns; j++) {
                XSSFCell cell = row.getCell(j);
                String cellValue = cell.getStringCellValue();
                data[i-1][j] = cellValue;
            }
        }
    return data;
    }
}

我的測試用例代碼

import java.io.IOException;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import com.github.javafaker.Faker;
import commonFeatures.CommonThings;
import commonFeatures.ReadExcel;

public class SignUpWithUnicode extends CommonThings{
    
    Faker faker = new Faker();

    @Test(dataProvider = "fetchData")
    public void signUpWithUnicode(String unicode) throws InterruptedException {
        invokeBrowser("chrome", "https://master.signup");
        type(locateEle("xpath","//input[@id='first_name-id']"),faker.name().firstName());
        type(locateEle("xpath","//input[@id='last_name-id']"),faker.name().lastName());
        type(locateEle("xpath","//input[@id='last_name-id']"),faker.name().lastName());
        type(locateEle("xpath","//input[@id='client_user_email-id']"),faker.internet().emailAddress());
        type(locateEle("xpath", "//input[@id='password-id']"), "12345");
        type(locateEle("xpath", "//input[@id='degree-id']"), unicode);
        click(locateEle("xpath", "//span[contains(text(),'SUBMIT')]"));
        closeBrowser();
    }
        
    @DataProvider (name = "fetchData")
    public String[][] getData() throws IOException {
        ReadExcel excel = new ReadExcel();
        return excel.readExcel();   
    }
}

下面是錯誤

[RemoteTestNG] detected TestNG version 7.0.0
FAILED: signUpWithUnicode
org.testng.internal.reflect.MethodMatcherException: 
[public void testCases.SignUpWithUnicode.signUpWithUnicode(java.lang.String) throws java.lang.InterruptedException] has no parameters defined but was found to be using a data provider (either explicitly specified or inherited from class level annotation).
Data provider mismatch

我在Excel工作表中使用的是Unicode字符,因此我嘗試使用Object而不是String,但仍然出現(xiàn)此錯誤。然后,我嘗試使用Excel中的字符串來查找錯誤,但仍未成功。

推薦答案

錯誤為Data provider mismatch

您在ReadExcel類中以Multi dimensional array的形式返回數(shù)據(jù),但在測試signUpWithUnicode中以String的形式傳遞數(shù)據(jù),因此請更改參數(shù)類型。

@Test(dataProvider = "fetchData")
    public void signUpWithUnicode(String[][] unicode) throws InterruptedException {
   //code
  }

這篇關(guān)于Selify與TestNG和Java中的數(shù)據(jù)提供程序不匹配的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,

分享到:
標簽:Java Selify TestNG 不匹配 提供 數(shù)據(jù) 程序
用戶無頭像

網(wǎng)友整理

注冊時間:

網(wǎng)站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨大挑戰(zhàn)2018-06-03

數(shù)獨一種數(shù)學游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學四六

運動步數(shù)有氧達人2018-06-03

記錄運動步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓練成績評定2018-06-03

通用課目體育訓練成績評定