Example usage for org.openqa.selenium By cssSelector

List of usage examples for org.openqa.selenium By cssSelector

Introduction

In this page you can find the example usage for org.openqa.selenium By cssSelector.

Prototype

public static By cssSelector(String cssSelector) 

Source Link

Document

Find elements via the driver's underlying W3C Selector engine.

Usage

From source file:com.company.components.impl.SearchBoxImpl.java

License:Apache License

private List<WebElement> getSuggestionItems() {

    // Must use Selenium's findElements() because framework's wrappers
    // (like jQuery syntax) are relative to this component's parent node,
    // while suggestions reside at the end of the whole document.

    By by = By.cssSelector("div.suggestions-result");
    return browser.findElements(by);
}

From source file:com.consol.citrus.selenium.actions.FindElementAction.java

License:Apache License

/**
 * Create by selector from type information.
 * @return//from ww  w .j a  va  2  s . c  o m
 */
protected By createBy(TestContext context) {
    if (by != null) {
        return by;
    }

    switch (property) {
    case "id":
        return By.id(context.replaceDynamicContentInString(propertyValue));
    case "class-name":
        return By.className(context.replaceDynamicContentInString(propertyValue));
    case "link-text":
        return By.linkText(context.replaceDynamicContentInString(propertyValue));
    case "css-selector":
        return By.cssSelector(context.replaceDynamicContentInString(propertyValue));
    case "name":
        return By.name(context.replaceDynamicContentInString(propertyValue));
    case "tag-name":
        return By.tagName(context.replaceDynamicContentInString(propertyValue));
    case "xpath":
        return By.xpath(context.replaceDynamicContentInString(propertyValue));
    }

    throw new CitrusRuntimeException("Unknown selector type: " + property);
}

From source file:com.consol.citrus.selenium.actions.FindElementActionTest.java

License:Apache License

@DataProvider
public Object[][] findByProvider() {
    return new Object[][] { new Object[] { "id", "myId", By.id("myId") },
            new Object[] { "name", "myName", By.name("myName") },
            new Object[] { "tag-name", "button", By.tagName("button") },
            new Object[] { "class-name", "myClass", By.className("myClass") },
            new Object[] { "link-text", "myLinkText", By.linkText("myLinkText") },
            new Object[] { "css-selector", "myCss", By.cssSelector("myCss") },
            new Object[] { "xpath", "myXpath", By.xpath("myXpath") } };
}

From source file:com.consol.citrus.selenium.client.WebClient.java

License:Apache License

/**
 * Click on a single element indicated by given CSS selector.
 *
 * @param selector The selector.//from  w w  w  . j ava  2s.c  o  m
 */
public void clickBySelector(String selector) {
    findElement(By.cssSelector(selector)).click();
}

From source file:com.consol.citrus.selenium.client.WebClient.java

License:Apache License

public static By getByFromEnum(ByEnum byEnum, String select) {
    By by = null;/*from  ww w .  j  ava  2s. c  o m*/
    switch (byEnum) {
    case ID:
        by = By.id(select);
        break;
    case CLASS_NAME:
        by = By.className(select);
        break;
    case LINK_TEXT:
        by = By.linkText(select);
        break;
    case CSS_SELECTOR:
        by = By.cssSelector(select);
        break;
    case NAME:
        by = By.name(select);
        break;
    case TAG_NAME:
        by = By.tagName(select);
        break;
    case XPATH:
        by = By.xpath(select);
        break;
    }
    return by;
}

From source file:com.contactenergy.Tests.ContactBrowserTest.java

