congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
WebElement.isSelected
Code IndexAdd Tabnine to your IDE (free)

How to use
isSelected
method
in
org.openqa.selenium.WebElement

Best Java code snippets using org.openqa.selenium.WebElement.isSelected (Showing top 20 results out of 873)

origin: selenide/selenide

@Override
public boolean apply(Driver driver, WebElement element) {
 return element.isSelected();
}
origin: selenide/selenide

@Override
public boolean apply(Driver driver, WebElement element) {
 return element.isSelected();
}
origin: selenide/selenide

 private void setSelected(WebElement option) {
  if (!option.isSelected()) {
   option.click();
  }
 }
}
origin: selenide/selenide

 @Override
 public String actualValue(Driver driver, WebElement element) {
  return String.valueOf(element.isSelected());
 }
};
origin: selenide/selenide

 @Override
 public String actualValue(Driver driver, WebElement element) {
  return String.valueOf(element.isSelected());
 }
};
origin: selenide/selenide

private Describe isSelected(WebElement element) {
 try {
  if (element.isSelected()) {
   sb.append(' ').append("selected:true");
  }
 } catch (UnsupportedOperationException ignore) {
 } catch (InvalidElementStateException ignore) {
 }
 return this;
}
origin: selenide/selenide

 @Override
 public WebElement execute(SelenideElement proxy, WebElementSource locator, Object[] args) {
  boolean selected = (Boolean) args[0];
  WebElement element = locator.getWebElement();
  if (!element.isDisplayed()) {
   throw new InvalidStateException(locator.driver(), "Cannot change invisible element");
  }
  String tag = element.getTagName();
  if (!tag.equals("option")) {
   if (tag.equals("input")) {
    String type = element.getAttribute("type");
    if (!type.equals("checkbox") && !type.equals("radio")) {
     throw new InvalidStateException(locator.driver(), "Only use setSelected on checkbox/option/radio");
    }
   }
   else {
    throw new InvalidStateException(locator.driver(), "Only use setSelected on checkbox/option/radio");
   }
  }
  if (element.getAttribute("readonly") != null || element.getAttribute("disabled") != null) {
   throw new InvalidStateException(locator.driver(), "Cannot change value of readonly/disabled element");
  }
  if (element.isSelected() != selected) {
   click.execute(proxy, locator, NO_ARGS);
  }
  return proxy;
 }
}
origin: spring-io/initializr

@Test
void dependencyUncheckedWhenHidden() throws Exception {
  HomePage page = toHome(); // bur: [2.1.4.RELEASE,2.2.0.BUILD-SNAPSHOT)
  page.advanced();
  page.dependency("org.acme:bur").click();
  assertThat(page.dependency("org.acme:bur").isSelected()).isTrue();
  page.bootVersion("1.5.17.RELEASE");
  assertThat(page.dependency("org.acme:bur").isEnabled()).isFalse();
  page.bootVersion("2.1.4.RELEASE");
  assertThat(page.dependency("org.acme:bur").isEnabled()).isTrue();
  assertThat(page.dependency("org.acme:bur").isSelected()).isFalse();
}
origin: spring-io/initializr

private Object getInputValue(WebElement input) {
  Object value = null;
  String type = input.getAttribute("type");
  if ("select".equals(input.getTagName())) {
    Select select = new Select(input);
    if (select.isMultiple()) {
      value = select.getAllSelectedOptions().stream().map(this::getValue)
          .collect(Collectors.toList());
    }
    else {
      value = getValue(select.getFirstSelectedOption());
    }
  }
  else if (Arrays.asList("checkbox", "radio").contains(type)) {
    if (input.isSelected()) {
      value = getValue(input);
    }
    else {
      if (Objects.equals(type, "checkbox")) {
        value = false;
      }
    }
  }
  else {
    value = getValue(input);
  }
  return value;
}
origin: cloudfoundry/uaa

Assert.assertFalse(webDriver.findElement(By.xpath("//input[@value='app-password.write']")).isSelected());
Assert.assertFalse(webDriver.findElement(By.xpath("//input[@value='app-scim.userids']")).isSelected());
Assert.assertTrue(webDriver.findElement(By.xpath("//input[@value='app-cloud_controller.read']")).isSelected());
Assert.assertTrue(webDriver.findElement(By.xpath("//input[@value='app-cloud_controller.write']")).isSelected());
Assert.assertTrue(webDriver.findElement(By.xpath("//input[@value='app-password.write']")).isSelected());
Assert.assertTrue(webDriver.findElement(By.xpath("//input[@value='app-scim.userids']")).isSelected());
Assert.assertTrue(webDriver.findElement(By.xpath("//input[@value='app-cloud_controller.read']")).isSelected());
Assert.assertTrue(webDriver.findElement(By.xpath("//input[@value='app-cloud_controller.write']")).isSelected());
origin: TEAMMATES/teammates

public boolean isElementSelected(String elementId) {
  try {
    return browser.driver.findElement(By.id(elementId)).isSelected();
  } catch (NoSuchElementException e) {
    return false;
  }
}
origin: TEAMMATES/teammates

