List of usage examples for org.openqa.selenium.support.ui Select deselectAll
@Override public void deselectAll()
From source file:scormADL2004.java
License:Open Source License
/** * Select All valid tests to perform in ADL 2004 Test Suite * @param testsToExecute/*from w ww. j a v a 2 s. c o m*/ */ public void initialiseTestSuite(String[] testsToExecute) { driver.switchTo().window(""); driver.switchTo().frame("instructions"); Select multipleTestsSelect = new Select(driver.findElement(By.id("possible"))); multipleTestsSelect.deselectAll(); for (int i = 0; i < testsToExecute.length; i++) { multipleTestsSelect.selectByVisibleText(testsToExecute[i]); } // Workaround for Selenium bug - 1020, to be fixed in 2.5.0 driver.findElement(By.id("add")).sendKeys(Keys.ENTER); driver.switchTo().window(""); driver.switchTo().frame("controls"); driver.findElement(By.id("continue")).click(); try { driver.switchTo().alert().accept(); } catch (NoAlertPresentException ex) { } }
From source file:com.ecofactor.qa.automation.insite.page.PartnerManagementImpl.java
License:Open Source License
/** * Fill partner type details.//from w w w . ja v a 2s . co m * @param driver the driver * @param availableRole the available role */ private void fillPartnerTypeDetails(final WebDriver driver, final String availableRole) { clickPartnerTypes(); LogUtil.setLogString("check if available roles element is displayed.", true); isDisplayedById(driver, partnerConfig.get(AVAILABLE_PARTNER_TYPE), MEDIUM_TIMEOUT); LogUtil.setLogString("unselect existing selection.", true); removeAllToAvailablePane(driver); final Select select = new Select(driver.findElement(By.id(partnerConfig.get(AVAILABLE_PARTNER_TYPE)))); select.deselectAll(); LogUtil.setLogString("select required role " + availableRole, true); select.selectByValue(availableRole); LogUtil.setLogString("click on add button.", true); driver.findElement(By.id(ADD_AVAILABLE_ROLE)).click(); }
From source file:com.ecofactor.qa.automation.insite.page.UserManagementImpl.java
License:Open Source License
/** * Assign role to User./*from w w w . j ava 2 s .c o m*/ * @param userName the user name * @return assigned role */ @Override public String assignRoleToUser(final String userName) { clickRoleTab(); DriverConfig.setLogString("check if available roles element is displayed.", true); isDisplayedById(DriverConfig.getDriver(), userConfig.get(AVAILABLE_ROLES), MEDIUM_TIMEOUT); final Select select = new Select( DriverConfig.getDriver().findElement(By.id(userConfig.get(AVAILABLE_ROLES)))); select.deselectAll(); DriverConfig.setLogString("select required role.", true); final List<WebElement> optionsList = select.getOptions(); final String firstRole = optionsList.get(0).getText(); DriverConfig.setLogString("Role Assigned to the user :" + firstRole, true); select.selectByVisibleText(firstRole); tinyWait(); DriverConfig.setLogString("click on add button.", true); DriverConfig.getDriver().findElement(By.id("add")).click(); return firstRole; }
From source file:com.ecofactor.qa.automation.insite.page.UserManagementImpl.java
License:Open Source License
/** * Verify the role is assigned and reassign the role. * @param assignedRole the assigned role *///from w w w. ja v a 2 s . co m @Override public void verifyAndReAssignRole(final String assignedRole) { clickRoleTab(); DriverConfig.setLogString("check if assigned roles element is displayed.", true); DriverConfig.setLogString("Assigned Role " + assignedRole, true); isDisplayedById(DriverConfig.getDriver(), userConfig.get(ASSIGNED_ROLES), MEDIUM_TIMEOUT); final Select select = new Select( DriverConfig.getDriver().findElement(By.id(userConfig.get(ASSIGNED_ROLES)))); final List<WebElement> optionsList = select.getOptions(); for (final WebElement webelement : optionsList) { if (webelement.getText().equalsIgnoreCase(assignedRole)) { Assert.assertTrue(true); DriverConfig.setLogString("Assigned role is verified, and the role is :" + webelement.getText(), true); } } DriverConfig.setLogString("ReAssign the selected Role", true); select.deselectAll(); DriverConfig.setLogString("select required role " + assignedRole, true); select.selectByVisibleText(assignedRole); DriverConfig.setLogString("click on remove button.", true); DriverConfig.getDriver().findElement(By.id("remove")).click(); smallWait(); }
From source file:com.ecofactor.qa.automation.insite.page.UserManagementImpl.java
License:Open Source License
/** * <p>//from w w w .j a v a 2 s . c o m * Click Role tab, and select the available roles. * </p> * @param driver the driver * @param availableRole the available role */ private void sendRoleDetails(final WebDriver driver, final String availableRole) { DriverConfig.setLogString( "Click on Role tab and Send the Role details to the selection, and add it to the pane.", true); isDisplayedById(driver, "roles", SHORT_TIMEOUT); clickRoleTab(); DriverConfig.setLogString("check if available roles element is displayed.", true); isDisplayedById(driver, userConfig.get(AVAILABLE_ROLES), MEDIUM_TIMEOUT); DriverConfig.setLogString("unselect existing selection.", true); removeAllToAvailablePane(driver); final Select select = new Select(driver.findElement(By.id(userConfig.get(AVAILABLE_ROLES)))); select.deselectAll(); DriverConfig.setLogString("select required role " + availableRole, true); if (!availableRole.isEmpty()) { select.selectByVisibleText(availableRole); DriverConfig.setLogString("click on add button.", true); driver.findElement(By.id("add")).click(); } }
From source file:com.hotwire.selenium.desktop.hotelextranet.ExtranetHotelOverviewPage.java
License:Open Source License
/** * Select the specific room type or select all room type * * @param roomType/*w ww. j a v a2 s.c om*/ * */ public void selectRoomType(String roomType) { Select roomTypeSelect = new Select(roomTypeField); roomTypeSelect.deselectAll(); roomTypeSelect.selectByVisibleText(roomType); }
From source file:com.mkl.websuites.internal.command.impl.select.DeselectAllCommand.java
License:Apache License
@Override protected void doOperationOnElement(WebElement elem) { if (!CommandUtils.checkIfElementIsSelect(elem)) { fail(String.format("Element picked by selector '%s' must be a SELECT, but is '%s'", by, elem.getTagName()));/* ww w . j a v a 2s . c om*/ } Select select = new Select(elem); select.deselectAll(); }
From source file:com.pentaho.ctools.issues.cdf.CDF435.java
License:Apache License
/** * ############################### Test Case 1 ############################### * * Test Case Name:/* w ww .java 2 s. c o m*/ * Assert Prpt Component is properly loaded and working * * Description: * The test pretends validate the CDF-435 issue, so using the specific dashboard created to replicate this issue * make sure that the Prpt Component is properly loaded and working as expected. * * Steps: * 1. Assert Elements and Text on Dashboard * 2. Select 2004 on 'select multiple=""' * 3. Assert Elements and Text on Dashboard */ @Test public void tc01_PrptComponent_RenderedResponsive() { this.log.info("tc01_PrptComponent_RenderedResponsive"); /* * ## Step 1 */ //Go to New CDE Dashboard driver.get(baseUrl + "api/repos/%3Apublic%3AIssues%3ACDF%3ACDF-435%3AIssue_435.wcdf/generatedContent"); // Wait for loading disappear this.elemHelper.WaitForElementInvisibility(driver, By.cssSelector("div.blockUI.blockOverlay"), 90); //assert Elements loaded WebElement element = this.elemHelper.WaitForElementPresenceAndVisible(driver, By.id("Panel_1")); assertNotNull(element); //focus iframe WebElement elementFrame = this.elemHelper.FindElement(driver, By.xpath("//iframe[@name='report_prptFrame']"), 180); assertNotNull(elementFrame); WebDriver frame = driver.switchTo().frame(elementFrame); element = this.elemHelper.WaitForElementPresenceAndVisible(frame, By.id("pageControl")); assertNotNull(element); element = this.elemHelper.WaitForElementPresenceAndVisible(frame, By.id("reportControlPanel")); assertNotNull(element); element = this.elemHelper.WaitForElementPresenceAndVisible(frame, By.xpath("//div[@id='promptPanel']//button")); assertNotNull(element); String buttonText = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//div[@id='promptPanel']//button")); assertEquals("View Report", buttonText); element = this.elemHelper.WaitForElementPresenceAndVisible(frame, By.xpath("//input[@value='[Time].[2003]']")); assertNotNull(element); String yearText = this.elemHelper.GetInputValue(frame, By.xpath("//input[@value='[Time].[2003]']")); assertEquals("[Time].[2003]", yearText); //focus iframe2 elementFrame = this.elemHelper.FindElement(driver, By.xpath("//iframe[@id='reportContent']")); frame = driver.switchTo().frame(elementFrame); //Check content of table String r1c1Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[2]/td")); String r1c2Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[2]/td[2]")); String r1c3Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[2]/td[3]")); String r1c4Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[2]/td[4]")); String r2c1Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[3]/td")); String r2c2Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[3]/td[2]")); String r2c3Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[3]/td[3]")); String r2c4Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[3]/td[4]")); String r3c1Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[4]/td")); String r3c2Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[4]/td[2]")); String r3c3Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[4]/td[3]")); String r3c4Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[4]/td[4]")); assertEquals("Euro+ Shopping Channel", r1c1Text); assertEquals("$ 210,228", r1c2Text); assertEquals("2,153", r1c3Text); assertEquals("5.72 %", r1c4Text); assertEquals("Mini Gifts Distributors Ltd.", r2c1Text); assertEquals("$ 185,128", r2c2Text); assertEquals("1,898", r2c3Text); assertEquals("5.03 %", r2c4Text); assertEquals("Dragon Souveniers, Ltd.", r3c1Text); assertEquals("$ 165,686", r3c2Text); assertEquals("1,452", r3c3Text); assertEquals("4.51 %", r3c4Text); /* * ## Step 2 */ driver.switchTo().defaultContent(); Select select = new Select(this.elemHelper.FindElement(driver, By.xpath("//div[@id='Panel_1']/select"))); select.deselectAll(); select.selectByVisibleText("2004"); // Wait for loading disappear this.elemHelper.WaitForElementInvisibility(driver, By.cssSelector("div.blockUI.blockOverlay")); /* * ## Step 3 */ //focus iframe elementFrame = this.elemHelper.FindElement(driver, By.xpath("//iframe[@name='report_prptFrame']")); frame = driver.switchTo().frame(elementFrame); element = this.elemHelper.WaitForElementPresenceAndVisible(driver, By.xpath("//div[@id='promptPanel']//button")); assertNotNull(element); buttonText = this.elemHelper.WaitForElementPresentGetText(driver, By.xpath("//div[@id='promptPanel']//button")); assertEquals("View Report", buttonText); element = this.elemHelper.WaitForElementPresenceAndVisible(frame, By.xpath("//input[@value='[Time].[2004]']")); assertNotNull(element); yearText = this.elemHelper.GetInputValue(frame, By.xpath("//input[@value='[Time].[2004]']")); assertEquals("[Time].[2004]", yearText); //focus iframe2 elementFrame = this.elemHelper.FindElement(driver, By.xpath("//iframe[@id='reportContent']")); frame = driver.switchTo().frame(elementFrame); //Check content of table r1c1Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[2]/td")); r1c2Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[2]/td[2]")); r1c3Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[2]/td[3]")); r1c4Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[2]/td[4]")); r2c1Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[3]/td")); r2c2Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[3]/td[2]")); r2c3Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[3]/td[3]")); r2c4Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[3]/td[4]")); r3c1Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[4]/td")); r3c2Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[4]/td[2]")); r3c3Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[4]/td[3]")); r3c4Text = this.elemHelper.WaitForElementPresentGetText(frame, By.xpath("//tbody/tr[4]/td[4]")); assertEquals("Euro+ Shopping Channel", r1c1Text); assertEquals("$ 375,268", r1c2Text); assertEquals("3,912", r1c3Text); assertEquals("7.52 %", r1c4Text); assertEquals("Mini Gifts Distributors Ltd.", r2c1Text); assertEquals("$ 256,474", r2c2Text); assertEquals("2,425", r2c3Text); assertEquals("5.14 %", r2c4Text); assertEquals("Australian Collectors, Co.", r3c1Text); assertEquals("$ 140,860", r3c2Text); assertEquals("1,335", r3c3Text); assertEquals("2.82 %", r3c4Text); }
From source file:com.screenslicer.core.scrape.QueryForm.java
License:Open Source License
public static void perform(RemoteWebDriver driver, FormQuery context) throws ActionFailed { try {// w w w. j av a 2 s . co m Util.get(driver, context.site, true); Util.doClicks(driver, context.preAuthClicks, null); QueryCommon.doAuth(driver, context.credentials); Util.doClicks(driver, context.preSearchClicks, null); Map<String, HtmlNode> formControls = new HashMap<String, HtmlNode>(); for (int i = 0; i < context.formSchema.length; i++) { formControls.put(context.formSchema[i].guid, context.formSchema[i]); } Map<String, List<String>> formData = context.formModel; boolean valueChanged = false; int count = 0; final int MAX_TRIES = 3; Element body = Util.openElement(driver, null, null, null); do { ++count; valueChanged = false; for (Map.Entry<String, List<String>> entry : formData.entrySet()) { try { HtmlNode formControl = formControls.get(entry.getKey()); if (!CommonUtil.isEmpty(entry.getValue())) { if ("select".equalsIgnoreCase(formControl.tagName)) { if (WebApp.DEBUG) { System.out.println("Query Form: select"); } Select select = new Select(Util.toElement(driver, formControl, body)); if (select.isMultiple()) { select.deselectAll(); } List<WebElement> selectedElements = select.getAllSelectedOptions(); List<String> selectedStrings = new ArrayList<String>(); for (WebElement selectedElement : selectedElements) { String selectedString = selectedElement.getAttribute("value"); if (!CommonUtil.isEmpty(selectedString)) { selectedStrings.add(selectedString); } } boolean matches = true; for (String selectedString : selectedStrings) { if (!entry.getValue().contains(selectedString)) { matches = false; break; } } if (!matches || selectedStrings.size() != entry.getValue().size()) { for (String val : entry.getValue()) { valueChanged = true; select.selectByValue(val); Util.driverSleepVeryShort(); } } } else if ("input".equalsIgnoreCase(formControl.tagName) && ("text".equalsIgnoreCase(formControl.type) || "search".equalsIgnoreCase(formControl.type))) { if (WebApp.DEBUG) { System.out.println("Query Form: input[text|search]"); } WebElement element = Util.toElement(driver, formControl, body); valueChanged = QueryCommon.typeText(driver, element, entry.getValue().get(0), true, false); } else if ("input".equalsIgnoreCase(formControl.tagName) && ("checkbox".equalsIgnoreCase(formControl.type) || "radio".equalsIgnoreCase(formControl.type))) { if (WebApp.DEBUG) { System.out.println("Query Form: input[checkbox|radio]"); } WebElement element = Util.toElement(driver, formControl, body); if (entry.getValue() != null && !entry.getValue().isEmpty()) { if ("radio".equalsIgnoreCase(formControl.type)) { String elementVal = element.getAttribute("value"); String schemaVal = formControl.value; String modelVal = entry.getValue().get(0); if (elementVal != null && schemaVal != null && elementVal.equalsIgnoreCase(schemaVal) && modelVal.equalsIgnoreCase(schemaVal)) { if (!element.isSelected()) { if (WebApp.DEBUG) { System.out.println("Clicking radio button"); } valueChanged = Util.click(driver, element); } } } else if (!element.isSelected()) { if (WebApp.DEBUG) { System.out.println("Clicking [checkbox|radio]"); } valueChanged = Util.click(driver, element); } } else { if (element.isSelected()) { if (WebApp.DEBUG) { System.out.println("Deselecting [checkbox|radio]"); } valueChanged = true; element.clear(); Util.driverSleepVeryShort(); } } } } } catch (Throwable t) { Log.exception(t); } } } while (valueChanged && count < MAX_TRIES); doSubmit(driver, context.formId); Util.doClicks(driver, context.postSearchClicks, null); } catch (Throwable t) { Log.exception(t); throw new ActionFailed(t); } }
From source file:com.stratio.qa.specs.WhenGSpec.java
License:Apache License
/** * Choose no option from a select webelement found previously * * @param index/*from w ww . ja v a2 s .c o m*/ */ @When("^I de-select every item on the element on index '(\\d+?)'$") public void elementDeSelect(Integer index) { Select sel = null; sel = new Select(commonspec.getPreviousWebElements().getPreviousWebElements().get(index)); if (sel.isMultiple()) { sel.deselectAll(); } }