@Test(dataProvider = "devices")
public void ResidentialJoinJourney_onDesktop(TestDevice device) throws IOException, Exception {
    load("/Residential/Find-a-Plan");

    Assert.assertTrue("Navigated to Residential Join Page",
            driver.get().findElement(By.xpath("//label[contains(.,'Enter your address')]")).isDisplayed());

    driver.get().findElement(By.xpath("//label[contains(.,'Enter your address')]")).click();

    driver.get().findElement(By.xpath("//input[contains(@autocomplete,'off')]"))
            .sendKeys("1 Bressay Way, Waikanae   5036");

    WebDriverWait wait = new WebDriverWait(driver.get(), 15);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//li[@class='ui-menu-item']")));

    driver.get().findElement(By.xpath("//li[@class='ui-menu-item']")).click();

    driver.get().findElement(By.xpath("//label[contains(@for,'ELEC')]")).click();

    scrollto("//h2[@class='form-subtitle']");
    driver.get().findElement(By.xpath("//label[contains(@for,'Three')]")).click();

    driver.get().findElement(By.xpath("//label[@for='WaterHeatingMethod _Gas']")).click();

    scrollto("//label[@for='WaterHeatingMethod']");
    driver.get().findElement(By.xpath("//label[@for='Property[PropertyInfo][ElectricityUserType] _Standard']"))
            .click();/*w  ww.  j  ava  2  s .  c  om*/

    System.out.println(driver.get().findElement(By.cssSelector(".message")).getText());

    scrollto("//h2[@class='recommendedplan-title']");

    driver.get().findElement(By.xpath("//a[@data-filter='PPD']")).click();

    scrollto("//h2[@class='recommendedplan-title sub']");
    driver.get().findElement(By.xpath("//h2[contains(.,'Certainty Plus')]")).click();

    scrollandclick("//a[@class='btn btn-default plan-progress-btn']");

    if (driver.get().findElement(By.xpath("//h2[contains(.,'About You')]")).isDisplayed()) {
        System.out.println("User on second page filling his details on Join Journey");
    }

    driver.get().findElement(By.xpath("//label[@for='Customer[CustomerInfo][Title] _Mr']")).click();

    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][FirstName]']"))
            .sendKeys("AutoRegression");
    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][LastName]']"))
            .sendKeys("AutoRegression");

    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][EmailAddress]']"))
            .sendKeys("DPTSTTM@contactenergy.co.nz");
    driver.get().findElement(By.xpath("//label[@for='Confirmation[ReceiveNewsAndOffers]']")).click();

    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][PhoneNumber]']"))
            .sendKeys("1231312232");
    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][DateOfBirth]']"))
            .sendKeys("02/06/2002");
    scrollto("//h2[contains(.,'About your property')]");
    driver.get().findElement(By.xpath("//label[@for='Property[MoveInfo][IsMovingHouse]_NO']")).click();

    driver.get().findElement(By.xpath("//label[@for='Property[PropertyInfo][WithAnotherSupplier]_YES']"))
            .click();

    scrollto("//label[@for='Property[PropertyInfo][AddressSameAsPostalAddress]']");
    driver.get().findElement(By.xpath("//label[@for='Property[PropertyInfo][HasPropertyHazard]_NO']")).click();

    driver.get().findElement(By.xpath("//label[@for='Property[MedicalInfo][HasVulnerablePerson]_NO']")).click();
    driver.get().findElement(By.xpath("//label[@for='Property[MedicalInfo][HasMedicalDependant]_NO']")).click();

    scrollto("//h2[contains(.,'Extra discounts & rewards')]");
    driver.get().findElement(By.xpath("//label[@for='Promotion[PaperlessDiscount]_YES']")).click();
    driver.get().findElement(By.xpath("//label[@for='Promotion[JoinDirectDebit]_NO']")).click();

    scrollto("//h2[contains(.,'Final Steps')]");
    driver.get().findElement(By.xpath("//label[@for='Customer[HasDriversLicense]_NO']")).click();

    scrollandclick("//label[@for='Confirmation-AcceptPlanTermsAndConditions']");
    scrollandclick("//label[@for='Confirmation-AcceptGeneralTermsAndConditions']");

    scrollandclick("//input[@type='submit']");

    Assert.assertTrue("Navigated to Move House Success Page",
            driver.get().findElement(By.xpath("//h1[contains(.,'Thanks!')]")).isDisplayed());
}

