List of usage examples for org.openqa.selenium WebElement isSelected
boolean isSelected();
From source file:com.ecofactor.qa.automation.insite.page.DemandSideManagementImpl.java
License:Open Source License
/** * Create Event Method creates LS Event in a given LS Program. Start date , * duration and mode (draft/save & schedule) for event creation are provided * as input .//ww w. ja v a 2s . c o m * * @param pastEvent * the past event * @param startDate * the start date * @param duration * the duration * @param mode * the mode * @param precoolOpted * the precool opted * @param groupName * the group name * @return the string * @throws ParseException * the parse exception */ public String createEvent(final boolean pastEvent, final String startDate, final String duration, final String mode, final boolean precoolOpted, String groupName) throws ParseException { DriverConfig.setLogString("Start create new event.", true); formatter = new SimpleDateFormat("yyyyMMddhhmmss"); WaitUtil.waitUntil(18000); // WaitUtil.waitUntil(10000); isDisplayedById(DriverConfig.getDriver(), demandSideManagementConfig.get(EVENT_LIST_PAGE_FORM_NAME), SHORT_TIMEOUT); formElement = DriverConfig.getDriver() .findElement(By.id(demandSideManagementConfig.get(EVENT_LIST_PAGE_FORM_NAME))); DriverConfig.setLogString("click create new event link.", true); WebElement newEventLink = formElement.findElement(By.linkText(demandSideManagementConfig.get(NEW_EVENT))); newEventLink.click(); inputEventName = "Test_" + formatter.format(new java.util.Date()); inputEventDesc = "Description for Test_" + formatter.format(new java.util.Date()); isDisplayedById(DriverConfig.getDriver(), demandSideManagementConfig.get(EVENT_CREATE_FORM_NAME), SHORT_TIMEOUT); newEventWizardForm = DriverConfig.getDriver() .findElement(By.id(demandSideManagementConfig.get(EVENT_CREATE_FORM_NAME))); WaitUtil.waitUntil(5000); DriverConfig.setLogString("find event name field.", true); WebElement eventName = newEventWizardForm.findElement(By.id(demandSideManagementConfig.get(EVENT_NAME))); DriverConfig.setLogString("Enter event name." + inputEventName, true); eventName.sendKeys(inputEventName); DriverConfig.setLogString("find event description field & send values to it.", true); newEventWizardForm.findElement(By.tagName(TAG_TEXTAREA)).sendKeys(inputEventDesc); DriverConfig.setLogString("Event Name provided :" + inputEventName, true); DriverConfig.setLogString("Event Desc provided :" + inputEventDesc, true); DriverConfig.setLogString("Event Start date provided :" + startDate, true); DriverConfig.setLogString("find start date field and enter start date.", true); newEventWizardForm.findElement(By.id(demandSideManagementConfig.get(START_TIME))).clear(); newEventWizardForm.findElement(By.id(demandSideManagementConfig.get(START_TIME))).sendKeys(startDate); roleManagement.clickDone(); DriverConfig.setLogString("find event duration field.", true); isFormDisplayedById(DriverConfig.getDriver(), newEventWizardForm, demandSideManagementConfig.get(EVENT_DURATION_ELEMENT), SHORT_TIMEOUT); DriverConfig.setLogString("select duration.", true); selectOptionByValue(newEventWizardForm, demandSideManagementConfig.get(EVENT_DURATION_ELEMENT), duration); DriverConfig.setLogString("Event Duration provided :" + duration + " minutes.", true); WaitUtil.waitUntil(1000); WebElement precoolOption = newEventWizardForm.findElement(By.id(demandSideManagementConfig.get(PRECOOL))); newEventWizardForm.findElement(By.id(demandSideManagementConfig.get(EVENT_DURATION_ELEMENT))).click(); DriverConfig.setLogString("select precool option if needed.", true); WaitUtil.waitUntil(SHORT_TIMEOUT); if (precoolOpted) { isFormElementClickableById(DriverConfig.getDriver(), demandSideManagementConfig.get(PRECOOL), MEDIUM_TIMEOUT); if (precoolOption.isSelected() == false) precoolOption.click(); } smallWait(); // DriverConfig.setLogString("Unselect the group for event.", true); // select groups WebElement selectGroupsForm = DriverConfig.getDriver() .findElement(By.id(demandSideManagementConfig.get(POPUP_FORM))); if (groupName != null) { DriverConfig.setLogString("select groups for event." + groupName, true); retrieveElementByAttributeValueByPassingElement(DriverConfig.getDriver(), selectGroupsForm, TAG_SPAN, ATTR_CLASS, demandSideManagementConfig.get(SELECT_GROUPS_CHECKBOX)).click(); WebElement groupsTableElement = retrieveElementByAttributeValueByPassingElement( DriverConfig.getDriver(), selectGroupsForm, TAG_TBODY, ATTR_ID, demandSideManagementConfig.get(GROUP_LIST_TABLE)); List<WebElement> groupRows = groupsTableElement.findElements(By.tagName("tr")); for (WebElement element : groupRows) { List<WebElement> groupColumns = element.findElements(By.tagName("td")); if (!groupColumns.isEmpty()) { WebElement checkBoxElement = groupColumns.get(0).findElement(By.tagName(TAG_INPUT)); WebElement groupNameElement = groupColumns.get(1); if (groupNameElement.findElement(By.tagName(TAG_DIV)).getText().equalsIgnoreCase(groupName)) // select the group name check box checkBoxElement.click(); } } } // End Select groups DriverConfig.setLogString("Mode " + mode, true); smallWait(); isFormDisplayedById(DriverConfig.getDriver(), newEventWizardForm, demandSideManagementConfig.get(EVENT_SAVE_BTN), MEDIUM_TIMEOUT); if (mode.equalsIgnoreCase(demandSideManagementConfig.get(EVENT_TYPE_DRAFT))) { WaitUtil.waitUntil(SHORT_TIMEOUT); DriverConfig.setLogString("click draft button.", true); newEventWizardForm.findElement(By.id(demandSideManagementConfig.get(EVENT_SAVE_BTN))).click(); } else if (mode.equalsIgnoreCase(demandSideManagementConfig.get(EVENT_TYPE_SCHEDULED))) { WaitUtil.waitUntil(SHORT_TIMEOUT); DriverConfig.setLogString("click schedule button.", true); newEventWizardForm.findElement(By.id(demandSideManagementConfig.get(EVENT_SCHEDULED_BTN))).click(); } else { smallWait(); DriverConfig.setLogString("click cancel button.", true); newEventWizardForm.findElement(By.id(demandSideManagementConfig.get(EVENT_CANCEL_BTN))).click(); } return inputEventName; }
From source file:com.ecofactor.qa.automation.insite.page.DemandSideManagementImpl.java
License:Open Source License
/** * Test Event Status Filter verifies that the event status filter shows up * list of events with selected event status. * /*from w ww .j av a2s.com*/ * @param programName * the program name * @throws ParseException * the parse exception */ public void testEventStatusFilter(final String programName) throws ParseException { pickGivenProgram(programName); loadPageFrame(); logger.info("check if event list form available.", true); isDisplayedById(DriverConfig.getDriver(), "form", SHORT_TIMEOUT); formElement = DriverConfig.getDriver().findElement(By.id("form")); DriverConfig.setLogString("find the event filter element.", true); isDisplayedById(DriverConfig.getDriver(), demandSideManagementConfig.get(EVENT_STATUS_FILTER), SHORT_TIMEOUT); DriverConfig.setLogString( "select options displayed in event status filter element and check if resulting event list displays events correspondingly.", true); WebElement select = formElement.findElement(By.id(demandSideManagementConfig.get(EVENT_STATUS_FILTER))); List<WebElement> options = select.findElements(By.tagName("option")); int i = 0; for (WebElement option : options) { selectOptionByText(formElement, demandSideManagementConfig.get(EVENT_STATUS_FILTER), option.getText()); if (option.isSelected()) { WaitUtil.waitUntil(2000); DriverConfig.setLogString("filter for " + option.getText() + ".", true); List<WebElement> listedEventStatus = retrieveElementsByAttributeValueList(DriverConfig.getDriver(), TAG_SPAN, ATTR_CLASS, demandSideManagementConfig.get(EVENT_STATUS_CLASS)); for (WebElement listItem : listedEventStatus) { WaitUtil.waitUntil(1000); log(listItem.getText()); if (i > 0) { Assert.assertTrue(listItem.getText().equalsIgnoreCase(option.getText()), "Status are different"); } } } i++; } }
From source file:com.ecofactor.qa.automation.insite.page.DemandSideManagementImpl.java
License:Open Source License
/** * Filter status.// w w w . jav a 2 s . c o m * * @param status * the status */ public void filterStatus(String status) { formElement = DriverConfig.getDriver().findElement(By.id("form")); DriverConfig.setLogString("find the event filter element.", true); isDisplayedById(DriverConfig.getDriver(), demandSideManagementConfig.get(EVENT_STATUS_FILTER), SHORT_TIMEOUT); DriverConfig.setLogString( "select options displayed in event status filter element and check if resulting event list displays events correspondingly.", true); WebElement select = formElement.findElement(By.id(demandSideManagementConfig.get(EVENT_STATUS_FILTER))); List<WebElement> options = select.findElements(By.tagName("option")); int i = 0; for (WebElement option : options) { if (option.getText().equalsIgnoreCase(status)) { selectOptionByText(formElement, demandSideManagementConfig.get(EVENT_STATUS_FILTER), option.getText()); if (option.isSelected()) { WaitUtil.waitUntil(2000); DriverConfig.setLogString("filter for " + option.getText() + ".", true); List<WebElement> listedEventStatus = retrieveElementsByAttributeValueList( DriverConfig.getDriver(), TAG_SPAN, ATTR_CLASS, demandSideManagementConfig.get(EVENT_STATUS_CLASS)); for (WebElement listItem : listedEventStatus) { WaitUtil.waitUntil(1000); log(listItem.getText()); if (i > 0) { Assert.assertTrue(listItem.getText().equalsIgnoreCase(option.getText()), "Status are different"); } } } i++; } } }
From source file:com.ecofactor.qa.automation.insite.page.DemandSideManagementImpl.java
License:Open Source License
/** * Create Event Method creates LS Event in a given LS Program. Start date , * duration and mode (draft/save & schedule) for event creation are provided * as input .//from w w w .ja va 2 s . c o m * * @param pastEvent * the past event * @param startDate * the start date * @param duration * the duration * @param mode * the mode * @param precoolOpted * the precool opted * @param groupName * the group name * @return the string * @throws ParseException * the parse exception */ public String createEventWithoutStartTime(final boolean pastEvent, final String startDate, final String duration, final String mode, final boolean precoolOpted, String groupName) throws ParseException { DriverConfig.setLogString("Start create new event.", true); formatter = new SimpleDateFormat("yyyyMMddhhmmss"); WaitUtil.waitUntil(18000); // WaitUtil.waitUntil(10000); isDisplayedById(DriverConfig.getDriver(), demandSideManagementConfig.get(EVENT_LIST_PAGE_FORM_NAME), SHORT_TIMEOUT); formElement = DriverConfig.getDriver() .findElement(By.id(demandSideManagementConfig.get(EVENT_LIST_PAGE_FORM_NAME))); DriverConfig.setLogString("click create new event link.", true); WebElement newEventLink = formElement.findElement(By.linkText(demandSideManagementConfig.get(NEW_EVENT))); newEventLink.click(); inputEventName = "Test_" + formatter.format(new java.util.Date()); inputEventDesc = "Description for Test_" + formatter.format(new java.util.Date()); isDisplayedById(DriverConfig.getDriver(), demandSideManagementConfig.get(EVENT_CREATE_FORM_NAME), SHORT_TIMEOUT); newEventWizardForm = DriverConfig.getDriver() .findElement(By.id(demandSideManagementConfig.get(EVENT_CREATE_FORM_NAME))); WaitUtil.waitUntil(5000); DriverConfig.setLogString("find event name field.", true); WebElement eventName = newEventWizardForm.findElement(By.id(demandSideManagementConfig.get(EVENT_NAME))); DriverConfig.setLogString("Enter event name." + inputEventName, true); eventName.sendKeys(inputEventName); DriverConfig.setLogString("find event description field & send values to it.", true); newEventWizardForm.findElement(By.tagName(TAG_TEXTAREA)).sendKeys(inputEventDesc); DriverConfig.setLogString("Event Name provided :" + inputEventName, true); DriverConfig.setLogString("Event Desc provided :" + inputEventDesc, true); DriverConfig.setLogString("Event Start date provided :" + startDate, true); DriverConfig.setLogString("find start date field and enter start date.", true); newEventWizardForm.findElement(By.id(demandSideManagementConfig.get(START_TIME))).clear(); newEventWizardForm.findElement(By.id(demandSideManagementConfig.get(START_TIME))).sendKeys(startDate); roleManagement.clickDone(); DriverConfig.setLogString("find event duration field.", true); isFormDisplayedById(DriverConfig.getDriver(), newEventWizardForm, demandSideManagementConfig.get(EVENT_DURATION_ELEMENT), SHORT_TIMEOUT); DriverConfig.setLogString("select duration.", true); selectOptionByValue(newEventWizardForm, demandSideManagementConfig.get(EVENT_DURATION_ELEMENT), duration); DriverConfig.setLogString("Event Duration provided :" + duration + " minutes.", true); WaitUtil.waitUntil(1000); WebElement precoolOption = newEventWizardForm.findElement(By.id(demandSideManagementConfig.get(PRECOOL))); newEventWizardForm.findElement(By.id(demandSideManagementConfig.get(EVENT_DURATION_ELEMENT))).click(); DriverConfig.setLogString("select precool option if needed.", true); WaitUtil.waitUntil(SHORT_TIMEOUT); if (precoolOpted) { isFormElementClickableById(DriverConfig.getDriver(), demandSideManagementConfig.get(PRECOOL), MEDIUM_TIMEOUT); if (precoolOption.isSelected() == false) precoolOption.click(); } smallWait(); // DriverConfig.setLogString("Unselect the group for event.", true); // select groups WebElement selectGroupsForm = DriverConfig.getDriver() .findElement(By.id(demandSideManagementConfig.get(POPUP_FORM))); if (groupName != null) { DriverConfig.setLogString("select groups for event." + groupName, true); retrieveElementByAttributeValueByPassingElement(DriverConfig.getDriver(), selectGroupsForm, TAG_SPAN, ATTR_CLASS, demandSideManagementConfig.get(SELECT_GROUPS_CHECKBOX)).click(); WebElement groupsTableElement = retrieveElementByAttributeValueByPassingElement( DriverConfig.getDriver(), selectGroupsForm, TAG_TBODY, ATTR_ID, demandSideManagementConfig.get(GROUP_LIST_TABLE)); List<WebElement> groupRows = groupsTableElement.findElements(By.tagName("tr")); for (WebElement element : groupRows) { List<WebElement> groupColumns = element.findElements(By.tagName("td")); if (!groupColumns.isEmpty()) { WebElement checkBoxElement = groupColumns.get(0).findElement(By.tagName(TAG_INPUT)); WebElement groupNameElement = groupColumns.get(1); if (groupNameElement.findElement(By.tagName(TAG_DIV)).getText().equalsIgnoreCase(groupName)) // select the group name check box checkBoxElement.click(); } } } // End Select groups DriverConfig.setLogString("Mode " + mode, true); smallWait(); isFormDisplayedById(DriverConfig.getDriver(), newEventWizardForm, demandSideManagementConfig.get(EVENT_SAVE_BTN), MEDIUM_TIMEOUT); if (mode.equalsIgnoreCase(demandSideManagementConfig.get(EVENT_TYPE_DRAFT))) { WaitUtil.waitUntil(SHORT_TIMEOUT); DriverConfig.setLogString("click draft button.", true); newEventWizardForm.findElement(By.id(demandSideManagementConfig.get(EVENT_SAVE_BTN))).click(); } else if (mode.equalsIgnoreCase(demandSideManagementConfig.get(EVENT_TYPE_SCHEDULED))) { WaitUtil.waitUntil(SHORT_TIMEOUT); DriverConfig.setLogString("click schedule button.", true); newEventWizardForm.findElement(By.id(demandSideManagementConfig.get(EVENT_SCHEDULED_BTN))).click(); } else { smallWait(); DriverConfig.setLogString("click cancel button.", true); newEventWizardForm.findElement(By.id(demandSideManagementConfig.get(EVENT_CANCEL_BTN))).click(); } return inputEventName; }
From source file:com.ecofactor.qa.automation.newapp.MobileTest.java
License:Open Source License
/** * Perform tstat operations./* w ww .j a v a 2 s .c o m*/ * @throws Exception the exception */ @SuppressWarnings("unused") private void performTstatOperations() throws Exception { DriverConfig.setLogString("Click mode", true); WebElement mode = mobileOps.getDeviceDriver().findElement(By.id("forLoc0mode0")); mobileUIAction.click(mode); smallWait(); DriverConfig.setLogString("Change the mode", true); WebElement radioCool = mobileOps.getDeviceDriver() .findElement(By.xpath("//*[@id='forLoc0hvacRadioBtn20']/div/input")); if (radioCool.isSelected()) { DriverConfig.setLogString("Click Heat", true); WebElement heat = mobileOps.getDeviceDriver() .findElement(By.xpath("//*[@id='forLoc0hvacRadioBtn10']/div/label")); mobileUIAction.click(heat); } else { DriverConfig.setLogString("Click Cool", true); WebElement cool = mobileOps.getDeviceDriver() .findElement(By.xpath("//*[@id='forLoc0hvacRadioBtn20']/div/label")); mobileUIAction.click(cool); } mediumWait(); mobileUIAction.click(mode); smallWait(); DriverConfig.setLogString("Change temperature", true); WebElement arrow_up = mobileOps.getDeviceDriver().findElement(By.id("forLoc0arrow0_up")); mobileUIAction.click(arrow_up); mobileUIAction.click(arrow_up); mediumWait(); }
From source file:com.ecofactor.qa.automation.newapp.page.impl.LoginPageImpl.java
License:Open Source License
/** * validates the check box is clicked or not of remember Mail. * @see com.ecofactor.qa.automation.newapp.page.LoginPage#clickRememberEvent(java.lang.String, * java.lang.String)/*from w w w . j a v a2s .c o m*/ */ @Override public void clickRememberEvent() { WebElement checkElement = getElement(getDriver(), By.name(CHECKBOX_NAME), MEDIUM_TIMEOUT); if (!checkElement.isSelected()) { LogUtil.setLogString("Click Remember Mail", true); getAction().click(checkElement); WaitUtil.tinyWait(); getAction().rejectAlert(); } else if ((checkElement.getAttribute("checked")) != null) { LogUtil.setLogString("UnCheck if Remember Mail Clicked already!", true); getAction().click(checkElement); WaitUtil.tinyWait(); /* getAction().rejectAlert(); */ if (!checkElement.isSelected()) { LogUtil.setLogString("Click Remember Mail", true); getAction().click(checkElement); WaitUtil.tinyWait(); getAction().rejectAlert(); } } }
From source file:com.elastica.webelements.SelectList.java
License:Apache License
/** * De-selects all options in a multi-select list element. */// w w w .j a va 2 s .c o m public void deselectAll() { TestLogging.logWebStep(null, "deselect all options on " + toHTML(), false); findElement(); if (!isMultiple()) { throw new UnsupportedOperationException("You may only deselect all options of a multi-select"); } for (WebElement option : options) { if (option.isSelected()) { option.click(); } } }
From source file:com.elastica.webelements.SelectList.java
License:Apache License
public void deselectByIndex(final int index) { TestLogging.logWebStep(null, "deselect index\"" + index + "\" on " + toHTML(), false); findElement();//www . j a va2 s . com WebElement option = options.get(index); if (option.isSelected()) { option.click(); } }
From source file:com.elastica.webelements.SelectList.java
License:Apache License
public void deselectByText(final String text) { TestLogging.logWebStep(null, "deselect text\"" + text + "\" on " + toHTML(), false); findElement();/* www . j av a 2s . c o m*/ for (WebElement option : options) { if (option.getAttribute("text").equals(text)) { if (option.isSelected()) { option.click(); } break; } } }
From source file:com.elastica.webelements.SelectList.java
License:Apache License
public void deselectByValue(final String value) { TestLogging.logWebStep(null, "deselect value\"" + value + "\" on " + toHTML(), false); findElement();/* w w w.java 2 s . c om*/ for (WebElement option : options) { if (option.getAttribute("value").equals(value)) { if (option.isSelected()) { option.click(); } break; } } }