lundi 15 février 2021

Cannot invoke "pageObject.loginPage.enter_username(String)" because "this.LoginPage" is null

I'm doing a simple login test project with cucumber + maven + testng. I can't write username and password in login page I can't login https://www.lambdatest.com/automation-demos/ website. Where I my mistake? What am I doing wrong.

 public class loginPage extends TestBase {
        
        public loginPage() {
            PageFactory.initElements(driver, this);
        }
        
        @FindBy(how = How.XPATH, using ="//input[@id='username']")
        WebElement uss;
    
        @FindBy(how = How.XPATH, using ="//input[@id='password']")
        WebElement pss;
    
        @FindBy(how = How.CSS, using=".applynow")
        WebElement buttonLogin;
        
        public void enter_username(String user) {
            uss.sendKeys(user); 
        }
    
        public void enter_password(String pass) {
            pss.sendKeys(pass);
        }
        public void enter_buttonLogin() {
            buttonLogin.click();
        }   
        
    }
    
    public class loginPageSteps extends TestBase{
        
        loginPage LoginPage;
        
        @Given("I open the login page")
        public void i_open_the_login_page() throws InterruptedException {
            TestBase.initialization();
        }
    
        @When("^I fill username \"([^\"]*)\" and password \"([^\"]*)\"$")
        public void i_fill_username_and_password(String username, String password) {
            
            LoginPage.enter_username(username);
            LoginPage.enter_password(password);
            LoginPage.enter_buttonLogin();
        }
        
        @Then("I should see the success login message \\\"([^\\\"]*)\\\"")
        public void i_should_see_the_success_login_message(String string) {
            // Write code here that turns the phrase above into concrete actions
            throw new cucumber.api.PendingException();
        }
    
    }

Aucun commentaire:

Enregistrer un commentaire