From source file:com.contactenergy.Tests.ContactBrowserTest.java

@Test(dataProvider = "devices")
public void MoveNewCustomerJourney_onDesktop(TestDevice device) throws IOException, Exception {

    load("/Residential/Electricity/Find-a-Plan/Moving-House");

    Assert.assertTrue("Navigated to Residential Moving House Page",
            driver.get().findElement(By.xpath("//h2[contains(.,'Moving House')]")).isDisplayed());

    scrollto("//h2[contains(.,'Already with Contact?')]");

    driver.get().findElement(By.xpath("//*[@id='app']/div[4]/div[1]/div/div/div[2]/div/a")).click();

    driver.get().findElement(By.xpath("//label[contains(.,'Enter your address')]")).click();

    driver.get().findElement(By.xpath("//input[contains(@autocomplete,'off')]"))
            .sendKeys("1 Bressay Way, Waikanae   5036");

    WebDriverWait wait = new WebDriverWait(driver.get(), 15);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//li[@class='ui-menu-item']")));

    driver.get().findElement(By.xpath("//li[@class='ui-menu-item']")).click();

    driver.get().findElement(By.xpath("//label[contains(@for,'ELEC')]")).click();

    scrollto("//h2[@class='form-subtitle']");
    driver.get().findElement(By.xpath("//label[contains(@for,'Three')]")).click();

    driver.get().findElement(By.xpath("//label[@for='WaterHeatingMethod _Gas']")).click();

    scrollto("//label[@for='WaterHeatingMethod']");
    driver.get().findElement(By.xpath("//label[@for='Property[PropertyInfo][ElectricityUserType] _Standard']"))
            .click();/*from   w w  w  . j ava 2  s.  com*/

    System.out.println(driver.get().findElement(By.cssSelector(".message")).getText());

    scrollto("//h2[@class='recommendedplan-title']");
    driver.get().findElement(By.xpath("//a[@data-filter='FIXED']")).click();

    scrollto("//h2[@class='recommendedplan-title sub']");
    driver.get().findElement(By.xpath("//h2[contains(.,'Certainty Plus')]")).click();

    scrollandclick("//a[@class='btn btn-default plan-progress-btn']");

    if (driver.get().findElement(By.xpath("//h2[contains(.,'About You')]")).isDisplayed()) {
        System.out.println("User on second page filling his details on Move Journey");
    }

    driver.get().findElement(By.xpath("//label[@for='Customer[CustomerInfo][Title] _Mr']")).click();

    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][FirstName]']"))
            .sendKeys("AutoRegression");
    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][LastName]']"))
            .sendKeys("AutoRegression");

    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][EmailAddress]']"))
            .sendKeys("DPTSTTM@contactenergy.co.nz");
    driver.get().findElement(By.xpath("//label[@for='Confirmation[ReceiveNewsAndOffers]']")).click();

    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][PhoneNumber]']"))
            .sendKeys("1231312232");
    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][DateOfBirth]']"))
            .sendKeys("02/06/2002");
    scrollto("//h2[contains(.,'About your property')]");
    driver.get().findElement(By.xpath("//label[@for='Property[MoveInfo][IsMovingHouse]_YES']")).click();

    driver.get().findElement(By.xpath("//input[@id='Property[MoveInfo][MoveInDate]']")).sendKeys("30/06/2017");
    scrollto("//label[@for='Property[PropertyInfo][AddressSameAsPostalAddress]']");
    driver.get().findElement(By.xpath("//label[@for='Property[PropertyInfo][HasPropertyHazard]_NO']")).click();

    scrollandclick("//label[@for='Property[MedicalInfo][HasVulnerablePerson]_NO']");
    driver.get().findElement(By.xpath("//label[@for='Property[MedicalInfo][HasMedicalDependant]_NO']")).click();

    driver.get().findElement(By.xpath("//label[@for='Promotion[PaperlessDiscount]_YES']")).click();
    driver.get().findElement(By.xpath("//label[@for='Promotion[JoinDirectDebit]_NO']")).click();

    driver.get().findElement(By.xpath("//label[@for='Customer[HasDriversLicense]_NO']")).click();

    scrollandclick("//label[@for='Confirmation-AcceptPlanTermsAndConditions']");
    scrollandclick("//label[@for='Confirmation-AcceptGeneralTermsAndConditions']");

    scrollandclick("//input[@type='submit']");
    Assert.assertTrue("Navigated to Move House Success Page",
            driver.get().findElement(By.xpath("//h1[contains(.,'Thanks!')]")).isDisplayed());
}

