Example usage for org.openqa.selenium WebElement click

List of usage examples for org.openqa.selenium WebElement click

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement click.

Prototype

void click();

Source Link

Document

Click this element.

Usage

From source file:com.consensus.qa.verizon.tests.ExchangeTests.java

@Test(groups = { "verizon" })
@Parameters("test-type")
public void QA_51_VerizonNonEdgeExchangeLikeForUnlike(@Optional String testtype)
        throws IOException, InterruptedException, AWTException {

    DependantTestCaseInputs dependantValues = Utilities.ReadFromCSV("QA_50");
    if (dependantValues.TC_ID == "" || dependantValues.ORDER_ID == "") {
        AddNewLineTests addNewLine = new AddNewLineTests();
        addNewLine.QA50_VerizonNonEdgeWithNumberPortCCInCA(BrowserSettings.readConfig("test-type"));
        dependantValues = Utilities.ReadFromCSV("QA_50");
        if (dependantValues.TC_ID == "" || dependantValues.ORDER_ID == "") {
            Reporter.log("<br> Data is not available from QA_50");
            Assert.fail("Data is not available from QA_50");
        }//from w ww  .  j av a2s .  co m
    }
    String ChildOrderId = null;
    String newIMEI1 = PageBase.CSVOperations()
            .GetIMEIOrSimNumberOrReceiptId(FileName.SamsungGalaxyS4_16GBWhite);
    String newIMEI2 = PageBase.CSVOperations()
            .GetIMEIOrSimNumberOrReceiptId(FileName.SamsungGalaxyS4_16GBWhite);
    String simType1 = PageBase.CSVOperations().GetIMEIOrSimNumberOrReceiptId(FileName.Sim_3FF);
    String simType2 = PageBase.CSVOperations().GetIMEIOrSimNumberOrReceiptId(FileName.Sim_3FF);
    String testType = BrowserSettings.readConfig("test-type");
    Reporter.log("QA_51_VerizonNonEdgeLikeForUnlike Starts.");
    Reporter.log("<br>Launching Browser");
    Log.startTestCase("QA_51_VerizonNonEdgeExchange_LikeForUnlike");

    //Carrier and Test Type Settings
    SetTestTypeForQA_51(testType);

    String receiptId = dependantValues.RECEIPT_ID;

    Utilities.switchPreviousTab();
    //Calling DBError utility to  find initial count or error in log files.
    DBError.navigateDBErrorPage();
    int initialCount = PageBase.AdminPage().totalErrorCount();

    Utilities.switchPreviousTab();
    PageBase.LoginPageRetail().poaLogin(Utilities.getCredentials("tuserUN"),
            Utilities.getCredentials("tuserPwd"), Utilities.getCredentials("storeId0003"));
    Reporter.log("Returning the device using Receipt ID: ");
    PageBase.HomePageRetail().newGuestButton.click();
    PageBase.HomePageRetail().guestLookupTab.click();
    PageBase.CustomerLookupPage().receiptIdTextbox.sendKeys(receiptId);
    Reporter.log(receiptId);

    List<WebElement> SubmitButtons = driver.findElements(By.xpath(ControlLocators.SUBMIT_RECEIPTID));
    for (WebElement visibleSubmitButton : SubmitButtons) {
        if (visibleSubmitButton.isDisplayed()) {
            visibleSubmitButton.click();
            break;
        }
    }

    PageBase.CarrierCreditCheckPage().firstNameTextBox.sendKeys(dependantValues.FIRST_NAME);
    PageBase.CarrierCreditCheckPage().lastNameTextBox.sendKeys(dependantValues.LAST_NAME);
    Reporter.log("<br>First Name: " + dependantValues.FIRST_NAME);
    Reporter.log("  Last Name: " + dependantValues.LAST_NAME + "; ");
    SelectLicense(dependantValues.ID_TYPE, PageBase.ReturnOrExchangeVerificationPage().idTypeDropdown);
    Reporter.log("State: " + dependantValues.STATE + "; ");
    Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().stateDropdown,
            SelectDropMethod.SELECTBYTEXT, dependantValues.STATE);
    Reporter.log("ID Type: " + dependantValues.ID_TYPE + "; ");
    PageBase.ReturnOrExchangeVerificationPage().idNumberTextbox.sendKeys(dependantValues.ID_NUMBER);
    Reporter.log("ID Number: " + dependantValues.ID_NUMBER + ".");
    PageBase.CommonControls().continueCommonButton.click();
    Utilities.waitForElementVisible(PageBase.ReturnScanDevicePage().esnIemeidTextbox);
    PageBase.ReturnScanDevicePage().esnIemeidTextbox.click();
    PageBase.ReturnScanDevicePage().esnIemeidTextbox.clear();
    PageBase.ReturnScanDevicePage().esnIemeidTextbox.sendKeys(dependantValues.ESN_IMEI1);
    PageBase.ReturnOrExchangeVerificationPage().continueEXCHANGE.click();

    SelectPreConditions();
    Reporter.log("<br>Pre Conditions Set for First Device");
    PageBase.ReturnOrExchangeVerificationPage().continuePRECONDITION.click();
    PageBase.ReturnOrExchangeVerificationPage().proceedEXCHANGE.click();
    PageBase.ReturnOrExchangeVerificationPage().exchangeDEVICE.click();

    Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().financingOptIn,
            SelectDropMethod.SELECTBYINDEX, "2");
    Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().exchangeReasons,
            SelectDropMethod.SELECTBYINDEX, "1");
    WebElement newESNBox = driver.findElement(By.id("addDeviceId"));
    newESNBox.click();
    newESNBox.clear();
    newESNBox.sendKeys(newIMEI1);
    PageBase.ReturnOrExchangeVerificationPage().submitFormButton.click();
    Thread.sleep(2000);
    Utilities.waitForElementVisible(PageBase.ReturnOrExchangeVerificationPage().exchangeReasons);
    Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().exchangeReasons,
            SelectDropMethod.SELECTBYINDEX, "1");

    Utilities.waitForElementVisible(PageBase.ReturnOrExchangeVerificationPage().returnAnotherDevice);
    PageBase.ReturnOrExchangeVerificationPage().returnAnotherDevice.click();

    Utilities.waitForElementVisible(PageBase.ReturnScanDevicePage().esnIemeidTextbox);
    PageBase.ReturnScanDevicePage().esnIemeidTextbox.click();
    PageBase.ReturnScanDevicePage().esnIemeidTextbox.clear();
    PageBase.ReturnScanDevicePage().esnIemeidTextbox.sendKeys(dependantValues.ESN_IMEI2);
    PageBase.ReturnOrExchangeVerificationPage().continueEXCHANGE.click();

    SelectPreConditions();
    Reporter.log("<br>Pre Conditions Set for Second Device");
    PageBase.ReturnOrExchangeVerificationPage().continuePRECONDITION.click();
    PageBase.ReturnOrExchangeVerificationPage().proceedEXCHANGE.click();
    PageBase.ReturnOrExchangeVerificationPage().exchangeDEVICE.click();
    Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().financingOptIn,
            SelectDropMethod.SELECTBYINDEX, "2");

    Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().exchangeReasons,
            SelectDropMethod.SELECTBYINDEX, "1");
    newESNBox = driver.findElement(By.id("addDeviceId"));
    newESNBox.click();
    newESNBox.clear();
    newESNBox.sendKeys(newIMEI2);

    PageBase.ReturnOrExchangeVerificationPage().submitFormButton.click();
    Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().exchangeReasons,
            SelectDropMethod.SELECTBYINDEX, "1");
    PageBase.ReturnOrExchangeVerificationPage().continueEXCHANGE.click();
    PageBase.VerizonSelectPlanFeaturesPage().continueSPFButton.click();//driver.findElement(By.id("featureSubmit")).click();
    Thread.sleep(1000);

    Utilities.ScrollToElement(PageBase.ReturnOrExchangeVerificationPage().firstDeviceNoInsurance);
    Thread.sleep(500);

    PageBase.ReturnOrExchangeVerificationPage().firstDeviceNoInsurance.click();
    PageBase.ReturnOrExchangeVerificationPage().firstDeviceNoInsurance.click();
    Thread.sleep(500);

    PageBase.ReturnOrExchangeVerificationPage().secondDeviceNoInsurance.click();
    PageBase.ReturnOrExchangeVerificationPage().secondDeviceNoInsurance.click();

    driver.findElement(By.xpath(".//*[@id='guestReview']/div/div/label/span")).click();
    PageBase.CommonControls().continueButton.click();

    Utilities.waitForElementVisible(PageBase.CommonControls().continueCommonButton);
    Utilities.ScrollToElement(PageBase.CommonControls().continueCommonButton);

    if (BrowserSettings.readConfig("Activation") == "true") {
        PageBase.CommonControls().continueCommonButton.click();

        if (driver.getCurrentUrl().contains("payment")) {
            PageBase.PaymentRequiredPage().populatingCardDetailsPaymentRequired(CardType.VISA);
            Utilities.ClickElement(PageBase.PaymentRequiredPage().sameAddressTab);
            Utilities.ClickElement(PageBase.PaymentRequiredPage().continuePRButton);
        }

        ChildOrderId = PageBase.PrintMobileScanSheetPage().orderNumberValuePMSSText.getText();
        Reporter.log("Child Order Created!!!  <br> <p>" + ChildOrderId);
        PageBase.ReturnOrExchangeVerificationPage().continueExchangeMSSPage.click();
        PageBase.ReturnOrExchangeVerificationPage().continueExchangeMSSPage.click();
        Utilities.implicitWaitSleep(1000);
        PageBase.PrintMobileScanSheetPage().continueFirstMSSButton.click();
        PageBase.PrintMobileScanSheetPage().continueFirstMSSButton.click();

        PageBase.PaymentVerificationPage().textboxTargetReceiptID.sendKeys(receiptId);
        PageBase.PaymentVerificationPage().submitButton.click();
        Reporter.log("Re-check Receipt ID - Successful <br> <p>");

        Utilities.waitForElementVisible(PageBase.DeviceVerificationaandActivation().deviceIMEITextbox);
        PageBase.DeviceVerificationaandActivation().deviceIMEITextbox.sendKeys(newIMEI1);
        PageBase.DeviceVerificationaandActivation().submitDVAButton.click();
        driver.findElement(By.id(PageBase.DeviceVerificationaandActivation().simTypeM + newIMEI1)).click();
        driver.findElement(By.id(PageBase.DeviceVerificationaandActivation().simTypeM + newIMEI1))
                .sendKeys(simType1);
        Utilities.ScrollToElement(PageBase.DeviceVerificationaandActivation().deviceIMEITextbox);

        PageBase.DeviceVerificationaandActivation().deviceIMEITextbox.sendKeys(newIMEI2);
        PageBase.DeviceVerificationaandActivation().submitDVAButton.click();
        driver.findElement(By.id(PageBase.DeviceVerificationaandActivation().simTypeM + newIMEI2)).click();
        driver.findElement(By.id(PageBase.DeviceVerificationaandActivation().simTypeM + newIMEI2))
                .sendKeys(simType2);
        PageBase.CommonControls().continueButtonDVA.click();
        Thread.sleep(30000);

        Utilities.waitForElementVisible(
                driver.findElement(By.xpath(".//*[@id='retailPage']/section/form/span/div/button")));
        String SupportCenterMessage = driver.findElement(By.xpath(".//*[@id='retailPage']/section/p"))
                .getText();
        Reporter.log(" <br> <p> Support Center Message: " + SupportCenterMessage + " <br> <p>");
        String toCompare = Constants.SUPPORT_PAGE_MESSAGE + "#" + ChildOrderId + " when calling.";
        Reporter.log(toCompare + " <br> <p>");

        //Assert.assertTrue(SupportCenterMessage.contains(toCompare));
        ShipAdminBaseClass.launchShipAdminInNewTab();
        Reporter.log("Navigating to Parent Order: " + dependantValues.ORDER_ID + " <br> <p>");
        PageBase.OrderSummaryPage().goToOrderSummaryPage(dependantValues.ORDER_ID);
        String eventLogTableContent = PageBase.OrderSummaryPage().checkForErrorAndLog(dependantValues.ORDER_ID);
        String parentOrderstatus = PageBase.OrderSummaryPage().getOrderStatus();
        Assert.assertEquals(parentOrderstatus, Constants.SHIPPED);
        Assert.assertEquals(PageBase.OrderSummaryPage().getChildOrderId(), ChildOrderId);
        Assert.assertTrue(eventLogTableContent.contains(ChildOrderId));

        PageBase.OrderSummaryPage().rOCHomeLink.click();
        Reporter.log("Navigating to Child Order: " + ChildOrderId + " <br> <p>");
        PageBase.OrderSummaryPage().goToOrderSummaryPage(ChildOrderId);
        eventLogTableContent = PageBase.OrderSummaryPage().checkForErrorAndLog(ChildOrderId);
        Assert.assertTrue(eventLogTableContent
                .contains("Old OrdId# " + dependantValues.ORDER_ID + ", Exchange order created"));
        String ChildOrderstatus = PageBase.OrderSummaryPage().getOrderStatus();
        Assert.assertTrue(ChildOrderstatus.contains("In-Store Activation"),
                "Checking for In-store activation String failed");
        Assert.assertEquals(PageBase.ReturnOrExchangeVerificationPage().parentOrderNumber.getText(),
                dependantValues.ORDER_ID,
                "Parent Order on Child Order is not the correct one. Check! <br> <p>");

        eventLogTableContent = PageBase.OrderSummaryPage().checkForErrorAndLog(ChildOrderId);
        PageBase.InventoryManagementPage().launchInventoryInNewTab();
        PageBase.InventoryManagementPage().verifyDeviceStatus(dependantValues.ESN_IMEI1,
                dependantValues.ESN_IMEI2, Constants.RETURN_TO_INVENTORY);
    }
    //DBError Verification
    DBError.navigateDBErrorPage();
    Assert.assertTrue(PageBase.AdminPage().isDBErrorFound(initialCount));
}

