Example usage for org.openqa.selenium WebElement clear

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

Introduction

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

Prototype

void clear();

Source Link

Document

If this element is a form entry element, this will reset its value.

Usage

From source file:com.comcast.dawg.house.EditDeviceRow.java

License:Apache License

/**
 * Changes the value in the <textarea> element
 * @param newValue/*  w w w  .j a  va  2 s. co m*/
 */
public void changeValue(String newValue) {
    WebElement valueInput = valueInput();
    valueInput.clear();
    valueInput.sendKeys(newValue);
}

From source file:com.comcast.dawg.house.pages.IndexPage.java

License:Apache License

/**
 * Type the tag name on text input element field.
 *
 * @param  tagName  Name of tag to be entered on text input field.
 *///from  w  w w.j  a  v  a2  s.  c  o  m
public void typeOnBulkTagTextElement(String tagName) {
    WebElement elementTagText = getBulkTagTextElement();

    // Clearing the text area before entering.
    elementTagText.clear();
    elementTagText.sendKeys(tagName);
}

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");
        }/* w  w  w  . j  a va2  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");

    //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.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.jav  a2 s .  com*/
    }
    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.SetInputAction.java

License:Apache License

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

    String tagName = webElement.getTagName();
    if (null == tagName || !"select".equals(tagName.toLowerCase())) {
        webElement.clear();
        webElement.sendKeys(value);//  w  ww. jav  a  2s .c  om
    } else {
        new Select(webElement).selectByValue(value);
    }
}

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

License:Apache License

/**
 * Set a value on a single input element by its id after clearing it.
 *
 * @param by/*from  w  w w .j a v a  2  s  .com*/
 * @param value Value to set.
 */
public void setInput(By by, String value) {
    WebElement element = findElement(by);
    String tagName = element.getTagName();
    if (null == tagName || !"select".equals(tagName.toLowerCase())) {
        element.clear();
        element.sendKeys(value);
    } else {
        new Select(element).selectByValue(value);
    }
}

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  ww  . java 2  s.com*/

    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.daarons.transfer.UploadTask.java

License:Apache License

private void inputMessage(Message message) {
    WebElement toInput = longWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(
            "body > div > div > div.transfer.transfer--half-panel > div > div.scrollable.transfer__contents > div.scrollable__content > div.uploader__fields > div.uploader__autosuggest > input")));
    toInput.clear();
    toInput.sendKeys(message.getTo());/*from  w ww .  ja v  a2s .  co  m*/
    WebElement fromInput = longWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(
            "body > div > div > div.transfer.transfer--half-panel > div > div.scrollable.transfer__contents > div.scrollable__content > div.uploader__fields > input")));
    fromInput.clear();
    fromInput.sendKeys(message.getFrom());
    WebElement messageInput = longWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(
            "body > div > div > div.transfer.transfer--half-panel > div > div.scrollable.transfer__contents > div.scrollable__content > div.uploader__fields > div.uploader__message > textarea")));
    messageInput.clear();
    messageInput.sendKeys(message.getMessage());
}

From source file:com.day.cq.social.comments.CloudServiceMTIT.java

@Test
public void testConfigureMSConnectorOnPublish() throws InterruptedException {
    browseTo(getURL(cloudServiceMTPage), true);
    WebElement msConnector = driver.findElement(By.cssSelector("div.product.msft-translation a"));
    msConnector.click();/*from w  w w  . j  av a  2  s.c o m*/
    assertTrue("Unable to find configuration button",
            isElementPresent(By.cssSelector("#msft-translation-more")));
    assertTrue("Unable to find default configuration", isElementPresent(
            By.linkText("Microsoft Translator Default Configuration (Microsoft Translation Configuration)")));
    assertTrue("Unable to find trail configuration", isElementPresent(
            By.linkText("Microsoft Translator Trial License (Microsoft Translation Configuration)")));

    WebElement defaultConfig = driver.findElement(
            By.linkText("Microsoft Translator Default Configuration (Microsoft Translation Configuration)"));
    defaultConfig.click();
    WebElement edit = driver.findElement(By.id("cq-gen14"));
    edit.click();

    WebElement label = driver.findElement(By.cssSelector("#x-form-el-ext-comp-1021 input"));
    WebElement attribution = driver.findElement(By.cssSelector("#x-form-el-ext-comp-1022 input"));
    WebElement workspaceID = driver.findElement(By.cssSelector("#x-form-el-ext-comp-1023 input"));
    WebElement clientID = driver.findElement(By.cssSelector("#x-form-el-ext-comp-1024 input"));
    WebElement clientSecret = driver.findElement(By.cssSelector("#x-form-el-ext-comp-1025 input"));
    label.clear();
    label.sendKeys("test");
    attribution.clear();
    attribution.sendKeys("test");
    workspaceID.clear();
    workspaceID.sendKeys("test");
    clientID.clear();
    clientID.sendKeys("AdobeAEMTrial");
    clientSecret.clear();
    clientSecret.sendKeys("AEMTrialAccount9468uTp");
    WebElement verifyButton = driver.findElement(By.id("cq-gen65"));
    verifyButton.click();
    WebElement okButton = driver.findElement(By.id("cq-gen90"));
    okButton.click();
    okButton = driver.findElement(By.id("cq-gen44"));
    okButton.click();

    Thread.sleep(2000);
    List<WebElement> property = driver.findElements(By.cssSelector("#cq-gen8 li"));
    Iterator it = property.iterator();
    it.next();

    assertEquals("Translation Label: test", ((WebElement) it.next()).getText());

}

From source file:com.demo.selenium.example.GridExampleTest.java

License:Apache License

@Test
public void GridTwoNodeTest() throws MalformedURLException, InterruptedException {

    DesiredCapabilities aDesiredcap = DesiredCapabilities.chrome();
    WebDriver dr = new RemoteWebDriver(new URL("http://172.19.6.46:5555/wd/hub"), aDesiredcap);
    dr.get("http://www.baidu.com");
    dr.manage().window().maximize();/*from w w w .j  av a 2s  . c om*/

    String str[] = new String[] { "java", "selenium", "spring", "mybatis", "jps", "grid", "mysql", "iphone" };
    for (String string : str) {
        WebElement element = dr.findElement(By.xpath(".//*[@id='kw']"));
        element.clear();
        element.sendKeys(string);

        Thread.sleep(1000);

        WebElement buttons = dr.findElement(By.xpath(".//*[@id='su']"));

        System.out.println(buttons.getTagName());

        buttons.click();
    }

    Thread.sleep(2000);

    dr.close();

}