From source file:com.contactenergy.Tests.ContactBrowserTest.java

@Test(dataProvider = "devices")
public void ExistingCustomerMovingHouseJourney_onDesktop(TestDevice device) throws IOException, Exception {

    load("/Residential/Electricity/Find-a-Plan/Moving-House");

    Assert.assertTrue("Navigated to Residential Moving House Page",
            driver.get().findElement(By.xpath("//h2[contains(.,'Moving House')]")).isDisplayed());

    scrollto("//h2[contains(.,'Already with Contact?')]");

    driver.get().findElement(By.xpath("//*[@id='app']/div[4]/div[2]/div[1]/div/div/div[2]/div/a")).click();

    Assert.assertTrue("Navigated to Residential Moving House Existing Customer Make-Changes Page", driver.get()
            .findElement(By.xpath("//h2[contains(.,'Hi, what would you like to do today?')]")).isDisplayed());

    driver.get().findElement(By.xpath("//label[@for='UserJourneyAction_MoveHouse']")).click();
    driver.get().findElement(By.xpath("//input[@id='AccountNumber']")).sendKeys("1231312232");

    driver.get().findElement(By.xpath("//input[contains(@autocomplete,'off')]"))
            .sendKeys("1 Bressay Way, Waikanae   5036");

    WebDriverWait wait = new WebDriverWait(driver.get(), 15);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//li[@class='ui-menu-item']")));

    driver.get().findElement(By.xpath("//li[@class='ui-menu-item']")).click();

    driver.get().findElement(By.xpath("//label[contains(@for,'ELEC')]")).click();
    driver.get().findElement(By.xpath("//label[contains(@for,'GAS')]")).click();

    scrollto("//h2[@class='form-subtitle']");
    driver.get().findElement(By.xpath("//label[contains(@for,'Three')]")).click();

    driver.get().findElement(By.xpath("//label[@for='WaterHeatingMethod _Gas']")).click();

    scrollto("//label[@for='WaterHeatingMethod']");
    driver.get().findElement(By.xpath("//label[@for='Property[PropertyInfo][ElectricityUserType] _Standard']"))
            .click();/*from w  w  w.j av  a  2  s.  c  o  m*/

    scrollto("//h2[@class='recommendedplan-title']");
    System.out.println(driver.get().findElement(By.cssSelector(".message")).getText());

    driver.get().findElement(By.xpath("//a[@data-filter='FIXED']")).click();

    scrollto("//h2[@class='recommendedplan-title sub']");
    driver.get().findElement(By.xpath("//h2[contains(.,'Certainty Plus')]")).click();

    scrollandclick("//a[@class='btn btn-default plan-progress-btn']");

    if (driver.get().findElement(By.xpath("//h2[contains(.,'About You')]")).isDisplayed()) {
        System.out.println("User on second page filling his details on existing customer Move house Journey");
    }

    driver.get().findElement(By.xpath("//label[@for='Customer[CustomerInfo][Title] _Mr']")).click();

    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][FirstName]']"))
            .sendKeys("AutoRegression");
    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][LastName]']"))
            .sendKeys("AutoRegression");

    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][EmailAddress]']"))
            .sendKeys("DPTSTTM@contactenergy.co.nz");

    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][PhoneNumber]']"))
            .sendKeys("1231312232");
    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][DateOfBirth]']"))
            .sendKeys("02/06/2002");

    driver.get().findElement(By.xpath("//label[contains(.,'Your current address')]")).click();

    driver.get().findElement(By.xpath("//input[contains(@autocomplete,'off')]"))
            .sendKeys("2 Bressay Way, Waikanae   5036");

    WebDriverWait wait1 = new WebDriverWait(driver.get(), 15);
    wait1.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//li[@class='ui-menu-item']")));

    driver.get().findElement(By.xpath("//li[@class='ui-menu-item']")).click();

    scrollto("//h2[contains(.,'About your property')]");
    driver.get().findElement(By.xpath("//input[@id='Property[MoveInfo][MoveOutDate]']")).sendKeys("30/06/2017");
    driver.get().findElement(By.xpath("//label[@for='Property[PropertyInfo][HaveFinalMeterReading]_NO']"))
            .click();
    driver.get().findElement(By.xpath("//label[@for='Property[PropertyInfo][SendMeterReader]_NO']")).click();

    driver.get().findElement(By.xpath("//input[@id='Property[MoveInfo][MoveInDate]']")).sendKeys("30/06/2017");

    driver.get().findElement(By.xpath("//label[@for='Property[PropertyInfo][HasPropertyHazard]_NO']")).click();

    driver.get().findElement(By.xpath("//label[@for='Property[MedicalInfo][HasVulnerablePerson]_NO']")).click();
    driver.get().findElement(By.xpath("//label[@for='Property[MedicalInfo][HasMedicalDependant]_NO']")).click();

    driver.get().findElement(By.xpath("//label[@for='Promotion[PaperlessDiscount]_YES']")).click();

    driver.get().findElement(By.xpath("//label[@for='Promotion[JoinDirectDebit]_NO']")).click();

    scrollandclick("//label[@for='Confirmation-AcceptPlanTermsAndConditions']");
    scrollandclick("//label[@for='Confirmation-AcceptGeneralTermsAndConditions']");

    scrollandclick("//input[@type='submit']");
    Assert.assertTrue("Navigated to Move House Success Page",
            driver.get().findElement(By.xpath("//h1[contains(.,'Thanks!')]")).isDisplayed());
}