From source file:com.consensus.qa.verizon.tests.ExchangeTests.java

private void poaCompleteFlowQA66(String iMEINumber1, boolean stopActivation, String testtype)
        throws AWTException, IOException, InterruptedException {
    String receiptId = "132710003008663237";
    PageBase.LoginPageRetail().poaLogin(Utilities.getCredentials("tuserUN"),
            Utilities.getCredentials("tuserPwd"), Utilities.getCredentials("storeId2766"));

    PageBase.HomePageRetail().newGuestButton.click();
    PageBase.HomePageRetail().guestLookupTab.click();
    PageBase.CustomerLookupPage().receiptIdTextbox.sendKeys(receiptId);

    List<WebElement> SubmitButtons = driver.findElements(By.xpath(ControlLocators.SUBMIT_RECEIPTID));
    for (WebElement visibleSubmitButton : SubmitButtons) {
        if (visibleSubmitButton.isDisplayed()) {
            visibleSubmitButton.click();
            break;
        }/* w w  w.  j  av a2  s  .c  o  m*/
    }
    /*Utilities.waitForElementVisible(PageBase.OrderHistory().completedLink);
       PageBase.OrderHistory().completedLink.click();*/
    PageBase.GuestVerificationPage().populateGuestVerificationDetails(GuestVerificationPage.IdType.STATEID,
            "CA", "579468249", "Frank", "Consumer Two");
    PageBase.ReturnScanDevicePage().esnIemeidTextbox.click();
    PageBase.ReturnScanDevicePage().esnIemeidTextbox.clear();
    PageBase.ReturnScanDevicePage().esnIemeidTextbox.sendKeys(iMEINumber1);
    PageBase.ReturnOrExchangeVerificationPage().continueEXCHANGE.click();

    SelectPreConditions();

    PageBase.ReturnOrExchangeVerificationPage().continuePRECONDITION.click();
    PageBase.ReturnOrExchangeVerificationPage().proceedEXCHANGE.click();
    PageBase.ReturnOrExchangeVerificationPage().exchangeDEVICE.click();

    Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().financingOptIn,
            SelectDropMethod.SELECTBYINDEX, "2");
    Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().exchangeReasons,
            SelectDropMethod.SELECTBYINDEX, "1");
    Utilities.waitForElementVisible(PageBase.ReturnOrExchangeVerificationPage().returnDeviceTextBox);
    PageBase.ReturnOrExchangeVerificationPage().returnDeviceTextBox.click();
    PageBase.ReturnOrExchangeVerificationPage().returnDeviceTextBox.clear();
    PageBase.ReturnOrExchangeVerificationPage().returnDeviceTextBox.sendKeys("99000342701028");
    PageBase.ReturnOrExchangeVerificationPage().submitFormButton.click();
    Thread.sleep(1000);
    Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().exchangeReasons,
            SelectDropMethod.SELECTBYINDEX, "1");
    PageBase.ReturnOrExchangeVerificationPage().continueEXCHANGE.click();

    // Selecting plan feature.
    Utilities.ClickElement(PageBase.VerizonSelectPlanFeaturesPage().continueSPFButton);

    // Selecting NO Insurance.
    PageBase.SelectProtectionPlanInsurancePage().selectNoInsurance();
    Thread.sleep(500);

    // Order Review and Confirm Page
    PageBase.CommonControls().continueCommonButton.click();

    if (driver.getCurrentUrl().contains("payment")) {
        PageBase.PaymentRequiredPage().populatingCardDetailsPaymentRequired(CardType.VISA); //ToDo: Need to read from data sheet.
        Utilities.ClickElement(PageBase.PaymentRequiredPage().sameAddressTab);
        Utilities.ClickElement(PageBase.PaymentRequiredPage().continuePRButton);
    }

    ChildOrderId = PageBase.PrintMobileScanSheetPage().orderNumberValuePMSSText.getText();
    PageBase.PrintMobileScanSheetPage().continueFirstMSSButton.click();

    // Payment Verification page.
    PageBase.PaymentVerificationPage().paymentVerification("230440567552718374");

    // Device Verification and Activation page.

    Thread.sleep(30000);

    Utilities.waitForElementVisible(
            driver.findElement(By.xpath(".//*[@id='retailPage']/section/form/span/div/button")));
    String SupportCenterMessage = driver.findElement(By.xpath(".//*[@id='retailPage']/section/p")).getText();
    Reporter.log(" <br> <p> Support Center Message: " + SupportCenterMessage + " <br> <p>");
    String toCompare = Constants.SUPPORT_PAGE_MESSAGE + "#" + ChildOrderId + " when calling.";
    Reporter.log(toCompare + " <br> <p>");
    //         Assert.assertTrue(SupportCenterMessage.contains(toCompare));
}

