Example usage for org.openqa.selenium WebElement isSelected

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

Introduction

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

Prototype

boolean isSelected();

Source Link

Document

Determine whether or not this element is selected or not.

Usage

From source file:com.goCompare.pages.AboutYourDrivingPage.java

public void LicenseInfo() {
    try {//from  w  w w .ja va  2  s .c o  m
        WebElement license = driver.findElement(By.id("YourDriving_LicenceType"));
        Select myLicense = new Select(license);
        myLicense.selectByValue("UKFull");

        WebElement license2 = driver.findElement(By.id("YourDriving_LicenceLength_Years"));
        Select myLicense2 = new Select(license2);
        myLicense2.selectByValue("Two");

        WebElement cac4 = driver.findElement(By.id("YourDriving_HasIAM_false"));
        if (cac4.isSelected()) {
            System.out.println("Hello, this option has been selected");
        } else {
            cac4.click();
        }

        WebElement license3 = driver.findElement(By.id("YourDriving_MedicalConditions"));
        Select myLicense3 = new Select(license3);
        myLicense3.selectByValue("No");

        WebElement license4 = driver.findElement(By.id("YourDriving_NoClaimsBonus"));
        Select myLicense4 = new Select(license4);
        myLicense4.selectByValue("TwoYears");

        WebElement license5 = driver.findElement(By.id("YourDriving_OtherVehicles"));
        Select myLicense5 = new Select(license5);
        myLicense5.selectByValue("No");
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.goCompare.pages.AboutYourDrivingPage.java

public void licenseNumber() {
    WebElement cac5 = driver.findElement(By.id("DrivingLicenceNumberPanel_Provided_false"));
    if (cac5.isSelected()) {
        System.out.println("Hello, this option has been selected");
    } else {//from   ww  w.  ja  va2s  . c o  m
        cac5.click();
    }
}

From source file:com.goCompare.pages.AboutYourDrivingPage.java

public void claimsAndConvictions() {
    WebElement cac = driver.findElement(By.id("ClaimsConvictions_AccidentsInLastFiveYears_false"));
    if (cac.isSelected()) {
        System.out.println("Hello, this option has been selected");
    } else {/*w  w  w.  j  a  va 2  s . co m*/
        cac.click();

        WebElement cac2 = driver.findElement(By.id("ClaimsConvictions_ConvictionsInLastFiveYears_false"));
        if (cac2.isSelected()) {
            System.out.println("Hello, this option has been selected");
        } else {
            cac2.click();
        }
    }
    WebElement cac3 = driver.findElement(By.id("ClaimsConvictions_UnspentNonMotoringConvictions_false"));
    if (cac3.isSelected()) {
        System.out.println("Hello, this option has been selected");
    } else {
        cac3.click();
    }
    driver.findElement(By.xpath("//*[@id='driver-form']/div[5]/input")).click();

}

From source file:com.hotwire.selenium.desktop.row.results.CarFilteringModule.java

License:Open Source License

public void disableOnlyCheckboxForOneFilterOption(List<WebElement> checkboxForDisable) {
    for (WebElement checkBox : listOfFilteringCheckBoxes) {
        if (checkboxForDisable.contains(checkBox)) {
            if (checkBox.isSelected()) {
                checkBox.click();// w  w w . ja v a 2 s . c  om
                waitingWhenFilteringDone();
            }
        } else if (!checkBox.isSelected()) {
            checkBox.click();
            waitingWhenFilteringDone();
        }
    }
}

From source file:com.hotwire.selenium.desktop.seo.DestinationListPage.java

License:Open Source License

public String getSelectedCountryFromDropdownList() {
    WebElement selectedCountry = null;//from ww  w  . ja  v a  2s. c om
    for (WebElement country : countrySelect.findElements(By.tagName("option"))) {
        if (country.isSelected()) {
            selectedCountry = country;
        }
    }
    return (selectedCountry == null) ? null : selectedCountry.getText();
}

From source file:com.hotwire.selenium.desktop.us.billing.car.impl.accordion.AcPaymentMethodFragment.java

License:Open Source License

@Override
public String getNameOfChosenPaymentMethod() {
    List<WebElement> listOfPaymentMethods = getWebDriver().findElements(
            By.cssSelector("div.paymentMethod" + " div.paymentMethodSelector div input[type='radio']"));
    for (WebElement a : listOfPaymentMethods) {
        if (a.isSelected()) {
            return a.getAttribute("id");
        }//from   w  w  w.j a  v  a 2 s .  c  o  m
    }
    return "null";
}

From source file:com.hotwire.selenium.desktop.us.billing.car.impl.accordion.HotDollarPaymentFragment.java

License:Open Source License

public void useIt() {
    WebElement useIt = getHotDollarsButton();
    if (!useIt.isSelected()) {
        useIt.click();//from   w  w w .j a  v a2  s. c  o  m
        new WebDriverWait(getWebDriver(), getTimeout()).until(new IsAjaxDone());
    }
}

From source file:com.hotwire.selenium.desktop.us.billing.car.impl.CarTravelerInfoFragment.java

License:Open Source License

@Override
public CarTravelerInfo creditCardAcceptance(boolean accepted) {

    WebElement cb = getCardAcceptance();

    if (cb != null && cb.isDisplayed()) {
        if (accepted && !cb.isSelected()) {
            cb.click();/*from   w  ww  .  j  a  v  a 2s  .com*/
        }

        if (!accepted && cb.isSelected()) {
            cb.click();
        }
    }
    return this;
}

From source file:com.hotwire.selenium.desktop.us.billing.car.impl.ccf.CcfPaymentMethodFragment.java

License:Open Source License

public String getNameOfChosenPaymentMethod() {
    List<WebElement> listOfPaymentMethods = getWebDriver().findElements(
            By.cssSelector("div.paymentMethod" + " div.paymentMethodSelector div input[type='radio']"));
    for (WebElement a : listOfPaymentMethods) {
        if (a.isSelected()) {
            return a.getAttribute("id");
        }/*from  w w w  . ja v  a 2 s .c  om*/
    }
    return "null";
}

From source file:com.hotwire.selenium.desktop.us.billing.onepage.HotelBillingOnePage.java

License:Open Source License

public String getSelectedPaymentMethodIDValue() {
    for (WebElement element : getWebDriver()
            .findElements(By.cssSelector(".selectPaymentMethod .cardMethod input.radioBtn"))) {
        if (element.isSelected()) {
            return element.getAttribute("id").trim();
        }/*  w w  w .j  ava 2s  .c o  m*/
    }
    throw new RuntimeException("Could not find the payment method that was selected.");
}