From source file:com.contactenergy.Tests.ContactBrowserTest.java

@Test(dataProvider = "devices")
public void ExistingCustomerAddPropertyJourney_onDesktop(TestDevice device) throws IOException, Exception {

    load("/Residential/Electricity/Find-a-Plan/Moving-House");

    Assert.assertTrue("Navigated to Residential Moving House Page",
            driver.get().findElement(By.xpath("//h2[contains(.,'Moving House')]")).isDisplayed());

    scrollto("//h2[contains(.,'Already with Contact?')]");

    driver.get().findElement(By.xpath("//*[@id='app']/div[4]/div[2]/div[1]/div/div/div[2]/div/a")).click();

    Assert.assertTrue("Navigated to Residential Moving House Existing Customer Make-Changes Page", driver.get()
            .findElement(By.xpath("//h2[contains(.,'Hi, what would you like to do today?')]")).isDisplayed());

    driver.get().findElement(By.xpath("//label[contains(.,'Adding a property')]")).click();
    driver.get().findElement(By.xpath("//input[@id='AccountNumber']")).sendKeys("1231312232");
    driver.get().findElement(By.xpath("//label[contains(.,'Enter the address of your additional property')]"))
            .click();/*from  w ww .  j  a  va 2s .  c  o  m*/

    driver.get().findElement(By.xpath("//input[contains(@autocomplete,'off')]"))
            .sendKeys("1 Bressay Way, Waikanae   5036");

    WebDriverWait wait = new WebDriverWait(driver.get(), 15);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//li[@class='ui-menu-item']")));

    driver.get().findElement(By.xpath("//li[@class='ui-menu-item']")).click();

    driver.get().findElement(By.xpath("//label[contains(@for,'ELEC')]")).click();
    driver.get().findElement(By.xpath("//label[contains(@for,'GAS')]")).click();

    scrollto("//h2[@class='form-subtitle']");
    driver.get().findElement(By.xpath("//label[contains(@for,'Three')]")).click();

    driver.get().findElement(By.xpath("//label[@for='WaterHeatingMethod _Gas']")).click();

    scrollto("//label[@for='WaterHeatingMethod']");
    driver.get().findElement(By.xpath("//label[@for='Property[PropertyInfo][ElectricityUserType] _Standard']"))
            .click();
    System.out.println(driver.get().findElement(By.cssSelector(".message")).getText());

    scrollto("//h2[@class='recommendedplan-title']");
    driver.get().findElement(By.xpath("//a[@data-filter='FIXED']")).click();

    scrollto("//h2[@class='recommendedplan-title sub']");
    driver.get().findElement(By.xpath("//h2[contains(.,'Certainty Plus')]")).click();

    scrollandclick("//a[@class='btn btn-default plan-progress-btn']");

    if (driver.get().findElement(By.xpath("//h2[contains(.,'About You')]")).isDisplayed()) {
        System.out.println("User on second page filling his details on Move Journey");
    }

    driver.get().findElement(By.xpath("//label[@for='Customer[CustomerInfo][Title] _Mr']")).click();

    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][FirstName]']"))
            .sendKeys("AutoRegression");
    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][LastName]']"))
            .sendKeys("AutoRegression");

    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][EmailAddress]']"))
            .sendKeys("DPTSTTM@contactenergy.co.nz");

    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][PhoneNumber]']"))
            .sendKeys("1231312232");
    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][DateOfBirth]']"))
            .sendKeys("02/06/2002");

    scrollto("//h2[contains(.,'About your property')]");
    driver.get().findElement(By.xpath("//input[@id='Property[MoveInfo][MoveInDate]']")).sendKeys("30/06/2017");

    driver.get().findElement(By.xpath("//label[@for='Property[PropertyInfo][IsBach]_YES']")).click();

    driver.get().findElement(By.xpath("//label[@for='Property[PropertyInfo][HasPropertyHazard]_NO']")).click();
    scrollto("//label[@for='Property[PropertyInfo][HasPropertyHazard]_NO']");
    driver.get().findElement(By.xpath("//label[@for='Property[MedicalInfo][HasVulnerablePerson]_NO']")).click();
    driver.get().findElement(By.xpath("//label[@for='Property[MedicalInfo][HasMedicalDependant]_NO']")).click();
    scrollto("//h2[contains(.,'Extra discounts & rewards')]");
    driver.get().findElement(By.xpath("//label[@for='Promotion[PaperlessDiscount]_YES']")).click();
    driver.get().findElement(By.xpath("//label[@for='Promotion[JoinDirectDebit]_NO']")).click();

    scrollandclick("//label[@for='Confirmation-AcceptPlanTermsAndConditions']");
    scrollandclick("//label[@for='Confirmation-AcceptGeneralTermsAndConditions']");

    scrollandclick("//input[@type='submit']");

    Assert.assertTrue("Navigated to Move House Success Page",
            driver.get().findElement(By.xpath("//h1[contains(.,'Thanks!')]")).isDisplayed());
}