From source file:com.consensus.qa.verizon.tests.ReturnTests.java

private String poaCompleteFlow_QA70(DependantTestCaseInputs dependantValues) throws IOException {
    //Login to retail page.
    PageBase.LoginPageRetail().poaLogin(Utilities.getCredentials("tuserUN"),
            Utilities.getCredentials("tuserPwd"), Utilities.getCredentials("storeId0003"));

    PageBase.HomePageRetail().guestLookupTab.click();

    PageBase.CustomerLookupPage().receiptIdTextbox.sendKeys(dependantValues.RECEIPT_ID);
    Reporter.log(dependantValues.RECEIPT_ID);

    java.util.List<WebElement> SubmitButtons = driver.findElements(By.xpath(ControlLocators.SUBMIT_RECEIPTID));
    for (WebElement visibleSubmitButton : SubmitButtons) {
        if (visibleSubmitButton.isDisplayed()) {
            visibleSubmitButton.click();
            break;
        }/*  ww w.j  a v  a  2 s.  co  m*/
    }

    PageBase.CarrierCreditCheckPage().firstNameTextBox.sendKeys(dependantValues.FIRST_NAME);
    PageBase.CarrierCreditCheckPage().lastNameTextBox.sendKeys(dependantValues.LAST_NAME);
    Reporter.log("<br>First Name: " + dependantValues.FIRST_NAME);
    Reporter.log("  Last Name: " + dependantValues.LAST_NAME + "; ");
    ExchangeTests.SelectLicense(dependantValues.ID_TYPE.toString(),
            PageBase.ReturnOrExchangeVerificationPage().idTypeDropdown);
    Reporter.log("State: " + dependantValues.STATE + "; ");
    Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().stateDropdown,
            Utilities.SelectDropMethod.SELECTBYTEXT, dependantValues.STATE);
    Reporter.log("ID Type: " + dependantValues.ID_TYPE + "; ");
    PageBase.ReturnOrExchangeVerificationPage().idNumberTextbox.sendKeys(dependantValues.ID_NUMBER);
    Reporter.log("ID Number: " + dependantValues.ID_NUMBER + ".");
    PageBase.CommonControls().continueCommonButton.click();

    Utilities.waitForElementVisible(PageBase.ReturnScanDevicePage().esnIemeidTextbox);
    PageBase.ReturnScanDevicePage().esnIemeidTextbox.click();
    PageBase.ReturnScanDevicePage().esnIemeidTextbox.clear();
    PageBase.ReturnScanDevicePage().esnIemeidTextbox.sendKeys(dependantValues.ESN_IMEI1);
    PageBase.ReturnOrExchangeVerificationPage().continueEXCHANGE.click();

    PageBase.ReturnOrExhangePreConditions().SelectPreconditions();
    PageBase.ReturnOrExhangePreConditions().continueREVButton.click();
    PageBase.ReturnOrExchangeVerificationPage().proceedEXCHANGE.click();
    PageBase.ReturnOrExchangeVerificationPage().returnDEVICE.click();
    Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().returnReasons,
            SelectDropMethod.SELECTBYINDEX, "1");
    PageBase.CustomerLookupPage().continueButton.click();

    if (driver.getCurrentUrl().contains("passwordcapture")) {
        PageBase.VerizonAccountPassword().password.sendKeys("Hello");
        PageBase.VerizonAccountPassword().continueButton.click();
    } else if (driver.getCurrentUrl().contains("printticket")) {
        PageBase.PrintMobileScanSheetPage().continueFirstMSSButton.click();
    }
    Assert.assertTrue(driver.findElement(By.xpath("//h2[contains(text(), 'Support Center')]")).isDisplayed());

    // Commenting below Assertions as this doesn't show up in Carrier Responder

    if (driver.getCurrentUrl().contains("passwordcapture")) {
        PageBase.VerizonAccountPassword().password.sendKeys("Hello");
        PageBase.VerizonAccountPassword().continueButton.click();
    }
    //*PageBase.CommonControls().continueButton.click();

    // RMSS Assertions - Todo from Parent Order
    /*Assert.assertEquals(PageBase.PrintMobileScanSheetPage().phonePriceValuePMSSText.getText(),
       "");
       Assert.assertEquals(PageBase.PrintMobileScanSheetPage().phoneTaxValuePMSSText.getText(),
       "");
       PageBase.PrintMobileScanSheetPage().barcodePMSSImage.isDisplayed();
            
       PageBase.PrintMobileScanSheetPage().continueFirstMSSButton.click();
            
            
       Assert.assertTrue(PageBase.ReturnConfirmation().returnConfirmation.isDisplayed());
       Assert.assertTrue(PageBase.ReturnConfirmation().successfullyReturnedString.isDisplayed());
       Assert.assertTrue(PageBase.ReturnConfirmation().linePhonenoString.isDisplayed());
       Assert.assertTrue(PageBase.ReturnConfirmation().returnStep1Text.isDisplayed());
       Assert.assertTrue(PageBase.ReturnConfirmation().returnStep2Text.isDisplayed());
       Assert.assertTrue(PageBase.ReturnConfirmation().printInstruction.isDisplayed());
       Assert.assertTrue(PageBase.ReturnConfirmation().returnHome.isDisplayed());*/
    return orderId;
}

