List of usage examples for org.openqa.selenium WebElement getAttribute
String getAttribute(String name);
From source file:com.ecofactor.qa.automation.insite.page.DemandSideManagementImpl.java
License:Open Source License
/** * iterateAndClickParticularProgram Iterate the Pagination and click on * particular program, if it was found.// w w w . j a v a 2 s .c om * * @param programeName * the programe name */ public void iterateAndClickParticularProgram(final String programeName) { DriverConfig.setLogString("Iterate the program list and click on specified program.", true); // WaitUtil.waitUntil(30000); WaitUtil.waitUntil(20000); logger.info("check if program list form displayed."); formElement = DriverConfig.getDriver() .findElement(By.id(demandSideManagementConfig.get(PROGRAM_LIST_FORM))); isDisplayedById(DriverConfig.getDriver(), demandSideManagementConfig.get(PROGRAM_LIST_FORM), LONG_TIMEOUT); List<WebElement> lastPageDisabledState = retrieveElementsByAttributeValueList(DriverConfig.getDriver(), TAG_SPAN, ATTR_CLASS, demandSideManagementConfig.get(LAST_PAGE_DISABLED)); logger.info("check if program pagination element displayed."); if (formElement.findElements(By.id(demandSideManagementConfig.get(PROGRAM_PAGINATION_BOTTOM_ELEMENT))) .size() > 0 && lastPageDisabledState.size() == 0) { isFormDisplayedById(DriverConfig.getDriver(), formElement, demandSideManagementConfig.get(PROGRAM_PAGINATION_BOTTOM_ELEMENT), SHORT_TIMEOUT); WebElement paginationBottomElement = formElement .findElement(By.id(demandSideManagementConfig.get(PROGRAM_PAGINATION_BOTTOM_ELEMENT))); logger.info("check if last page button displayed."); List<WebElement> paginationElements = paginationBottomElement.findElements(By.tagName(TAG_SPAN)); for (WebElement items : paginationElements) { if (items.getAttribute(ATTR_CLASS).equalsIgnoreCase(demandSideManagementConfig.get(LAST_PAGE_ICON)) || items.getAttribute(ATTR_CLASS) .equalsIgnoreCase(demandSideManagementConfig.get(LAST_PAGE_WITHOUT_HOVER))) { logger.info("select last page."); items.click(); logger.info("Last page is clicked." + items.getAttribute(ATTR_CLASS)); break; } } retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_SPAN, ATTR_CLASS, demandSideManagementConfig.get(LAST_PAGE_DISABLED)); WebElement programIndexElement = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_TD, ATTR_ID, demandSideManagementConfig.get(PROGRAM_PAGINATION_BOTTOM_ELEMENT)); if (programIndexElement != null) { WebElement pageIndexElement = formElement .findElement(By.id(demandSideManagementConfig.get(PROGRAM_PAGINATION_BOTTOM_ELEMENT))); List<WebElement> pageIndexes = pageIndexElement.findElements(By.tagName(TAG_SPAN)); previousPageElement = pageIndexes.get(pageIndexes.size() - 4); iterateProgramList(programeName); } } else { logger.info("There are no multiple pages available. Select from the default page."); WebElement programElement = retrieveElementByTagTextForSubElement(DriverConfig.getDriver(), formElement, TAG_ANCHOR, programeName); if (programElement != null) { smallWait(); DriverConfig.setLogString("click the program element.", true); programElement.click(); programfound = true; } } if (programfound == false) { DriverConfig.setLogString("Load shapping program '" + programeName + "' not found.", true); } }
From source file:com.ecofactor.qa.automation.insite.page.DemandSideManagementImpl.java
License:Open Source License
/** * Completed event status view.// w w w . j a v a2 s . com * * @param programName * the program name * @return the load shaping event report * @throws ParseException * the parse exception */ public LoadShapingEventReport completedEventStatusView(final String programName) throws ParseException { List<String> eventReport = new ArrayList<String>(); pickGivenProgram(programName); loadPageFrame(); logger.info("check if event list form is available.", true); isDisplayedById(DriverConfig.getDriver(), "form", SHORT_TIMEOUT); formElement = DriverConfig.getDriver().findElement(By.id("form")); logger.info("check if event status filter is available.", true); isDisplayedById(DriverConfig.getDriver(), demandSideManagementConfig.get(EVENT_STATUS_FILTER), SHORT_TIMEOUT); WebElement select = formElement.findElement(By.id(demandSideManagementConfig.get(EVENT_STATUS_FILTER))); List<WebElement> options = select.findElements(By.tagName("option")); for (WebElement option : options) { if (option.getAttribute("value").contains(Status.COMPLETED.toString())) { selectOptionByText(formElement, demandSideManagementConfig.get(EVENT_STATUS_FILTER), option.getText()); WaitUtil.waitUntil(2000); List<WebElement> listedEventStatus = retrieveElementsByAttributeValueList(DriverConfig.getDriver(), TAG_ANCHOR, ATTR_CLASS, demandSideManagementConfig.get(EVENT_STATUS_LINK_CLASS)); logger.info("size:" + listedEventStatus.size()); for (WebElement listItem : listedEventStatus) { WaitUtil.waitUntil(1000); // DriverConfig.setLogString("listItem " + // listItem.getAttribute(ATTR_ID)); if (listItem.getText().equalsIgnoreCase(Status.COMPLETED.toString())) { listItem.click(); WaitUtil.waitUntil(1000); WebElement spanForm = DriverConfig.getDriver() .findElement(By.id(demandSideManagementConfig.get(REPORT_DISPLAY_FORM))); WaitUtil.waitUntil(1000); List<WebElement> labelElements = spanForm.findElements(By.tagName("label")); for (WebElement labels : labelElements) { logger.info("Labels: " + labels.getText().toString()); eventReport.add(labels.getText()); } break; } } } } Iterator<String> iterator = eventReport.iterator(); Calendar rDate = Calendar.getInstance(); while (iterator.hasNext()) { // PROGRAM,EVENT,EVENT_PERIOD,EVENT_STATUS ,LOCATIONS_TARGETED, // LOCATIONS_PARTICIPATED formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm a"); String labelText = iterator.next(); String labelValue = null; logger.info("Label text: " + labelText); if (labelText.equalsIgnoreCase(demandSideManagementConfig.get(PROGRAM))) { labelValue = iterator.next(); lsEventReportUI.getLoadShapingEvent().getEcpCoreLSProgram().setName(labelValue); } else if (labelText.equalsIgnoreCase(demandSideManagementConfig.get(EVENT))) { labelValue = iterator.next(); lsEventReportUI.getLoadShapingEvent().setName(labelValue); } else if (labelText.equalsIgnoreCase(demandSideManagementConfig.get(LOCATIONS_TARGETED))) { labelValue = iterator.next(); lsEventReportUI.setNumExpectedLocations(Integer.parseInt(labelValue)); } else if (labelText.equalsIgnoreCase(demandSideManagementConfig.get(LOCATIONS_PARTICIPATED))) { labelValue = iterator.next(); lsEventReportUI.setNumActualLocations(Integer.parseInt(labelValue)); } else if (labelText.equalsIgnoreCase(demandSideManagementConfig.get(EVENT_STATUS))) { labelValue = iterator.next(); lsEventReportUI.getLoadShapingEvent().setStatus(Status.valueOf(labelValue)); } else if (labelText.equalsIgnoreCase(demandSideManagementConfig.get(EVENT_PERIOD))) { labelValue = iterator.next(); rDate.setTime(formatter.parse(labelValue.trim())); lsEventReportUI.getLoadShapingEvent().setStartDate(rDate); labelValue = iterator.next(); String endTimePart = labelValue.trim(); rDate.set(Calendar.HOUR, Integer.parseInt(endTimePart.split(":")[0])); rDate.set(Calendar.MINUTE, Integer.parseInt(endTimePart.substring(endTimePart.indexOf(":") + 1, 5))); if (endTimePart.substring(endTimePart.indexOf(" ") + 1, 8).equalsIgnoreCase("AM")) { rDate.set(Calendar.AM, 1); } else { rDate.set(Calendar.PM, 1); } lsEventReport.getLoadShapingEvent().setEndDate(rDate); /* * rDate.setTime(formatter.parse(iterator.next().split("-")[1])); * lsEventReport.getLoadShapingEvent().setEndDate(rDate); * rDate.setTimeZone(TimeZone. * getTimeZone(lsEventReportUI.getLoadShapingEvent * ().getTimeZone())); */ } } return lsEventReportUI; }
From source file:com.ecofactor.qa.automation.insite.page.DemandSideManagementImpl.java
License:Open Source License
/** * Gets the program id for the displayed LS program dfrom the UI. * /*w ww . j a va 2s. c o m*/ * @param programName * the program name * @return the program id from ui * @throws ParseException * the parse exception */ public int getProgramIdFromUI(String programName) throws ParseException { DriverConfig.getDriver().switchTo().defaultContent(); pickGivenProgram(programName); formElement = DriverConfig.getDriver().findElement(By.id("form")); WebElement programId = formElement.findElement(By.id(demandSideManagementConfig.get(PROGRAM_ID_FIELDS_ID))); lsProgramId = Integer.parseInt(programId.getAttribute(ATTR_VALUE)); logger.info("programid: " + programId.getAttribute(ATTR_VALUE)); lsProgramId = Integer.parseInt(programId.getAttribute(ATTR_VALUE)); DriverConfig.getDriver().switchTo().defaultContent(); return lsProgramId; }
From source file:com.ecofactor.qa.automation.insite.page.DemandSideManagementImpl.java
License:Open Source License
/** * Gets the next program button./*w w w.j a va2 s . c om*/ * * @return the next program button */ private boolean getNextProgramButton() { DriverConfig.setLogString("click next page element.", true); boolean nextpageFound = false; WebElement paginationBottom = formElement .findElement(By.id(demandSideManagementConfig.get(PROGRAM_PAGINATION_BOTTOM_ELEMENT))); List<WebElement> pageLists = paginationBottom.findElements(By.tagName(TAG_SPAN)); WebElement nextpage = pageLists.get(8); String classDisplayed = nextpage.getAttribute("class"); logger.info(DISABLED_CLASS + " : nextpage.getAttribute(class): " + classDisplayed, true); nextpageFound = classDisplayed.endsWith(demandSideManagementConfig.get(DISABLED_CLASS)) ? true : false; if (nextpageFound == false) { logger.info(nextpage.isEnabled() + "next page found!"); nextpage.click(); DriverConfig.setLogString("next page clicked!", true); } return !nextpageFound; }
From source file:com.ecofactor.qa.automation.insite.page.InstallationHardwareImpl.java
License:Open Source License
/** * Check the 1st step Look Up address./* ww w . java2 s. c om*/ * @param streetAddressValue the street address value */ public void checkLookUpAddress(final String streetAddressValue) { DriverConfig.setLogString("Select Wizard 1 : LookUp Address", true); logger.info("check if street address is displayed."); isDisplayedById(DriverConfig.getDriver(), installationConfig.get(STREET_ADDRESS), MEDIUM_TIMEOUT); DriverConfig.setLogString("send values to street address." + streetAddressValue, true); DriverConfig.getDriver().findElement(By.id("ef_street_address")).sendKeys(streetAddressValue); mediumWait(); DriverConfig.setLogString("Select the top 1st Value from the dropDown.", true); WebElement selectedElement = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_LI, ATTR_CLASS, installationConfig.get(STREET_DROP_DOWN_CLASS)); selectedElement.click(); largeWait(); DriverConfig.setLogString("check if ok button visible.", true); isEnabledById(DriverConfig.getDriver(), installationConfig.get(OK_BUTTON), MEDIUM_TIMEOUT); if (DriverConfig.getDriver().findElement(By.id(installationConfig.get(OK_BUTTON))).isEnabled()) { DriverConfig.setLogString("Click on View Account", true); DriverConfig.getDriver().findElement(By.id(installationConfig.get(OK_BUTTON))).click(); smallWait(); } DriverConfig.setLogString("Check the HVAC System and Network Availability...", true); List<WebElement> networkAvailabilityList = DriverConfig.getDriver() .findElements(By.id(installationConfig.get(INTERNET_QUESTION))); for (WebElement webElement : networkAvailabilityList) { if (webElement.getAttribute(ATTR_VALUE).equalsIgnoreCase("4")) { DriverConfig.setLogString("Click on Working Properly..", true); webElement.click(); smallWait(); break; } } smallWait(); DriverConfig.setLogString("find and click on Continue button", true); isDisplayedById(DriverConfig.getDriver(), installationConfig.get(START_INSTALLATION), MEDIUM_TIMEOUT); DriverConfig.getDriver().findElement(By.id(installationConfig.get(START_INSTALLATION))).click(); }
From source file:com.ecofactor.qa.automation.insite.page.InstallationHardwareImpl.java
License:Open Source License
/** * Save thermostat name.//from w w w . ja va 2 s . c o m * @param thermostatName the thermostat name * @see com.ecofactor.qa.automation.insite.page.InstallationHardware#saveThermostatName(java.lang.String) */ @Override public void saveThermostatName(String thermostatName) { DriverConfig.setLogString("Provide name to existig thermostat.", true); smallWait(); WebElement tblHomeProfile = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_TABLE, ATTR_ID, "homeProfile"); logger.info("tblHomeProfile: " + tblHomeProfile.getAttribute("class")); WebElement hiddenElement = retrieveElementByAttributeValueByPassingElement(DriverConfig.getDriver(), tblHomeProfile, "input", "type", "hidden"); //ForSubElement(driver, tblHomeProfile, TAG_INPUT, "type", "hidden", SHORT_TIMEOUT); logger.info("Hidden value: " + hiddenElement.getAttribute("value")); String thermostatFld = hiddenElement.getAttribute("value"); DriverConfig.setLogString("Enter value for thermostat name as " + thermostatName + ".", true); WebElement fldThermostatName = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_INPUT, ATTR_ID, thermostatFld); fldThermostatName.clear(); fldThermostatName.sendKeys(thermostatName); DriverConfig.setLogString("Click link gateway", true); WebElement LinkGateWayBtn = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_INPUT, ATTR_ID, "nextStepButton"); LinkGateWayBtn.click(); smallWait(); }
From source file:com.ecofactor.qa.automation.insite.page.InstallationHardwareImpl.java
License:Open Source License
@Override public void addThermostat(String thermostatName) { smallWait();//w ww . j av a2 s . co m WebElement getAddressDiv = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_DIV, ATTR_ID, "getAddressDiv"); logger.info("getAddressDiv ID: " + getAddressDiv.getAttribute("id")); WebElement tblHomeProfile = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_TABLE, ATTR_ID, "homeProfile"); logger.info("tblHomeProfile: " + tblHomeProfile.getAttribute("class")); List<WebElement> newlyAddedTstats = retrieveElementsByContainsOfAttributeValue(DriverConfig.getDriver(), TAG_TD, ATTR_CLASS, "ef_dataTable toCountThermostats"); WebElement newlyAddedTstat = newlyAddedTstats.get(newlyAddedTstats.size() - 1); logger.info("Newly Added thermostat: " + newlyAddedTstat.getTagName(), true); DriverConfig.setLogString("Enter name for existing thermostat field as 'TestTstat'.", true); WebElement newTstatName = retrieveElementByAttributeValueByPassingElement(DriverConfig.getDriver(), newlyAddedTstat, TAG_INPUT, ATTR_TYPE, "text"); newTstatName.clear(); newTstatName.sendKeys("TestTstat"); tinyWait(); //click add link DriverConfig.setLogString("Click add thermostat link.", true); WebElement addThermostatElement = retrieveElementByAttributeValueByPassingElement(DriverConfig.getDriver(), getAddressDiv, TAG_ANCHOR, ATTR_ID, "addThermostat"); addThermostatElement.click(); tinyWait(); tblHomeProfile = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_TABLE, ATTR_ID, "homeProfile"); logger.info("tblHomeProfile: " + tblHomeProfile.getAttribute("class"), true); newlyAddedTstats = retrieveElementsByContainsOfAttributeValue(DriverConfig.getDriver(), TAG_TD, ATTR_CLASS, "ef_dataTable toCountThermostats"); newlyAddedTstat = newlyAddedTstats.get(newlyAddedTstats.size() - 1); logger.info("newlyAddedTstat: " + newlyAddedTstat.getTagName(), true); DriverConfig.setLogString("Enter name for newly added thermostat" + thermostatName + ".", true); WebElement newTstatNameFld = retrieveElementByAttributeValueByPassingElement(DriverConfig.getDriver(), newlyAddedTstat, TAG_INPUT, ATTR_TYPE, "text"); newTstatNameFld.sendKeys(thermostatName); DriverConfig.setLogString("Click link gateway", true); WebElement LinkGateWayBtn = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_INPUT, ATTR_ID, "nextStepButton"); LinkGateWayBtn.click(); tinyWait(); }
From source file:com.ecofactor.qa.automation.insite.page.InstallationHardwareImpl.java
License:Open Source License
/** * Verify thermostat name.// w w w. ja v a2 s . c o m * * @param thermostatName the thermostat name * @see com.ecofactor.qa.automation.insite.page.InstallationHardware#verifyThermostatName(java.lang.String) */ @Override public void verifyThermostatName(String thermostatName) { DriverConfig.setLogString("verify thermostat '" + thermostatName + "' exists.", true); smallWait(); WebElement tblHomeProfile = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_TABLE, ATTR_ID, "homeProfile"); logger.info("tblHomeProfile: " + tblHomeProfile.getAttribute("class")); WebElement hiddenElement = retrieveElementByAttributeValueByPassingElement(DriverConfig.getDriver(), tblHomeProfile, "input", "type", "hidden"); logger.info("Hidden value: " + hiddenElement.getAttribute("value"), true); String thermostatFld = hiddenElement.getAttribute("value"); WebElement fldThermostatName = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_INPUT, ATTR_ID, thermostatFld); Assert.assertTrue("Thermostat name is different", fldThermostatName.getAttribute("value").equalsIgnoreCase(thermostatName)); }
From source file:com.ecofactor.qa.automation.insite.page.InstallationHardwareImpl.java
License:Open Source License
@Override public String removeThermostat() { smallWait();// w w w .j a v a 2s.c om WebElement getAddressDiv = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_DIV, ATTR_ID, "getAddressDiv"); logger.info("remove getAddressDiv ID: " + getAddressDiv.getAttribute("id"), true); WebElement tblHomeProfile = retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_TABLE, ATTR_ID, "homeProfile"); logger.info("remove tblHomeProfile: " + tblHomeProfile.getAttribute("class"), true); //get thermostat name , which will be removed. List<WebElement> tagTDElements = retrieveElementsByContainsOfAttributeValue(DriverConfig.getDriver(), TAG_TD, ATTR_CLASS, "ef_dataTable toCountThermostats"); WebElement tstatTDElement = tagTDElements.get(tagTDElements.size() - 1); WebElement lastThermostatNameElement = retrieveElementByAttributeValueByPassingElement( DriverConfig.getDriver(), tstatTDElement, TAG_INPUT, ATTR_TYPE, "text"); String thermostatName = lastThermostatNameElement.getAttribute("value"); DriverConfig.setLogString("Thermostat to be removed: " + thermostatName, true); //select tstat to remove DriverConfig.setLogString("Select thermostat to remove.", true); smallWait(); //WebElement selectTstatCheckBox=retrieveElementByAttributeValue(DriverConfig.getDriver(), TAG_INPUT, ATTR_TYPE, "checkbox", LONG_TIMEOUT); WebElement selectTstatCheckBox = DriverConfig.getDriver() .findElement(By.cssSelector(installationConfig.get(CHECKBOX))); selectTstatCheckBox.click(); logger.info("CheckBox: " + selectTstatCheckBox.getAttribute("type"), true); //click remove link DriverConfig.setLogString("Click remove link.", true); WebElement removeThermostatLink = retrieveElementByAttributeValueByPassingElement(DriverConfig.getDriver(), getAddressDiv, TAG_ANCHOR, ATTR_ID, "delThermostat"); logger.info("Remove Link id: " + removeThermostatLink.getAttribute("id"), true); removeThermostatLink.click(); smallWait(); return thermostatName; }
From source file:com.ecofactor.qa.automation.insite.page.InstallationHardwareImpl.java
License:Open Source License
public void verifyNoThermostatWithName(String thermostatName) { DriverConfig.setLogString("Verify no thermostat with name '" + thermostatName + "' exists.", true); //get list of thermostats , iterate & check to verify the removed tstats dosen't exists. List<WebElement> tstatNames = retrieveElementsByContainsOfAttributeValue(DriverConfig.getDriver(), TAG_INPUT, ATTR_TYPE, "text"); for (WebElement tstat : tstatNames) { logger.info("Tstat names:" + tstat.getAttribute("value"), true); Assert.assertFalse("Thermostat name is different", tstat.getAttribute("value").equalsIgnoreCase(thermostatName)); }//w ww .j a va 2 s . c o m }