From source file:com.contactenergy.Tests.ContactBrowserTest.java

@Test(dataProvider = "devices")
public void ExistingCustomerChangePlanJourney_onDesktop(TestDevice device) throws IOException, Exception {

    load("/Residential/Electricity/Find-a-Plan/Moving-House");

    Assert.assertTrue("Navigated to Residential Moving House Page",
            driver.get().findElement(By.xpath("//h2[contains(.,'Moving House')]")).isDisplayed());

    scrollto("//h2[contains(.,'Already with Contact?')]");

    driver.get().findElement(By.xpath("//*[@id='app']/div[4]/div[2]/div[1]/div/div/div[2]/div/a")).click();

    Assert.assertTrue("Navigated to Residential Moving House Existing Customer Make-Changes Page", driver.get()
            .findElement(By.xpath("//h2[contains(.,'Hi, what would you like to do today?')]")).isDisplayed());

    driver.get().findElement(By.xpath("//label[contains(.,'Changing my plan')]")).click();
    driver.get().findElement(By.xpath("//input[@id='AccountNumber']")).sendKeys("1231312232");
    driver.get().findElement(By.xpath("//label[contains(.,'Enter your address')]")).click();

    driver.get().findElement(By.xpath("//input[contains(@autocomplete,'off')]"))
            .sendKeys("1 Bressay Way, Waikanae   5036");

    WebDriverWait wait = new WebDriverWait(driver.get(), 15);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//li[@class='ui-menu-item']")));

    driver.get().findElement(By.xpath("//li[@class='ui-menu-item']")).click();

    driver.get().findElement(By.xpath("//label[contains(@for,'ELEC')]")).click();
    driver.get().findElement(By.xpath("//label[contains(@for,'GAS')]")).click();

    scrollto("//h2[@class='form-subtitle']");
    driver.get().findElement(By.xpath("//label[contains(@for,'Three')]")).click();

    driver.get().findElement(By.xpath("//label[@for='WaterHeatingMethod _Gas']")).click();

    scrollto("//label[@for='WaterHeatingMethod']");
    driver.get().findElement(By.xpath("//label[@for='Property[PropertyInfo][ElectricityUserType] _Standard']"))
            .click();/*from  ww w .ja  v  a  2  s . co  m*/

    System.out.println(driver.get().findElement(By.cssSelector(".message")).getText());

    scrollto("//h2[@class='recommendedplan-title']");
    driver.get().findElement(By.xpath("//a[@data-filter='FIXED']")).click();

    scrollto("//h2[@class='recommendedplan-title sub']");
    driver.get().findElement(By.xpath("//h2[contains(.,'Certainty')]")).click();

    scrollandclick("//a[@class='btn btn-default plan-progress-btn']");

    if (driver.get().findElement(By.xpath("//h2[contains(.,'About You')]")).isDisplayed()) {
        System.out.println("User on second page filling his details on Move Journey");
    }

    driver.get().findElement(By.xpath("//label[@for='Customer[CustomerInfo][Title] _Mr']")).click();

    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][FirstName]']"))
            .sendKeys("AutoRegression");
    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][LastName]']"))
            .sendKeys("AutoRegression");

    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][EmailAddress]']"))
            .sendKeys("DPTSTTM@contactenergy.co.nz");
    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][PhoneNumber]']"))
            .sendKeys("1231312232");
    driver.get().findElement(By.xpath("//input[@id='Customer[CustomerInfo][DateOfBirth]']"))
            .sendKeys("02/06/2002");
    scrollto("//h2[contains(.,'Extra discounts & rewards')]");
    driver.get().findElement(By.xpath("//label[@for='Promotion[PaperlessDiscount]_YES']")).click();
    driver.get().findElement(By.xpath("//label[@for='Promotion[JoinDirectDebit]_NO']")).click();

    scrollandclick("//label[@for='Confirmation-AcceptPlanTermsAndConditions']");

    scrollandclick("//input[@type='submit']");

    Assert.assertTrue("MoveExistingCustomerChangePlanJourney Success Page",
            driver.get().findElement(By.xpath("//h1[contains(.,'Thanks!')]")).isDisplayed());
}