public boolean getInstructorDisplayedToStudents(int instrNum) {
  String isDisplayedToStudentsCheckboxSelector = "#instructorTable" + instrNum + " input[name='"
      + Const.ParamsNames.INSTRUCTOR_IS_DISPLAYED_TO_STUDENT
      + "']";
  return browser.driver.findElement(By.cssSelector(isDisplayedToStudentsCheckboxSelector)).isSelected();
}
origin: TEAMMATES/teammates

public boolean isPrivilegeCheckboxInModalChecked(String privilege) {
  By selector = By.cssSelector("#tunePermissionsDivForInstructorAll input[type='checkbox'][name='"
                 + privilege + "']");
  WebElement checkbox = browser.driver.findElement(selector);
  return checkbox.isSelected();
}
origin: TEAMMATES/teammates

public boolean isPrivilegeCheckboxInPermissionDivChecked(int instructorIndex, String privilege) {
  By selector = By.cssSelector("#tunePermissionsDivForInstructor" + instructorIndex
                 + " input[type='checkbox'][name='" + privilege + "']");
  WebElement checkbox = browser.driver.findElement(selector);
  return checkbox.isSelected();
}
origin: TEAMMATES/teammates

public boolean isCheckboxChecked(String checkboxClass, String checkboxValue, int questionNumber) {
  By checkboxSelector = By.cssSelector("#questionTable-" + questionNumber + " input[value='" + checkboxValue
                          + "']." + checkboxClass);
  WebElement checkbox = browser.driver.findElement(checkboxSelector);
  return checkbox.isSelected();
}
origin: TEAMMATES/teammates

/**
 * 'uncheck' the check box, if it is already 'checked'.
 * No action taken if it is not already 'checked'.
 */
protected void markCheckBoxAsUnchecked(WebElement checkBox) {
  if (checkBox.isSelected()) {
    click(checkBox);
  }
}
origin: TEAMMATES/teammates

/**
 * 'check' the check box, if it is not already 'checked'.
 * No action taken if it is already 'checked'.
 */
protected void markCheckBoxAsChecked(WebElement checkBox) {
  waitForElementVisibility(checkBox);
  if (!checkBox.isSelected()) {
    click(checkBox);
  }
}
origin: TEAMMATES/teammates

/**
 * 'check' the radio button, if it is not already 'checked'.
 * No action taken if it is already 'checked'.
 */
protected void markRadioButtonAsChecked(WebElement radioButton) {
  waitForElementVisibility(radioButton);
  if (!radioButton.isSelected()) {
    click(radioButton);
  }
}
origin: TEAMMATES/teammates

public boolean isRadioButtonChecked(int rowIndex) {
  WebElement button = browser.driver.findElement(By.id("copyTableModal"))
                  .findElements(By.tagName("tr"))
                  .get(rowIndex + 1).findElement(By.tagName("input"));
  return button.isSelected();
}
origin: TEAMMATES/teammates

public void submitWithoutConfirmationEmail() {
  WebElement sendEmailCheckbox = browser.driver.findElement(By.name(Const.ParamsNames.SEND_SUBMISSION_EMAIL));
  if (sendEmailCheckbox.isSelected()) {
    click(sendEmailCheckbox);
  }
  clickSubmitButton();
}
org.openqa.seleniumWebElementisSelected

Javadoc

Determine whether or not this element is selected or not. This operation only applies to input elements such as checkboxes, options in a select and radio buttons.

Popular methods of WebElement

  • getText
    Get the visible (i.e. not hidden by CSS) text of this element, including sub-elements.
  • click
    Click this element. If this causes a new page to load, you should discard all references to this ele
  • sendKeys
    Use this method to simulate typing into an element, which may set its value.
  • getAttribute
    Get the value of the given attribute of the element. Will return the current value, even if this has
  • clear
    If this element is a text entry element, this will clear the value. Has no effect on other elements.
  • isDisplayed
    Is this element displayed or not? This method avoids the problem of having to parse an element's "st
  • findElements
    Find all elements within the current context using the given mechanism. When using xpath be aware th
  • findElement
    Find the first WebElement using the given method. See the note in #findElements(By) about finding vi
  • getTagName
    Get the tag name of this element. Not the value of the name attribute: will return"input" for the el
  • isEnabled
    Is the element currently enabled or not? This will generally return true for everything but disabled
  • getLocation
    Where on the page is the top left-hand corner of the rendered element?
  • submit
    If this current element is a form, or an element within a form, then this will be submitted to the r
  • getLocation,
  • submit,
  • getSize,
  • getCssValue,
  • getRect,
  • getScreenshotAs,
  • getValue,
  • setSelected,
  • toggle

Popular in Java

  • Reading from database using SQL prepared statement
  • setContentView (Activity)
  • getContentResolver (Context)
  • getSupportFragmentManager (FragmentActivity)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • Socket (java.net)
    Provides a client-side TCP socket.
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • Top 12 Jupyter Notebook Extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now