0

Test:

package com.digitalmqc.automation.ff.projectstests;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.PageFactory;
import org.testng.annotations.Test;

import com.digitalmqc.automation.ff.projectspages.loginpage;
import com.digitalmqc.automation.utils.LoginTypes;
//import org.openqa.selenium.WebElement;

public class CbaLoginandhomepagetest 
{
    WebDriver driver;
    //WebElement w;
    @Test
    public void cbalogin() throws Exception
    {
    LoginTypes type=PageFactory.initElements(driver,LoginTypes.class );
    type.cbachromeLogin();
    loginpage login=PageFactory.initElements(driver, loginpage.class);
    Thread.sleep(5000L);
    login.cbclogin("abc","abc@gmail.com","xyz");


    }

}

Page:

 /* 
 */
package com.digitalmqc.automation.ff.projectspages;

import org.openqa.selenium.support.How;
import org.openqa.selenium.support.CacheLookup;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

/**
 * @author user
 *
 */
public class loginpage
{
    WebDriver driver;
    public loginpage(WebDriver ldriver)
    {
        this.driver=ldriver;
    }
    @FindBy(how=How.XPATH,using=".//*[@id='cbDomain']")
    @CacheLookup
    WebElement domain;
    @FindBy(how=How.XPATH,using=".//*[@id='cbUname']")
    @CacheLookup
    WebElement username;
    @FindBy(how=How.XPATH,using=".//*[@id='cbPwd']")
    @CacheLookup
    WebElement password;
    @FindBy(how=How.XPATH,using=".//*[@id='ssoForm']/p[2]/button")
    @CacheLookup
    WebElement submit;
    @FindBy(how=How.LINK_TEXT,using=".//*[@id='ssoForm']/p[3]/a")
    WebElement forgotpassword;

    public void cbclogin(String domain_name,String uname,String pass)
    {
        domain.sendKeys(domain_name);
        username.sendKeys(uname);
        password.sendKeys(pass);
        submit.click();
    }

}
  • 3
    Without knowing what the null pointer exception is, it's not possible to say what the problem is. You need to edit the question to include the error information. – Kate Paulk Mar 31 '16 at 11:19
1

You are not initializing the Webdriver driver field anywhere in your Test class. So you're essentially passing nothing to the Page constructor.

Try this: driver = new FirefoxDriver();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.