From source file:com.consensus.test.verizon.tests.ExchangeTests.java

@Test(groups = { "verizon" })
@Parameters("test-type")
public void QA_51_VerizonNonEdgeExchangeLikeForUnlike(@Optional String testtype)
        throws IOException, InterruptedException, AWTException {

    DependantTestCaseInputs dependantValues = Utilities.ReadFromCSV("QA_50");
    if (dependantValues.TC_ID == "" || dependantValues.ORDER_ID == "") {
        AddNewLineTests addNewLine = new AddNewLineTests();
        addNewLine.QA50_VerizonNonEdgeWithNumberPortCCInCA(BrowserSettings.readConfig("test-type"));
        dependantValues = Utilities.ReadFromCSV("QA_50");
        if (dependantValues.TC_ID == "" || dependantValues.ORDER_ID == "") {
            Reporter.log("<br> Data is not available from QA_50");
            Assert.fail("Data is not available from QA_50");
        }/*  w  w  w .  j a  v a2  s  .  c  o m*/
    }
    String ChildOrderId = null;
    String newIMEI1 = PageBase.CSVOperations()
            .GetIMEIOrSimNumberOrReceiptId(FileName.SamsungGalaxyS4_16GBWhite);
    String newIMEI2 = PageBase.CSVOperations()
            .GetIMEIOrSimNumberOrReceiptId(FileName.SamsungGalaxyS4_16GBWhite);
    String simType1 = PageBase.CSVOperations().GetIMEIOrSimNumberOrReceiptId(FileName.Sim_3FF);
    String simType2 = PageBase.CSVOperations().GetIMEIOrSimNumberOrReceiptId(FileName.Sim_3FF);
    String testType = BrowserSettings.readConfig("test-type");
    Reporter.log("QA_51_VerizonNonEdgeLikeForUnlike Starts.");
    Reporter.log("<br>Launching Browser");
    Log.startTestCase("QA_51_VerizonNonEdgeExchange_LikeForUnlike");

    if (testType.equals("internal")) {
        AdminBaseClass adminBaseClass = new AdminBaseClass();
        adminBaseClass.launchAdminInNewTab();
        PageBase.AdminPage().navigateToSimulator();

        if (readConfig("internalTestType").toLowerCase().equals("carrierresponder")) {
            Reporter.log("Using Carrier Responder  <br> <p>", true);
            PageBase.AdminPage().selectWebAPIResponse("Verizon", "CarrierResponder");
            PageBase.AdminPage().selectAPIConfig("Verizon");
            Utilities.waitForElementVisible(PageBase.CarrierResponseXMLPage().verizonCarrierTab);
            PageBase.CarrierResponseXMLPage().verizonCarrierTab.click();
            Utilities.waitForElementVisible(PageBase.CarrierResponseXMLPage().versionsDropdown);
            PageBase.CarrierResponseXMLPage().selectOptions("current", "returnOrExchangeDevice",
                    "default_exchange.xml");
            Reporter.log("<br>XML Used: returnOrExchangeDevice - default_exchange.xml", true);
            Utilities.waitForElementVisible(PageBase.CarrierResponseXMLPage().saveResponseButton);
            PageBase.CarrierResponseXMLPage().saveResponseButton.click();
            Reporter.log("<br>Carrier Responder Changes Done!!!", true);
        }
    } else //External
    {
        AdminBaseClass adminBaseClass = new AdminBaseClass();
        adminBaseClass.launchAdminInNewTab();

        PageBase.AdminPage().navigateToSimulator();
        PageBase.AdminPage().selectWebAPIResponse("Verizon", "External");
        Reporter.log("<br><U>Pointing to External Server</U>");
    }

    String receiptId = dependantValues.RECEIPT_ID;

    Utilities.switchPreviousTab();
    //Calling DBError utility to  find initial count or error in log files.
    DBError.navigateDBErrorPage();
    int initialCount = PageBase.AdminPage().totalErrorCount();

    Utilities.switchPreviousTab();
    PageBase.LoginPageRetail().poaLogin(Utilities.getCredentials("tuserUN"),
            Utilities.getCredentials("tuserPwd"), Utilities.getCredentials("storeId0003"));
    Reporter.log("Returning the device using Receipt ID: ");
    PageBase.HomePageRetail().newGuestButton.click();
    PageBase.HomePageRetail().guestLookupTab.click();
    PageBase.CustomerLookupPage().receiptIdTextbox.sendKeys(receiptId);
    Reporter.log(receiptId);

    List<WebElement> SubmitButtons = driver.findElements(By.xpath(ControlLocators.SUBMIT_RECEIPTID));
    for (WebElement visibleSubmitButton : SubmitButtons) {
        if (visibleSubmitButton.isDisplayed()) {
            visibleSubmitButton.click();
            break;
        }
    }

    PageBase.CarrierCreditCheckPage().firstNameTextBox.sendKeys(dependantValues.FIRST_NAME);
    PageBase.CarrierCreditCheckPage().lastNameTextBox.sendKeys(dependantValues.LAST_NAME);
    Reporter.log("<br>First Name: " + dependantValues.FIRST_NAME);
    Reporter.log("  Last Name: " + dependantValues.LAST_NAME + "; ");
    SelectLicense(dependantValues.ID_TYPE, PageBase.ReturnOrExchangeVerificationPage().idTypeDropdown);
    Reporter.log("State: " + dependantValues.STATE + "; ");
    Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().stateDropdown,
            SelectDropMethod.SELECTBYTEXT, dependantValues.STATE);
    Reporter.log("ID Type: " + dependantValues.ID_TYPE + "; ");
    PageBase.ReturnOrExchangeVerificationPage().idNumberTextbox.sendKeys(dependantValues.ID_NUMBER);
    Reporter.log("ID Number: " + dependantValues.ID_NUMBER + ".");
    PageBase.CommonControls().continueCommonButton.click();
    Utilities.waitForElementVisible(PageBase.ReturnScanDevicePage().esnIemeidTextbox);
    PageBase.ReturnScanDevicePage().esnIemeidTextbox.click();
    PageBase.ReturnScanDevicePage().esnIemeidTextbox.clear();
    PageBase.ReturnScanDevicePage().esnIemeidTextbox.sendKeys(dependantValues.ESN_IMEI1);
    PageBase.ReturnOrExchangeVerificationPage().continueEXCHANGE.click();

    SelectPreConditions();
    Reporter.log("<br>Pre Conditions Set for First Device");
    PageBase.ReturnOrExchangeVerificationPage().continuePRECONDITION.click();
    PageBase.ReturnOrExchangeVerificationPage().proceedEXCHANGE.click();
    PageBase.ReturnOrExchangeVerificationPage().exchangeDEVICE.click();

    Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().financingOptIn,
            SelectDropMethod.SELECTBYINDEX, "2");
    Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().exchangeReasons,
            SelectDropMethod.SELECTBYINDEX, "1");
    WebElement newESNBox = driver.findElement(By.id("addDeviceId"));
    newESNBox.click();
    newESNBox.clear();
    newESNBox.sendKeys(newIMEI1);
    PageBase.ReturnOrExchangeVerificationPage().submitFormButton.click();
    Thread.sleep(2000);
    Utilities.waitForElementVisible(PageBase.ReturnOrExchangeVerificationPage().exchangeReasons);
    Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().exchangeReasons,
            SelectDropMethod.SELECTBYINDEX, "1");

    Utilities.waitForElementVisible(PageBase.ReturnOrExchangeVerificationPage().returnAnotherDevice);
    PageBase.ReturnOrExchangeVerificationPage().returnAnotherDevice.click();

    Utilities.waitForElementVisible(PageBase.ReturnScanDevicePage().esnIemeidTextbox);
    PageBase.ReturnScanDevicePage().esnIemeidTextbox.click();
    PageBase.ReturnScanDevicePage().esnIemeidTextbox.clear();
    PageBase.ReturnScanDevicePage().esnIemeidTextbox.sendKeys(dependantValues.ESN_IMEI2);
    PageBase.ReturnOrExchangeVerificationPage().continueEXCHANGE.click();

    SelectPreConditions();
    Reporter.log("<br>Pre Conditions Set for Second Device");
    PageBase.ReturnOrExchangeVerificationPage().continuePRECONDITION.click();
    PageBase.ReturnOrExchangeVerificationPage().proceedEXCHANGE.click();
    PageBase.ReturnOrExchangeVerificationPage().exchangeDEVICE.click();
    Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().financingOptIn,
            SelectDropMethod.SELECTBYINDEX, "2");

    Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().exchangeReasons,
            SelectDropMethod.SELECTBYINDEX, "1");
    newESNBox = driver.findElement(By.id("addDeviceId"));
    newESNBox.click();
    newESNBox.clear();
    newESNBox.sendKeys(newIMEI2);

    PageBase.ReturnOrExchangeVerificationPage().submitFormButton.click();
    Utilities.dropdownSelect(PageBase.ReturnOrExchangeVerificationPage().exchangeReasons,
            SelectDropMethod.SELECTBYINDEX, "1");
    PageBase.ReturnOrExchangeVerificationPage().continueEXCHANGE.click();
    PageBase.VerizonSelectPlanFeaturesPage().continueSPFButton.click();//driver.findElement(By.id("featureSubmit")).click();
    Thread.sleep(1000);

    Utilities.ScrollToElement(PageBase.ReturnOrExchangeVerificationPage().firstDeviceNoInsurance);
    Thread.sleep(500);

    PageBase.ReturnOrExchangeVerificationPage().firstDeviceNoInsurance.click();
    PageBase.ReturnOrExchangeVerificationPage().firstDeviceNoInsurance.click();
    Thread.sleep(500);

    PageBase.ReturnOrExchangeVerificationPage().secondDeviceNoInsurance.click();
    PageBase.ReturnOrExchangeVerificationPage().secondDeviceNoInsurance.click();

    driver.findElement(By.xpath(".//*[@id='guestReview']/div/div/label/span")).click();
    PageBase.CommonControls().continueButton.click();

    Utilities.waitForElementVisible(PageBase.CommonControls().continueCommonButton);
    Utilities.ScrollToElement(PageBase.CommonControls().continueCommonButton);

    if (BrowserSettings.readConfig("Activation") == "true") {
        PageBase.CommonControls().continueCommonButton.click();

        if (driver.getCurrentUrl().contains("payment")) {
            PageBase.PaymentRequiredPage().populatingCardDetailsPaymentRequired(CardType.VISA);
            Utilities.ClickElement(PageBase.PaymentRequiredPage().sameAddressTab);
            Utilities.ClickElement(PageBase.PaymentRequiredPage().continuePRButton);
        }

        ChildOrderId = PageBase.PrintMobileScanSheetPage().orderNumberValuePMSSText.getText();
        Reporter.log("Child Order Created!!!  <br> <p>" + ChildOrderId);
        PageBase.ReturnOrExchangeVerificationPage().continueExchangeMSSPage.click();
        PageBase.ReturnOrExchangeVerificationPage().continueExchangeMSSPage.click();
        Utilities.implicitWaitSleep(1000);
        PageBase.PrintMobileScanSheetPage().continueFirstMSSButton.click();
        PageBase.PrintMobileScanSheetPage().continueFirstMSSButton.click();

        PageBase.PaymentVerificationPage().textboxTargetReceiptID.sendKeys(receiptId);
        PageBase.PaymentVerificationPage().submitButton.click();
        Reporter.log("Re-check Receipt ID - Successful <br> <p>");

        Utilities.waitForElementVisible(PageBase.DeviceVerificationaandActivation().deviceIMEITextbox);
        PageBase.DeviceVerificationaandActivation().deviceIMEITextbox.sendKeys(newIMEI1);
        PageBase.DeviceVerificationaandActivation().submitDVAButton.click();
        driver.findElement(By.id(PageBase.DeviceVerificationaandActivation().simTypeM + newIMEI1)).click();
        driver.findElement(By.id(PageBase.DeviceVerificationaandActivation().simTypeM + newIMEI1))
                .sendKeys(simType1);
        Utilities.ScrollToElement(PageBase.DeviceVerificationaandActivation().deviceIMEITextbox);

        PageBase.DeviceVerificationaandActivation().deviceIMEITextbox.sendKeys(newIMEI2);
        PageBase.DeviceVerificationaandActivation().submitDVAButton.click();
        driver.findElement(By.id(PageBase.DeviceVerificationaandActivation().simTypeM + newIMEI2)).click();
        driver.findElement(By.id(PageBase.DeviceVerificationaandActivation().simTypeM + newIMEI2))
                .sendKeys(simType2);
        PageBase.CommonControls().continueButtonDVA.click();
        Thread.sleep(30000);

        Utilities.waitForElementVisible(
                driver.findElement(By.xpath(".//*[@id='retailPage']/section/form/span/div/button")));
        String SupportCenterMessage = driver.findElement(By.xpath(".//*[@id='retailPage']/section/p"))
                .getText();
        Reporter.log(" <br> <p> Support Center Message: " + SupportCenterMessage + " <br> <p>");
        String toCompare = Constants.SUPPORT_PAGE_MESSAGE + "#" + ChildOrderId + " when calling.";
        Reporter.log(toCompare + " <br> <p>");

        //Assert.assertTrue(SupportCenterMessage.contains(toCompare));
        ShipAdminBaseClass.launchShipAdminInNewTab();
        Reporter.log("Navigating to Parent Order: " + dependantValues.ORDER_ID + " <br> <p>");
        PageBase.OrderSummaryPage().goToOrderSummaryPage(dependantValues.ORDER_ID);
        String eventLogTableContent = PageBase.OrderSummaryPage().checkForErrorAndLog(dependantValues.ORDER_ID);
        String parentOrderstatus = PageBase.OrderSummaryPage().getOrderStatus();
        Assert.assertEquals(parentOrderstatus, Constants.SHIPPED);
        Assert.assertEquals(PageBase.OrderSummaryPage().getChildOrderId(), ChildOrderId);
        Assert.assertTrue(eventLogTableContent.contains(ChildOrderId));

        PageBase.OrderSummaryPage().rOCHomeLink.click();
        Reporter.log("Navigating to Child Order: " + ChildOrderId + " <br> <p>");
        PageBase.OrderSummaryPage().goToOrderSummaryPage(ChildOrderId);
        eventLogTableContent = PageBase.OrderSummaryPage().checkForErrorAndLog(ChildOrderId);
        Assert.assertTrue(eventLogTableContent
                .contains("Old OrdId# " + dependantValues.ORDER_ID + ", Exchange order created"));
        String ChildOrderstatus = PageBase.OrderSummaryPage().getOrderStatus();
        Assert.assertTrue(ChildOrderstatus.contains("In-Store Activation"),
                "Checking for In-store activation String failed");
        Assert.assertEquals(PageBase.ReturnOrExchangeVerificationPage().parentOrderNumber.getText(),
                dependantValues.ORDER_ID,
                "Parent Order on Child Order is not the correct one. Check! <br> <p>");

        eventLogTableContent = PageBase.OrderSummaryPage().checkForErrorAndLog(ChildOrderId);
        PageBase.InventoryManagementPage().launchInventoryInNewTab();
        PageBase.InventoryManagementPage().verifyDeviceStatus(dependantValues.ESN_IMEI1,
                dependantValues.ESN_IMEI2, Constants.RETURN_TO_INVENTORY);
    }
    //DBError Verification
    DBError.navigateDBErrorPage();
    Assert.assertTrue(PageBase.AdminPage().isDBErrorFound(initialCount));
}

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

