List of usage examples for org.openqa.selenium WebElement getAttribute
String getAttribute(String name);
From source file:com.ecofactor.qa.automation.newapp.page.impl.LocationSwitcherUIPageImpl.java
License:Open Source License
/** * Gets the tstat id for location.//from ww w. j a va 2 s. c om * @param locId the loc id * @return the tstat id for location * @see com.ecofactor.qa.automation.newapp.page.LocationSwitcherUIPage#getTstatIdForLocation(java.lang.Integer) */ @Override public List<Integer> getTstatIdForLocation(final Integer locId) { LogUtil.setLogString("Get Thermostat Id for location id :" + locId, true, CustomLogLevel.LOW); final WebElement thermostatSwitcherContainer = getElement(getDriver(), By.className(THERMOSTAT_SWITCHER_CONTAINER), SHORT_TIMEOUT); final List<WebElement> tstatName = getElementsBySubElement(getDriver(), thermostatSwitcherContainer, By.cssSelector(THERMOSTAT_ROW), SHORT_TIMEOUT); final List<Integer> tstatIdList = new ArrayList<Integer>(); for (final WebElement element1 : tstatName) { final String locId1 = element1.getAttribute(LOCATION_ID); if (locId1.equalsIgnoreCase(String.valueOf(locId))) { final Integer tstatId = Integer.valueOf(element1.getAttribute(THERMOSTAT_ID)); tstatIdList.add(tstatId); } } return tstatIdList; }
From source file:com.ecofactor.qa.automation.newapp.page.impl.LocationSwitcherUIPageImpl.java
License:Open Source License
/** * Gets the mode by tstat id./*from w ww .j a va 2s . com*/ * @param tstatId the tstat id * @return the mode by tstat id * @see com.ecofactor.qa.automation.newapp.page.LocationSwitcherUIPage#getModeByTstatId(Integer) */ @Override public String getModeByTstatId(final Integer tstatId) { LogUtil.setLogString("Get Mode for thermostat :" + tstatId, true, CustomLogLevel.LOW); final WebElement tstatElement = getElementByAttr(getDriver(), By.cssSelector(THERMOSTAT_ROW), THERMOSTAT_ID, tstatId.toString(), SHORT_TIMEOUT); String className = tstatElement.getAttribute(CLASS); Object val = null; if (className != null && className.contains(" ")) { int spaceIndex = className.lastIndexOf(" "); className = className.substring(spaceIndex, className.length()); LogUtil.setLogString("Get the icon displayed for thermostat " + tstatId, true, CustomLogLevel.LOW); val = executeScriptByClassName(className, BACKGROUND_IMG, getDriver()); LogUtil.setLogString("Icon Displayed " + val.toString(), true, CustomLogLevel.LOW); } else { val = executeScriptByClassName(className, BACKGROUND_IMG, getDriver()); if (val == null) { val = ""; } LogUtil.setLogString("Icon Displayed " + val.toString(), true, CustomLogLevel.LOW); } return getMode(val.toString()); }
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)/* w ww .jav a 2s .c om*/ */ @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.ecofactor.qa.automation.newapp.page.impl.SetAwayPageImpl.java
License:Open Source License
/** * Sets the away param picker./* w w w. j a va 2s . c om*/ * @param setAwayParams the set away params * @param expectedValue the expected value * @return true, if successful * @see com.ecofactor.qa.automation.newapp.page.SetAwayPage#setAwayParamPicker(com.ecofactor.qa.automation.newapp.enums.SetAwayParams, * int) */ @Override public boolean setAwayParamPicker(final SetAwayParams setAwayParams, final int expectedValue) { setLogString("Set " + setAwayParams + " as :" + expectedValue, true); Assert.assertTrue(clickAwayParamPicker(setAwayParams), setAwayParams + " picker not displayed."); final WebElement currentReadingElement = getElement(getDriver(), By.cssSelector(CURRENT_VALUE), TINY_TIMEOUT); final int currentReadingValue = Integer.parseInt(currentReadingElement.getAttribute(DATA_VALUE)); final int setPointValue = currentReadingValue > expectedValue ? -(currentReadingValue - expectedValue) : expectedValue - currentReadingValue; return changeAwayParamValue(setAwayParams, setPointValue).equals(expectedValue); }
From source file:com.ecofactor.qa.automation.newapp.page.impl.SetAwayPageImpl.java
License:Open Source License
/** * Sets the away date./*from ww w . j a v a 2 s .c om*/ * @param reqDateTime the new away date * @return true, if successful */ @Override public boolean setAwayDate(final Calendar reqDateTime) { SimpleDateFormat enddateFormat = new SimpleDateFormat("E - MMM dd, YYYY"); enddateFormat.setTimeZone(enddateFormat.getTimeZone()); String enddate = enddateFormat.format(reqDateTime.getTime()); setLogString("Set away date as :" + enddate, true, CustomLogLevel.MEDIUM); Assert.assertTrue(clickAwayParamPicker(SetAwayParams.Days), SetAwayParams.Days + " picker not displayed."); final WebElement dateContainerElement = getElement(getDriver(), By.cssSelector("div.dwwl.dwwl1"), TINY_TIMEOUT); final WebElement monthContainerElement = getElement(getDriver(), By.cssSelector("div.dwwl.dwwl0"), TINY_TIMEOUT); final WebElement yearContainerElement = getElement(getDriver(), By.cssSelector("div.dwwl.dwwl2"), TINY_TIMEOUT); boolean dateUpdated = true; final WebElement dateCurrentReadingElement = getElementBySubElement(getDriver(), dateContainerElement, By.cssSelector(CURRENT_VALUE), TINY_TIMEOUT); int currentReadingValue = Integer.parseInt(dateCurrentReadingElement.getAttribute(DATA_VALUE)); int expectedValue = reqDateTime.get(Calendar.DATE); int setPointValue = currentReadingValue > expectedValue ? -(currentReadingValue - expectedValue) : expectedValue - currentReadingValue; dateUpdated = dateUpdated && changeRequiredParameter(dateContainerElement, setPointValue, reqDateTime.get(Calendar.DATE)); final WebElement monthCurrentReadingElement = getElementBySubElement(getDriver(), monthContainerElement, By.cssSelector(CURRENT_VALUE), TINY_TIMEOUT); currentReadingValue = Integer.parseInt(monthCurrentReadingElement.getAttribute(DATA_VALUE)); expectedValue = reqDateTime.get(Calendar.MONTH); setPointValue = currentReadingValue > expectedValue ? -(currentReadingValue - expectedValue) : expectedValue - currentReadingValue; dateUpdated = dateUpdated && changeRequiredParameter(monthContainerElement, setPointValue, reqDateTime.get(Calendar.MONTH)); final WebElement yearCurrentReadingElement = getElementBySubElement(getDriver(), yearContainerElement, By.cssSelector(CURRENT_VALUE), TINY_TIMEOUT); currentReadingValue = Integer.parseInt(yearCurrentReadingElement.getAttribute(DATA_VALUE)); expectedValue = reqDateTime.get(Calendar.YEAR); setPointValue = currentReadingValue > expectedValue ? -(currentReadingValue - expectedValue) : expectedValue - currentReadingValue; dateUpdated = dateUpdated && changeRequiredParameter(yearContainerElement, setPointValue, reqDateTime.get(Calendar.YEAR)); saveAwaySettings(); return dateUpdated; }
From source file:com.ecofactor.qa.automation.newapp.page.impl.SetAwayPageImpl.java
License:Open Source License
/** * Sets the away time./*from www .j a v a 2 s . c o m*/ * @param reqDateTime the new away time * @return true, if successful */ @Override public boolean setAwayTime(final Calendar reqDateTime) { SimpleDateFormat endtimeFormat = new SimpleDateFormat("HH:MM a Z"); endtimeFormat.setTimeZone(endtimeFormat.getTimeZone()); String endtime = endtimeFormat.format(reqDateTime.getTime()); setLogString("Set away time as :" + endtime, true, CustomLogLevel.MEDIUM); boolean timeUpdated = true; Assert.assertTrue(clickAwayParamPicker(SetAwayParams.Hours), SetAwayParams.Hours + " picker not displayed."); final WebElement hourContainerElement = getElement(getDriver(), By.cssSelector("div.dwwl.dwwl0"), TINY_TIMEOUT); final WebElement minuteContainerElement = getElement(getDriver(), By.cssSelector("div.dwwl.dwwl1"), TINY_TIMEOUT); final WebElement ampmContainerElement = getElement(getDriver(), By.cssSelector("div.dwwl.dwwl2"), TINY_TIMEOUT); final WebElement hourCurrentReadingElement = getElementBySubElement(getDriver(), hourContainerElement, By.cssSelector(CURRENT_VALUE), TINY_TIMEOUT); int currentReadingValue = Integer.parseInt(hourCurrentReadingElement.getAttribute(DATA_VALUE)); int expectedValue = reqDateTime.get(Calendar.HOUR); int setPointValue = currentReadingValue > expectedValue ? -(currentReadingValue - expectedValue) : expectedValue - currentReadingValue; timeUpdated = timeUpdated && changeRequiredParameter(hourContainerElement, setPointValue, reqDateTime.get(Calendar.HOUR)); final WebElement minuteCurrentReadingElement = getElementBySubElement(getDriver(), minuteContainerElement, By.cssSelector(CURRENT_VALUE), TINY_TIMEOUT); currentReadingValue = Integer.parseInt(minuteCurrentReadingElement.getAttribute(DATA_VALUE)); expectedValue = reqDateTime.get(Calendar.MINUTE); setPointValue = currentReadingValue > expectedValue ? -(currentReadingValue - expectedValue) : expectedValue - currentReadingValue; timeUpdated = timeUpdated && changeRequiredParameter(minuteContainerElement, setPointValue, reqDateTime.get(Calendar.MINUTE)); final WebElement ampmCurrentReadingElement = getElementBySubElement(getDriver(), ampmContainerElement, By.cssSelector(CURRENT_VALUE), TINY_TIMEOUT); currentReadingValue = Integer.parseInt(ampmCurrentReadingElement.getAttribute(DATA_VALUE)); expectedValue = reqDateTime.get(Calendar.AM_PM); setPointValue = currentReadingValue > expectedValue ? -(currentReadingValue - expectedValue) : expectedValue - currentReadingValue; timeUpdated = timeUpdated && changeRequiredParameter(ampmContainerElement, setPointValue, reqDateTime.get(Calendar.AM_PM)); saveAwaySettings(); return timeUpdated; }
From source file:com.ecofactor.qa.automation.newapp.page.impl.SetAwayPageImpl.java
License:Open Source License
/** * Change required parameter.//w ww.ja va2s.c o m * @param containerElement the container element * @param noOfSetPoints the no of set points * @param expectedValue the expected value * @return true, if successful */ private boolean changeRequiredParameter(final WebElement containerElement, final int noOfSetPoints, final int expectedValue) { final int setPoints = Math.abs(noOfSetPoints); final WebElement upOrDownArrow = expectedValue > 0 ? getElementBySubElement(getDriver(), containerElement, By.cssSelector("a.dwb-e.dwwb.dwwbm"), SHORT_TIMEOUT) : getElementBySubElement(getDriver(), containerElement, By.cssSelector("a.dwb-e.dwwb.dwwbp"), SHORT_TIMEOUT); for (int count = 0; count < setPoints; count++) { getAction().click(upOrDownArrow); } final WebElement currentReadingElement = getElementBySubElement(getDriver(), containerElement, By.cssSelector(CURRENT_VALUE), TINY_TIMEOUT); final Integer currentReadingValue = Integer.parseInt(currentReadingElement.getAttribute(DATA_VALUE)); return currentReadingValue.equals(expectedValue); }
From source file:com.ecofactor.qa.automation.newapp.page.impl.SettingsPageImpl.java
License:Open Source License
/** * Tst sorting./*w w w .j av a2 s . c o m*/ * @see com.ecofactor.qa.automation.newapp.page.SettingsPage#verifyTstNames() */ @Override public void verifyTstNames() { setLogString("verify Thermostat names", true, CustomLogLevel.LOW); final WebElement tstNameOne = retrieveElementByAttributeValue(getDriver(), TAG_NAME, ATTRIBUTE_TST, TST_1); final WebElement tstNameTwo = retrieveElementByAttributeValue(getDriver(), TAG_NAME, ATTRIBUTE_TST, TST_2); setLogString("Thermostat names:" + tstNameOne.getAttribute(ATTRIBUTE_VALUE) + " " + tstNameTwo.getAttribute(ATTRIBUTE_VALUE), true, CustomLogLevel.LOW); }
From source file:com.ecofactor.qa.automation.newapp.page.impl.ThermostatPageUIImpl.java
License:Open Source License
/** * Gets the temperature content by position. * @param position the position/*from www .j a va 2 s .c o m*/ * @return the temperature content by position * @see com.ecofactor.qa.automation.mobile.page.ThermostatPage#getTemperatureContentByPosition(java.lang.String) */ @Override public String getTemperatureContentByPosition(String position) { final WebElement tempDifferenceContainer = getElement(getDriver(), By.className("temperatureDiffContainer"), TINY_TIMEOUT); final List<WebElement> divElements = getElementsBySubElement(getDriver(), tempDifferenceContainer, By.tagName("div"), TINY_TIMEOUT); WebElement requiredContainer = null; for (final WebElement element : divElements) { if (element.getAttribute("class").startsWith(position)) { requiredContainer = element; break; } } WebElement temperatureInfo = getElementBySubElementText(getDriver(), requiredContainer, By.tagName(TAG_DIV), "INSIDE", SHORT_TIMEOUT); temperatureInfo = (temperatureInfo != null) ? temperatureInfo : getElementBySubElementText(getDriver(), requiredContainer, By.tagName(TAG_DIV), "TARGET", SHORT_TIMEOUT); return temperatureInfo.getText(); }
From source file:com.ecofactor.qa.automation.newapp.page.impl.ThermostatPageUIImpl.java
License:Open Source License
/** * Checks if is temp position relative./*from w ww .j ava 2s . com*/ * @param currentTemp the current temp * @param targetTemp the target temp * @return true, if is temp position relative * @see com.ecofactor.qa.automation.newapp.page.ThermostatPage#isTempPositionRelative(int, int) */ @Override public boolean isTempPositionRelative(int currentTemp, int targetTemp) { boolean relative = false; final WebElement currentTempElement = getElement(getDriver(), By.cssSelector("div[class*='" + LEFT_TEMP_DIFF + "']"), TINY_TIMEOUT); final WebElement targetTempElement = getElement(getDriver(), By.cssSelector("div[class*='" + RIGHT_TEMP_DIFF + "']"), TINY_TIMEOUT); setLogString("Current temperature now :" + currentTempElement.getAttribute("className"), true, CustomLogLevel.HIGH); setLogString("Target temperature now :" + targetTempElement.getAttribute("className"), true, CustomLogLevel.HIGH); final String currentposition = currentTempElement.getAttribute("className"); final String targetposition = targetTempElement.getAttribute("className"); if (currentTemp > targetTemp) { relative = (currentposition.contains(TOP_POSITION) && targetposition.contains(BOTTOM_POSITION)) ? true : false; } else if (targetTemp > currentTemp) { relative = (currentposition.contains(BOTTOM_POSITION) && targetposition.contains(TOP_POSITION)) ? true : false; } else { relative = (currentposition.contains(NEUTRAL_POSITION) && targetposition.contains(NEUTRAL_POSITION)) ? true : false; } return relative; }