List of usage examples for org.openqa.selenium WebElement isSelected
boolean isSelected();
From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java
License:Open Source License
public String getHTMLSourceOfOmnitureDebuggerWindow(final String javaScript, String windowName, String decodeCheckboxNameLocator, int waitTime) { String htmlSource = null;//from ww w. ja v a 2 s. c o m String parentWindowHandle = driver.getWindowHandle(); executor.executeScript(javaScript); try { boolean windowFound = false; while (!windowFound) { { driver = driver.switchTo().window(windowName); WebElement element = driver.findElement(By.name(decodeCheckboxNameLocator)); if (!element.isSelected()) { element.click(); while (!element.isSelected()) { Thread.sleep(waitTime); } } executor.executeScript("window.scrollBy(0,450)", ""); // scroll down to view the last image Thread.sleep(waitTime); htmlSource = driver.getPageSource(); driver.close();// child window closing windowFound = true; break; } } } catch (Exception e) { e.printStackTrace(); } driver.switchTo().window(parentWindowHandle); // driver.close(); // do not close for another set of actions return htmlSource; }
From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java
License:Open Source License
public void unselectFromListByIndex(String locator, List<Integer> indices) { LOG.createAppender().appendBold("Unselect From List By Index:").appendCss(locator) .appendProperty("Indices", indices).log(); HighlightRobotLogger.HtmlAppender appender = LOG.createAppender(); List<WebElement> options = getSelectListOptions(locator); for (int i : indices) { WebElement option = options.get(i); boolean isSelected = option.isSelected(); //if not selected, dont unselect since it'll just click the option--thus selecting it. if (isSelected) { appender.append(String.format("option[index=%d,value=%s]", i, option.getAttribute("value")), option.getText());/* w w w .j a v a 2s .c om*/ option.click(); } } appender.log(); }
From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java
License:Open Source License
public void unselectFromListByValue(String locator, List<String> values) { LOG.createAppender().appendBold("Unselect From List By Value:").appendCss(locator) .appendProperty("Values", values).log(); HighlightRobotLogger.HtmlAppender appender = LOG.createAppender(); List<WebElement> options = getSelectListOptions(locator); for (int i = 0; i < options.size(); i++) { WebElement option = options.get(i); if (values.contains(option.getAttribute("value"))) { boolean isSelected = option.isSelected(); //if not selected, dont unselect since it'll just click the option--thus selecting it. if (isSelected) { appender.append(String.format("option[index=%d,value=%s]", i, option.getAttribute("value")), option.getText()); option.click();//from w w w.j ava 2s . c o m } if (values.size() == 1) { // single selection so skip checking // other options break; } } } appender.log(); }
From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java
License:Open Source License
public void unselectFromListByLabel(String locator, List<String> labels) { LOG.createAppender().appendBold("Unselect From List By Label").appendCss(locator) .appendProperty("Labels", labels).log(); HighlightRobotLogger.HtmlAppender appender = LOG.createAppender(); List<WebElement> options = getSelectListOptions(locator); for (int i = 0; i < options.size(); i++) { WebElement option = options.get(i); if (labels.contains(option.getText())) { boolean isSelected = option.isSelected(); //if not selected, dont unselect since it'll just click the option--thus selecting it. if (isSelected) { appender.append(String.format("option[index=%d,value=%s]", i, option.getAttribute("value")), option.getText()); options.get(i).click();//from ww w . ja v a 2s .co m } if (labels.size() == 1) { // single selection so skip checking // other options break; } } } appender.log(); }
From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java
License:Open Source License
public void selectRadioButton(String groupName, String value) { LOG.info(String.format("Selecting '%s' from radio button '%s'", value, groupName)); WebElement el = getRadioButtonWithValue(groupName, value); if (!el.isSelected()) { el.click();//from w w w .j a va 2 s . c om } }
From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java
License:Open Source License
public boolean isElementSelected(String locator) { WebElement el = finder.find(locator, true, "input"); return el.isSelected(); }
From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java
License:Open Source License
public void selectCheckbox(String locator) { LOG.info(String.format("Selecting checkbox '%s'.", locator)); WebElement el = finder.find(locator, true, "input"); if (!el.isSelected()) { el.click();//w w w.j a va2 s . c om } }
From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java
License:Open Source License
public void unselectCheckbox(String locator) { LOG.info("Unselecting checkbox '%s'.", locator); WebElement el = getCheckbox(locator); if (el.isSelected()) { el.click();/*from w w w .j av a 2s .c o m*/ } }
From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java
License:Open Source License
private String getValueFromRadioButtons(List<WebElement> els) { for (WebElement el : els) { if (el.isSelected()) { return el.getAttribute("value"); }/* w ww . jav a2 s . c om*/ } return null; }
From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java
License:Open Source License
private List<WebElement> getSelectListOptionsSelected(String locator) { List<WebElement> selectOptions = getSelectListOptions(locator); List<WebElement> selectedOptions = new ArrayList<WebElement>(); for (WebElement selected : selectOptions) { if (selected.isSelected()) { selectedOptions.add(selected); }//from w w w. j a va 2s.c o m } return selectedOptions; }