License:Apache License

@Override
protected void execute(WebElement webElement, SeleniumBrowser browser, TestContext context) {
    super.execute(webElement, browser, context);

    if (webElement.isSelected() && !checked) {
        webElement.click();
    } else if (checked && !webElement.isSelected()) {
        webElement.click();// w  w w  .  j  a v a  2  s  .c  om
    }
}

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

License:Apache License

@Override
protected void execute(WebElement webElement, SeleniumBrowser browser, TestContext context) {
    super.execute(webElement, browser, context);

    webElement.click();
}

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

License:Apache License

/**
 * Enable or disable a check button./*from   w w w .ja  va 2s.  co  m*/
 *
 * @param by
 * @param str "true" or "false".
 */
public void checkItem(By by, String str) {
    boolean value = Boolean.parseBoolean(str);
    WebElement element = findElement(by);
    if (element.isSelected() && !value) {
        element.click();
    } else if (value && !element.isSelected()) {
        element.click();
    }
}

From source file:com.continuuity.test.GenericTest.java

License:Apache License

public String switchToNewTab(WebElement elemForClick, String url) {
    String oldTab = globalDriver.getWindowHandle();
    elemForClick.click();
    driverWait(5);//w w  w  . ja v  a2 s.c o m
    ArrayList<String> newTab = new ArrayList<String>(globalDriver.getWindowHandles());
    newTab.remove(oldTab);
    // change focus to new tab
    globalDriver.switchTo().window(newTab.get(0));
    String newUrl = globalDriver.getCurrentUrl();
    globalDriver.close();
    // change focus back to old tab
    globalDriver.switchTo().window(oldTab);

    return newUrl;
}

