Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javapoi中excel单元格的行验证_Java_Selenium_Apache Poi - Fatal编程技术网

javapoi中excel单元格的行验证

javapoi中excel单元格的行验证,java,selenium,apache-poi,Java,Selenium,Apache Poi,我试图在我的测试自动化框架中实现一个数据驱动的方面。我已经创建了一个fe函数,它似乎工作正常,可以检索参数的列/行数、从特定单元格获取数据、更新特定单元格等等 我现在用一个基本上有两列的脚本来测试它。第一列是用户名,第二列是密码。我可以毫无问题地迭代这些行、列 我遇到了一个问题,如果有一个空白单元格,它将崩溃,但我通过一些错误处理解决了这个问题,如果有一个黑色单元格,它将返回字符串“Empty cell” 我有一个小问题,即如果一些测试数据不一致: 我不知道如何处理这样的问题。如果两个单元格都

我试图在我的测试自动化框架中实现一个数据驱动的方面。我已经创建了一个fe函数,它似乎工作正常,可以检索参数的列/行数、从特定单元格获取数据、更新特定单元格等等

我现在用一个基本上有两列的脚本来测试它。第一列是用户名,第二列是密码。我可以毫无问题地迭代这些行、列

我遇到了一个问题,如果有一个空白单元格,它将崩溃,但我通过一些错误处理解决了这个问题,如果有一个黑色单元格,它将返回字符串“Empty cell”

我有一个小问题,即如果一些测试数据不一致:

我不知道如何处理这样的问题。如果两个单元格都是空的,我添加了一些验证(它跳过该行)。如何让它完全跳过这些类型的行,只获取包含两个单元格条目的数据

我的现行守则如下:

int endMarker = edc.getExcelParameterRow(edc, 0, nextColumnMarker);

    System.out.println(endMarker);

    int columnParam = edc.getExcelParameterCol(edc, 0, ExcelDataUserName);
    System.out.println(columnParam);

    open_chrome_browser();
    Logout lo = new Logout();



    //get all of the usernames
    for (i = 0; i <endMarker-1;i++){
        String param1_celldata = edc.getExcelData(0, i+1, columnParam);
        String param2_celldata = edc.getExcelData(0, i+1, columnParam+1);

        //iterate over the username passwords of the data.xls sheet to login and out as different users

        if(param1_celldata.contains("Empty cell")&&param2_celldata.contains("Empty cell")){
            i++;
        }


        LoginPage.login(driver, edc.getExcelData(0, i+1, columnParam), edc.getExcelData(0, i+1, columnParam+1));
        lo.logout_user_out(driver);
以下内容也不符合要求:

if(param1_celldata.contains("Empty cell")&&param2_celldata.contains("Empty cell")){
            i++;
        }
        if(param1_celldata.contains("Empty cell")||param2_celldata.contains("Empty cell")){
            i++;
        }           

我只想让这个工具跳过这些奇怪的错误排列的单元格。我怎样才能做到这一点呢?

你能稍微改变一下逻辑,然后试试下面的方法吗?这将跳过任一单元格为空的行

for (i = 0; i < endMarker - 1; i++)
{
    String param1_celldata = edc.getExcelData(0, i + 1, columnParam);
    String param2_celldata = edc.getExcelData(0, i + 1, columnParam + 1);

    // iterate over the username passwords of the data.xls sheet to login and out as different users
    if (!param1_celldata.contains("Empty cell") && !param2_celldata.contains("Empty cell"))
    {
        LoginPage.login(driver, param1_celldata, param2_celldata);
        lo.logout_user_out(driver);
    }
}
for(i=0;i
更改内容为。。。如果Cell1不为空,Cell2不为空,则登录并注销。如果任一单元格为空,则会跳过登录和注销步骤,将您带回到
开头,并递增
i
。感谢Gowrishankar,我没有意识到我可以添加感叹号来否定该子句:!param1_celldata.contains(“空单元格”)。谢谢你为我指明了正确的方向,我现在正在工作。
for (i = 0; i < endMarker - 1; i++)
{
    String param1_celldata = edc.getExcelData(0, i + 1, columnParam);
    String param2_celldata = edc.getExcelData(0, i + 1, columnParam + 1);

    // iterate over the username passwords of the data.xls sheet to login and out as different users
    if (!param1_celldata.contains("Empty cell") && !param2_celldata.contains("Empty cell"))
    {
        LoginPage.login(driver, param1_celldata, param2_celldata);
        lo.logout_user_out(driver);
    }
}