I created 3 file, one is common which is hold common opening browser detail and dashboard page object. And second one is for homepage testcase and third one is for loginIn page or after login page element find test case.
I am able to run dashbaord test case.but i want also run testcase for LogedIn, i can’t.
<code>package BaseDataSource;
import java.io.FileInputStream;
import java.io.IOException;
import java.time.Duration;
import java.util.Properties;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import ParaBank.AutomationTestCase.DashBoard;
import io.github.bonigarcia.wdm.WebDriverManager;
public class MainDataSourceTest
public DashBoard dashboard;
public WebDriver inisilaizebroswer() throws IOException {
Properties prop = new Properties();
FileInputStream file = new FileInputStream(System.getProperty("user.dir")+"\src\main\java\SourceData\DataSource.properties");
String browserName=prop.getProperty("browser");
if(browserName.equalsIgnoreCase("chrome"))
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
else if(browserName.equalsIgnoreCase("firefox")) {
else if(browserName.equalsIgnoreCase("chrome")) {
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
public DashBoard LuanchApp() throws IOException
driver = inisilaizebroswer();
dashboard = new DashBoard(driver);
public void closedriver()
<code>package BaseDataSource;
import java.io.FileInputStream;
import java.io.IOException;
import java.time.Duration;
import java.util.Properties;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import ParaBank.AutomationTestCase.DashBoard;
import io.github.bonigarcia.wdm.WebDriverManager;
public class MainDataSourceTest
{
public WebDriver driver;
public DashBoard dashboard;
public WebDriver inisilaizebroswer() throws IOException {
Properties prop = new Properties();
FileInputStream file = new FileInputStream(System.getProperty("user.dir")+"\src\main\java\SourceData\DataSource.properties");
prop.load(file);
String browserName=prop.getProperty("browser");
if(browserName.equalsIgnoreCase("chrome"))
{
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
}
else if(browserName.equalsIgnoreCase("firefox")) {
}
else if(browserName.equalsIgnoreCase("chrome")) {
}
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
return driver;
}
@BeforeTest
public DashBoard LuanchApp() throws IOException
{
driver = inisilaizebroswer();
dashboard = new DashBoard(driver);
dashboard.GotoURL();
return dashboard;
}
public void closedriver()
{
driver.close();
}
}
</code>
package BaseDataSource;
import java.io.FileInputStream;
import java.io.IOException;
import java.time.Duration;
import java.util.Properties;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import ParaBank.AutomationTestCase.DashBoard;
import io.github.bonigarcia.wdm.WebDriverManager;
public class MainDataSourceTest
{
public WebDriver driver;
public DashBoard dashboard;
public WebDriver inisilaizebroswer() throws IOException {
Properties prop = new Properties();
FileInputStream file = new FileInputStream(System.getProperty("user.dir")+"\src\main\java\SourceData\DataSource.properties");
prop.load(file);
String browserName=prop.getProperty("browser");
if(browserName.equalsIgnoreCase("chrome"))
{
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
}
else if(browserName.equalsIgnoreCase("firefox")) {
}
else if(browserName.equalsIgnoreCase("chrome")) {
}
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
return driver;
}
@BeforeTest
public DashBoard LuanchApp() throws IOException
{
driver = inisilaizebroswer();
dashboard = new DashBoard(driver);
dashboard.GotoURL();
return dashboard;
}
public void closedriver()
{
driver.close();
}
}
<code>package ParaBank.AutomationTestCase;
import org.testng.Assert;
import org.testng.annotations.Test;
import BaseDataSource.MainDataSourceTest;
public class LogedInTest extends MainDataSourceTest
LogedIn acc = new LogedIn(driver);
dashboard.clicksubmit("BhaveshSolanki", "Bhavesh@1234");
public void accounttest(){
<code>package ParaBank.AutomationTestCase;
import org.testng.Assert;
import org.testng.annotations.Test;
import BaseDataSource.MainDataSourceTest;
public class LogedInTest extends MainDataSourceTest
{
LogedIn acc = new LogedIn(driver);
@Test
public void login()
{
dashboard.clicksubmit("BhaveshSolanki", "Bhavesh@1234");
}
@Test
public void accounttest(){
acc.newAccout();
}
}
</code>
package ParaBank.AutomationTestCase;
import org.testng.Assert;
import org.testng.annotations.Test;
import BaseDataSource.MainDataSourceTest;
public class LogedInTest extends MainDataSourceTest
{
LogedIn acc = new LogedIn(driver);
@Test
public void login()
{
dashboard.clicksubmit("BhaveshSolanki", "Bhavesh@1234");
}
@Test
public void accounttest(){
acc.newAccout();
}
}
<code>package ParaBank.AutomationTestCase;
import org.testng.Assert;
import org.testng.annotations.Test;
import BaseDataSource.MainDataSourceTest;
public class DashBoardTest extends MainDataSourceTest
dashboard.clicksubmit("BhaveshSolanki", "Bhavesh@1234");
String about = dashboard.VerifyAboutus();
Assert.assertEquals(about, "https://parabank.parasoft.com/parabank/about.htm");
String Service = dashboard.VerifyServices();
Assert.assertEquals(Service, "https://parabank.parasoft.com/parabank/services.htm");
String Products = dashboard.VerifyProducts();
Assert.assertEquals(Products, "http://www.parasoft.com/jsp/products.jsp");
String Location = dashboard.VerifyLocations();
Assert.assertEquals(Location,
"http://www.parasoft.com/jsp/pr/contacts.jsp");
public void adminpage() {
String admin = dashboard.VerifyAdminPage();
Assert.assertEquals(admin,
"https://parabank.parasoft.com/parabank/admin.htm");
public void RegisterURL()
dashboard.clickRegister();
<code>package ParaBank.AutomationTestCase;
import org.testng.Assert;
import org.testng.annotations.Test;
import BaseDataSource.MainDataSourceTest;
public class DashBoardTest extends MainDataSourceTest
{
@Test
public void login()
{
dashboard.clicksubmit("BhaveshSolanki", "Bhavesh@1234");
}
@Test
public void about()
{
String about = dashboard.VerifyAboutus();
Assert.assertEquals(about, "https://parabank.parasoft.com/parabank/about.htm");
}
@Test
public void service() {
String Service = dashboard.VerifyServices();
Assert.assertEquals(Service, "https://parabank.parasoft.com/parabank/services.htm");
}
@Test
public void products() {
String Products = dashboard.VerifyProducts();
Assert.assertEquals(Products, "http://www.parasoft.com/jsp/products.jsp");
}
@Test
public void location() {
String Location = dashboard.VerifyLocations();
Assert.assertEquals(Location,
"http://www.parasoft.com/jsp/pr/contacts.jsp");
}
@Test
public void adminpage() {
String admin = dashboard.VerifyAdminPage();
Assert.assertEquals(admin,
"https://parabank.parasoft.com/parabank/admin.htm");
}
@Test
public void RegisterURL()
{
dashboard.clickRegister();
}
}
</code>
package ParaBank.AutomationTestCase;
import org.testng.Assert;
import org.testng.annotations.Test;
import BaseDataSource.MainDataSourceTest;
public class DashBoardTest extends MainDataSourceTest
{
@Test
public void login()
{
dashboard.clicksubmit("BhaveshSolanki", "Bhavesh@1234");
}
@Test
public void about()
{
String about = dashboard.VerifyAboutus();
Assert.assertEquals(about, "https://parabank.parasoft.com/parabank/about.htm");
}
@Test
public void service() {
String Service = dashboard.VerifyServices();
Assert.assertEquals(Service, "https://parabank.parasoft.com/parabank/services.htm");
}
@Test
public void products() {
String Products = dashboard.VerifyProducts();
Assert.assertEquals(Products, "http://www.parasoft.com/jsp/products.jsp");
}
@Test
public void location() {
String Location = dashboard.VerifyLocations();
Assert.assertEquals(Location,
"http://www.parasoft.com/jsp/pr/contacts.jsp");
}
@Test
public void adminpage() {
String admin = dashboard.VerifyAdminPage();
Assert.assertEquals(admin,
"https://parabank.parasoft.com/parabank/admin.htm");
}
@Test
public void RegisterURL()
{
dashboard.clickRegister();
}
}
I am able suceesfully run dashboard.class testcasts but i am not able to LogedIn.class test cases.
can you please help me to resolve null exception.