From source file:com.continuuity.test.pagetest.CreateClustertemplateTest.java

License:Apache License

@Test
public void test_01_submitHadoopDistributed() throws Exception {
    globalDriver.get(Constants.CLUSTERTEMPLATE_CREATE_URI);
    ClusterTemplate clusterTemplate = EXAMPLE_READER.getClusterTemplate(Constants.CLUSTERTEMPLATE_PATH)
            .get("hadoop-distributed");
    WebElement inputName = globalDriver.findElement(By.cssSelector("#inputName"));
    inputName.sendKeys(clusterTemplate.getName());
    WebElement inputDescription = globalDriver.findElement(By.cssSelector("#inputDescription"));
    inputDescription.sendKeys(clusterTemplate.getDescription());

    List<WebElement> leaseDurationInputs = globalDriver
            .findElements(By.cssSelector("#lease-duration-table .number-input"));

    for (WebElement input : leaseDurationInputs) {
        input.sendKeys("0");
    }/*from   w  w  w  .  j  ava2  s. co m*/

    globalDriver.findElement(By.cssSelector("#general .next-tab-button")).click();
    Global.driverWait(1);

    Set<String> compatibleServices = clusterTemplate.getCompatibilities().getServices();
    Select serviceSelect = new Select(
            globalDriver.findElement(By.cssSelector("#compatibility .service-select")));
    WebElement addServiceBtn = globalDriver.findElement(By.cssSelector("#compatibility .add-service-btn"));
    for (String service : compatibleServices) {
        serviceSelect.selectByVisibleText(service);
        addServiceBtn.click();
    }

    Set<String> compatibleHardwaretypes = clusterTemplate.getCompatibilities().getHardwaretypes();
    Select hardwaretypeSelect = new Select(
            globalDriver.findElement(By.cssSelector("#compatibility .hardwaretype-select")));
    WebElement addHardwaretypeBtn = globalDriver
            .findElement(By.cssSelector("#compatibility .add-hardwaretype-btn"));
    for (String hardwaretype : compatibleHardwaretypes) {
        hardwaretypeSelect.selectByVisibleText(hardwaretype);
        addHardwaretypeBtn.click();
    }

    Set<String> compatibleImagetypes = clusterTemplate.getCompatibilities().getImagetypes();
    Select imagetypeSelect = new Select(
            globalDriver.findElement(By.cssSelector("#compatibility .imagetype-select")));
    WebElement addImagetypeBtn = globalDriver.findElement(By.cssSelector("#compatibility .add-imagetype-btn"));
    for (String imagetype : compatibleImagetypes) {
        imagetypeSelect.selectByVisibleText(imagetype);
        addImagetypeBtn.click();
    }

    globalDriver.findElement(By.cssSelector("#compatibility .next-tab-button")).click();
    Global.driverWait(1);

    new Select(globalDriver.findElement(By.cssSelector("#defaults .provider-select")))
            .selectByVisibleText(clusterTemplate.getClusterDefaults().getProvider());

    Select defaulthardwaretype = new Select(
            globalDriver.findElement(By.cssSelector("#defaults .hardwaretype-select")));
    Select defaultimagetype = new Select(
            globalDriver.findElement(By.cssSelector("#defaults .imagetype-select")));
    List<WebElement> defaultHardwareOptions = defaulthardwaretype.getOptions();
    List<WebElement> defaultImageOptions = defaultimagetype.getOptions();

    Set<String> defaultHardwareItems = Sets.newHashSet();
    for (WebElement item : defaultHardwareOptions) {
        if (item.getText().length() != 0) {
            defaultHardwareItems.add(item.getText());
        }

    }

    Set<String> defaultImageItems = Sets.newHashSet();
    for (WebElement item : defaultImageOptions) {
        if (item.getText().length() != 0) {
            defaultImageItems.add(item.getText());
        }
    }

    defaulthardwaretype.selectByVisibleText(clusterTemplate.getClusterDefaults().getHardwaretype());
    defaultimagetype.selectByVisibleText(clusterTemplate.getClusterDefaults().getImagetype());

    globalDriver.findElement(By.cssSelector("#inputDnsSuffix"))
            .sendKeys(clusterTemplate.getClusterDefaults().getDnsSuffix().toString());

    globalDriver.findElement(By.cssSelector("#inputConfig"))
            .sendKeys(clusterTemplate.getClusterDefaults().getConfig().toString());

    Set<String> defaultServices = clusterTemplate.getClusterDefaults().getServices();

    Select defaultServiceSelect = new Select(
            globalDriver.findElement(By.cssSelector("#defaults .service-select")));
    List<WebElement> defaultServiceSelectOptions = defaultServiceSelect.getOptions();

    Set<String> defaultServiceSelectItems = Sets.newHashSet();
    for (WebElement item : defaultServiceSelectOptions) {
        if (item.getText().length() != 0) {
            defaultServiceSelectItems.add(item.getText());
        }
    }

    assertEquals(compatibleHardwaretypes, defaultHardwareItems);
    assertEquals(compatibleImagetypes, defaultImageItems);
    assertEquals(defaultServices, defaultServiceSelectItems);

    WebElement addServicebtn = globalDriver.findElement(By.cssSelector("#defaults .add-service-btn"));
    for (String service : defaultServices) {
        defaultServiceSelect.selectByVisibleText(service);
        addServicebtn.click();
    }

    globalDriver.findElement(By.cssSelector("#defaults .next-tab-button")).click();

    Global.driverWait(1);
    globalDriver.findElement(By.cssSelector(".add-must-coexist-group")).click();
    Global.driverWait(1);

    Set<String> mustcoexistgroup1 = clusterTemplate.getConstraints().getLayoutConstraint()
            .getServicesThatMustCoexist().iterator().next();
    Select mustCoExistSelect = new Select(
            globalDriver.findElement(By.cssSelector("#must-coexist-modal .must-coexist-select")));
    addServiceBtn = globalDriver.findElement(By.cssSelector("#must-coexist-modal .add-service-btn"));
    for (WebElement close : globalDriver.findElements(By.cssSelector("#cant-coexist-modal .service-delete"))) {
        close.click();
    }

    for (String serviceEntry : mustcoexistgroup1) {
        mustCoExistSelect.selectByVisibleText(serviceEntry);
        addServiceBtn.click();
    }
    globalDriver.findElement(By.cssSelector("#must-coexist-modal .add-group-btn")).click();
    Global.driverWait(1);

    Set<Set<String>> cantcoexistgroups = clusterTemplate.getConstraints().getLayoutConstraint()
            .getServicesThatMustNotCoexist();
    for (Set<String> cantcoexistentry : cantcoexistgroups) {
        globalDriver.findElement(By.cssSelector(".add-cant-coexist-group")).click();
        Global.driverWait(1);
        for (WebElement close : globalDriver
                .findElements(By.cssSelector("#cant-coexist-modal .service-delete"))) {
            close.click();
        }
        Select cantcoexistSelect = new Select(
                globalDriver.findElement(By.cssSelector("#cant-coexist-modal .cant-coexist-select")));
        addServiceBtn = globalDriver.findElement(By.cssSelector("#cant-coexist-modal .add-service-btn"));
        for (String serviceEntry : cantcoexistentry) {
            cantcoexistSelect.selectByVisibleText(serviceEntry);
            addServiceBtn.click();
        }
        globalDriver.findElement(By.cssSelector("#cant-coexist-modal .add-group-btn")).click();
        Global.driverWait(1);
    }

    Map<String, ServiceConstraint> serviceConstraints = clusterTemplate.getConstraints()
            .getServiceConstraints();
    Select serviceNameSelect = new Select(
            globalDriver.findElement(By.cssSelector("#service-constraint-modal .service-select")));
    Select serviceHardwaretypeSelect = new Select(
            globalDriver.findElement(By.cssSelector("#service-constraint-modal .hardwaretype-select")));
    addHardwaretypeBtn = globalDriver
            .findElement(By.cssSelector("#service-constraint-modal .add-hardwaretype-btn"));
    Select serviceImagetypeSelect = new Select(
            globalDriver.findElement(By.cssSelector("#service-constraint-modal .imagetype-select")));
    addImagetypeBtn = globalDriver.findElement(By.cssSelector("#service-constraint-modal .add-imagetype-btn"));
    WebElement minConstraint = globalDriver
            .findElement(By.cssSelector("#service-constraint-modal .constraint-min"));
    WebElement maxConstraint = globalDriver
            .findElement(By.cssSelector("#service-constraint-modal .constraint-max"));
    WebElement addServiceConstraintBtn = globalDriver
            .findElement(By.cssSelector(".add-service-constraint-btn"));
    WebElement addServiceConstraintModal = globalDriver
            .findElement(By.cssSelector(".add-serviceconstraint-modal"));
    for (Map.Entry<String, ServiceConstraint> entry : serviceConstraints.entrySet()) {
        addServiceConstraintModal.click();
        Global.driverWait(1);
        minConstraint.clear();
        maxConstraint.clear();
        String key = entry.getKey();
        ServiceConstraint constraint = entry.getValue();
        serviceNameSelect.selectByVisibleText(key);

        if (constraint.getRequiredHardwareTypes() != null) {
            for (String hardwaretype : constraint.getRequiredHardwareTypes()) {
                serviceHardwaretypeSelect.selectByVisibleText(hardwaretype);
                addHardwaretypeBtn.click();
            }
        }

        if (constraint.getRequiredImageTypes() != null) {
            for (String imagetype : constraint.getRequiredImageTypes()) {
                serviceImagetypeSelect.selectByVisibleText(imagetype);
                addImagetypeBtn.click();
            }
        }

        minConstraint.sendKeys(String.valueOf(constraint.getMinCount()));
        maxConstraint.sendKeys(String.valueOf(constraint.getMaxCount()));
        addServiceConstraintBtn.click();
        Global.driverWait(1);
    }
    globalDriver.findElement(By.cssSelector("#create-clustertemplate-form")).submit();
    Global.driverWait(1);
    assertEquals(Constants.CLUSTERTEMPLATES_URL, globalDriver.getCurrentUrl());
}

