I am trying to validate whether user is able to logon or not by verifying whether text is present or not on Home page after logon action. But after login action, execution is not reading assertion code for whether text is present or not on Home page. However, overall test execution run successfully but during execution it skip Assertion. Please help me to identified anything I missed here.
Here is my code:
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;
}
}
Assert.fail()does everything still pass?