I was wondering if this platform could be of any help. I was running some test in eclipse, even though i have defined the test in a step definition, define the page object class, when i run the test it opens the browser and perform the first step but fail on the 2nd step (I click on the start button)i get the NullpointerException.
[DEBUG] Adding key: http://localhost:48614 for channel [id: 0x69f1164a, L:/127.0.0.1:59373 - R:localhost/127.0.0.1:48614]
Given I am from Wales and i launch the checkertool #
stepDefinitions.steps.i_am_from_wales_and_i_launch_the_checkertool()
When I click on the start button # stepDefinitions.steps.i_click_on_the_start_button()
[DEBUG] Entry count for : http://localhost:59374 : 1
[DEBUG] Entry count for : http://localhost:48614 : 1
java.lang.NullPointerException at org.openqa.selenium.support.pagefactory.DefaultElementLocator.findElement(DefaultElementLocator.java:70)
at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:39)
at com.sun.proxy.$Proxy15.click(Unknown Source)
at pageObjects.loginPage.Clicknocookies(loginPage.java:30)
at stepDefinitions.steps.i_click_on_the_start_button(steps.java:36)
at ✽.I click on the start button(file:///C:/Users/aka_s/eclipse-workspace/nhsbsa/./Features/Walesticket.feature:5)
And I choose my country # stepDefinitions.steps.i_choose_my_country()
And I input my date of birth # stepDefinitions.steps.i_input_my_date_of_birth()
When I choose if i live with my partner or not # stepDefinitions.steps.i_choose_if_i_live_with_my_partner_or_not()
And I choose whether i claim tax benefit # stepDefinitions.steps.i_choose_whether_i_claim_tax_benefit()
And I choose whether i am pregnant or given birth in the last twelve month # stepDefinitions.steps.i_choose_whether_i_am_pregnant_or_given_birth_in_the_last_twelve_month()
And I choose if i have injury caused by service # stepDefinitions.steps.i_choose_if_i_have_injury_caused_by_service()
And I choose if i am diabetic or not # stepDefinitions.steps.i_choose_if_i_am_diabetic_or_not()
When I choose if myself or my family has gloucoma # stepDefinitions.steps.i_choose_if_myself_or_my_family_has_gloucoma()
And I choose if i live permanently in a care home # stepDefinitions.steps.i_choose_if_i_live_permanently_in_a_care_home()
And I choose if i have savings more than sixteen thousand pounds # stepDefinitions.steps.i_choose_if_i_have_savings_more_than_sixteen_thousand_pounds()
Then I should get a result of whether I will get help or not # stepDefinitions.steps.i_should_get_a_result_of_whether_i_will_get_help_or_not()
Also find the features files
Feature: Wales Test Ticket
Scenario: Test to Validate Wales Test Ticket
Given I am from Wales and i launch the checkertool
When I click on the start button
And I choose my country
And I input my date of birth
When I choose if i live with my partner or not
And I choose whether i claim tax benefit
And I choose whether i am pregnant or given birth in the last twelve month
And I choose if i have injury caused by service
And I choose if i am diabetic or not
When I choose if myself or my family has gloucoma
And I choose if i live permanently in a care home
And I choose if i have savings more than sixteen thousand pounds
Then I should get a result of whether I will get help or not
Kindly find below the step definition for the 1st and 2nd scenario. package stepDefinitions;
import static org.junit.Assert.assertEquals;
import org.openqa.selenium.WebDriver;
import io.cucumber.java.en.*;
import pageObjects.birthPage;
import pageObjects.countryPage;
import pageObjects.diabetesPage;
import pageObjects.glaucomaPage;
import pageObjects.injuryPage;
import pageObjects.loginPage;
import pageObjects.partnerPage;
import pageObjects.pregnantPage;
import pageObjects.residencePage;
import pageObjects.resultPage;
import pageObjects.savingsPage;
import pageObjects.taxbenefitPage;
import utilities.Executescript;
import utilities.browserDriver;
public class steps
{
public WebDriver driver;
public loginPage login = new loginPage(driver) ;
@Given("I am from Wales and i launch the checkertool")
public void i_am_from_wales_and_i_launch_the_checkertool() {
driver = browserDriver.getDriver();
}
@When("I click on the start button")
public void i_click_on_the_start_button() throws Exception{
login.Clicknocookies();
Executescript.JavascriptexecutorCoordinate(driver);
login.Clickstartbutton();
}
Find below Page object for the loginpage.
public class loginPage {
WebDriver driver;
// Constructor for the webdriver
public loginPage(WebDriver driver) {
this.driver = driver;
PageFactory.initElements(driver, this);
}
// Collection of web element
@FindBy(how = How.ID, using = "next-button")
private WebElement startbutton;
@FindBy(how = How.ID, using = "nhs-global-header")
private WebElement donotusecookies;
public void Clicknocookies() {
donotusecookies.click();
}
public void Clickstartbutton() {
startbutton.click();
}
}
Aucun commentaire:
Enregistrer un commentaire