断言不工作 excel 基于数据驱动的测试 selenium 网络驱动程序 java

Assertion is not working excel based data driven testing selenium web driver java

我正在尝试通过验证登录操作后主页上是否存在文本来验证用户是否能够登录。但是在登录操作之后,执行不会读取关于主页上是否存在文本的断言代码。然而,整体测试执行 运行 成功但在执行期间它跳过断言。请帮我找出我在这里遗漏的任何内容。

这是我的代码:

package com.provider;

import java.io.File;
import jxl.Sheet;
import jxl.Workbook;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;



public class ProApp extends OneClass {

    Workbook wb;
    Sheet sh1;
    int numrow;
    String uname;
    String password1;

    @Test
    public void oneTimeSetUp() throws InterruptedException {


    driver.manage().window().maximize();
    driver.get("xyz.com");
    Thread.sleep(1000);
    driver.findElement(By.xpath("//*[@id='app']/div/main/section/ul/li[1]/a")).click();
    Thread.sleep(1000);

    }


    @Test(dataProvider="testdata")
    public void testFireFox(String uname,String password1) throws InterruptedException

    {

    driver.findElement(By.xpath("//input[@name='username']")).clear();
    Thread.sleep(1000);
    driver.findElement(By.xpath("//input[@name='username']")).sendKeys(uname);
    Thread.sleep(1000);
    driver.findElement(By.xpath("//input[@name='password']")).clear();
    Thread.sleep(1000);
    driver.findElement(By.xpath("//input[@name='password']")).sendKeys(password1);
    Thread.sleep(1000);
    driver.findElement(By.xpath("//button[@name='loginButton']")).click();
    Thread.sleep(1000);

    }


    @Test
    public void loginVerify() {

        Assert.assertEquals("Wel Come to Testing World!", driver.findElement(By.xpath("//*[@id='app']/div/header/nav[1]/div/div/span/span")).getText());

    }   

    @Test
    public void logonActionVerify() {   
    WebElement DashboardHeader = driver.findElement(By.xpath("//*    [@id='app']/div/header/nav[1]/div/div/span/span"));
    DashboardHeader.getText().equals("Wel Come to Testing World!");




    @DataProvider(name="testdata")
    public Object[][] TestDataFeed(){

    try {

    // load workbook
    wb=Workbook.getWorkbook(new File("C://File//Book2.xls"));

    // load sheet in my case I am referring to first sheet only
    sh1= wb.getSheet(0);

    // get number of rows so that we can run loop based on this
    numrow=  sh1.getRows();
    }
    catch (Exception e)

    {
    e.printStackTrace();
    }

    // Create 2 D array and pass row and columns
    Object [][] logindata=new Object[numrow][sh1.getColumns()];

    // This will run a loop and each iteration  it will fetch new row
    for(int i=0;i<numrow;i++){

    // Fetch first row username
        logindata[i][0]=sh1.getCell(0,i).getContents();
    // Fetch first row password
        logindata[i][1]=sh1.getCell(1,i).getContents();

    }

    // Return 2d array object so that test script can use the same
    return logindata;
    }

    } 

请指定每个@Test 方法的优先级以指定的顺序执行。

 @Test( priority = 1 )
 public void testA1() {
  System.out.println("testA1");
 }

 @Test( priority = 2 )
 public void testA2() {
  System.out.println("testA2");
}

我希望 loginVerify 在这些设置和登录之前执行,因为 testng 主要按字母顺序调用方法。

如果上述答案无效,请post完全了解结果或异常情况,以便更好地理解。

谢谢, 穆拉利 G