From source file:com.continuuity.test.pagetest.CreateHardwaretypeTest.java

License:Apache License

@Test
public void test_01_submitSmall() throws Exception {
    globalDriver.get(Constants.HARDWARETYPE_CREATE_URI);
    HardwareType hardwareType = EXAMPLE_READER.getHardwareTypes(Constants.HARDWARETYPES_PATH).get("small");

    WebElement inputName = globalDriver.findElement(By.cssSelector("#inputName"));
    inputName.sendKeys(hardwareType.getName());

    WebElement inputDescription = globalDriver.findElement(By.cssSelector("#inputDescription"));
    inputDescription.sendKeys(hardwareType.getDescription());

    WebElement addProvider = globalDriver.findElement(By.cssSelector("#add-provider"));
    addProvider.click();
    addProvider.click();//from w w  w.j  av a2s .c  o m

    List<WebElement> providerEntries = globalDriver.findElements(By.cssSelector(".provider-entry"));

    providerEntries.get(0).findElement(By.cssSelector("select")).sendKeys("joyent");
    providerEntries.get(0).findElement(By.cssSelector("input"))
            .sendKeys(hardwareType.getProviderMap().get("joyent").get("flavor"));

    providerEntries.get(1).findElement(By.cssSelector("select")).sendKeys("rackspace");
    providerEntries.get(1).findElement(By.cssSelector("input"))
            .sendKeys(hardwareType.getProviderMap().get("rackspace").get("flavor"));

    providerEntries.get(2).findElement(By.cssSelector("select")).sendKeys("openstack");
    providerEntries.get(2).findElement(By.cssSelector("input"))
            .sendKeys(hardwareType.getProviderMap().get("openstack").get("flavor"));

    globalDriver.findElement(By.cssSelector("#create-hardwaretype-form")).submit();
    Global.driverWait(1);
    assertEquals(Constants.HARDWARETYPES_URL, globalDriver.getCurrentUrl());
}