List of usage examples for org.openqa.selenium WebElement getAttribute
String getAttribute(String name);
From source file:com.easytox.automation.steps.LabClientImpl.java
@When("^Click 'Lock' icon for any existing user$") public void click_lock_icon_for_any_existing_user() { WebElement lock = MyWebDriverUtils.findElement(driver, LOCK_LOCATOR, LocatorType.CSS); if (lock != null && lock.getAttribute(ATTRIBUTE_CLASS_LOCATOR).equals(LOCK_VALUE)) { WebElement el = MyWebDriverUtils.findElement(driver, LOCK_ICON_LOCATOR, LocatorType.CSS); WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS); boolean flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID); if (flag) { checkAndClick(el);/* ww w.j ava 2s.c o m*/ } else { Assert.fail("flag is false!"); } } WebElement el = MyWebDriverUtils.findElement(driver, LOCK_ICON_LOCATOR, LocatorType.CSS); WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS); boolean flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID); if (flag) { checkAndClick(el); } else { Assert.fail("flag is false!"); } }
From source file:com.easytox.automation.steps.LabClientImpl.java
@Then("^User should be locked and 'User locked successfully' message should be populated$") public void user_should_be_locked() { WebElement widget = MyWebDriverUtils.findPresenceElement(driver, SUCCESS_LOCATOR, LocatorType.CSS); if (widget != null) { String title = widget.getText(); Assert.assertEquals(title, SUCCESS_VALUE); }/* w w w. j a v a 2s.c om*/ WebElement el = MyWebDriverUtils.findElement(driver, MESSAGE_LOCATOR, LocatorType.CSS); if (el != null) { Assert.assertEquals(el.getText(), MESSAGE_VALUE); } WebElement lock = MyWebDriverUtils.findElement(driver, LOCK_LOCATOR, LocatorType.CSS); if (lock != null) { Assert.assertEquals(lock.getAttribute(ATTRIBUTE_CLASS_LOCATOR), LOCK_VALUE); } }
From source file:com.easytox.automation.steps.LabClientImpl.java
@Then("^Notes for lab client should be saved successfully along with date stamp$") public void check_saved_notes() { String currentUrl = driver.getCurrentUrl(); Assert.assertEquals(currentUrl, UPDATE_NOTES_URL); WebElement widget = MyWebDriverUtils.findPresenceElement(driver, MESSAGE_LOCATOR, LocatorType.CSS); if (widget != null) { String title = widget.getText(); Assert.assertEquals(title, NOTES_ALERT_VALUE); }//from www. j a v a2s . c om for (int i = 0; i < 3; i++) { boolean flag = false; WebElement note = MyWebDriverUtils.findElement(driver, NEW_NOTE_LOCATOR + "[" + i + "]", LocatorType.ID); if (note != null) { String noteValue = note.getAttribute(ATTRIBUTE_VALUE_LOCATOR); if (noteValue.equals(NEW_NOTE_VALUE + 0) || noteValue.equals(NEW_NOTE_VALUE + 1) || noteValue.equals(NEW_NOTE_VALUE + 2)) { flag = true; } Assert.assertTrue(flag); } else { Assert.fail("notes is null!"); } } WebElement el = MyWebDriverUtils.findElement(driver, "#clientNoteDiv > div > label", LocatorType.CSS); if (el != null) { String user = el.getText(); Assert.assertNotNull(user); Assert.assertTrue(user.contains("cgilabadmin")); } else { Assert.fail("el is null!"); } }
From source file:com.easytox.automation.steps.LabClientImpl.java
@Then("^Notes should be opened for edit$") public void notes_should_be_opened_for_edit() { WebElement note = MyWebDriverUtils.findElement(driver, NEW_NOTE_LOCATOR + "[" + 0 + "]", LocatorType.ID); if (note != null) { String noteValue = note.getAttribute(NOTE_UNLOCK_FOR_EDIT_LOCATOR); Assert.assertNotNull(noteValue); String noteClass = note.getAttribute(ATTRIBUTE_CLASS_LOCATOR); Assert.assertEquals(noteClass, NOTE_UNLOCK_FOR_EDIT_CLASS_VALUE); note.clear();// ww w.j av a 2 s. c o m note.sendKeys(NEW_NOTE_VALUE); String value = note.getAttribute(ATTRIBUTE_VALUE_LOCATOR); Assert.assertEquals(value, NEW_NOTE_VALUE); } else { Assert.fail("note is null!"); } }
From source file:com.easytox.automation.steps.LabClientImpl.java
@Then("^User should be navigate to the selected page$") public void user_should_be_navigate_to_selected_page() { WebElement el = MyWebDriverUtils.findElement(driver, PAGINATION_LOCATOR, LocatorType.CSS); if (el != null) { List<WebElement> list = MyWebDriverUtils.findElements(driver, LIST_LOCATOR, LocatorType.TAG, el); if (list != null) { WebElement activeButton; String attribute;//from w ww .j a v a 2 s . c om switch (navigateButton) { case "Next": activeButton = list.get(3); attribute = activeButton.getAttribute(ATTRIBUTE_CLASS_LOCATOR); Assert.assertEquals(attribute, "active"); break; case "Prev": activeButton = list.get(1); attribute = activeButton.getAttribute(ATTRIBUTE_CLASS_LOCATOR); Assert.assertEquals(attribute, "active"); break; default: int num = Integer.parseInt(navigateButton); activeButton = list.get(num); attribute = activeButton.getAttribute(ATTRIBUTE_CLASS_LOCATOR); Assert.assertEquals(attribute, "active"); } } } }
From source file:com.easytox.automation.steps.LabPhysicianImpl.java
@Then("^User should be navigate to the selected page.$") public void user_should_be_navigate_to_the_selected_page() { WebElement el = MyWebDriverUtils.findElement(driver, PAGINATION_LOCATOR, LocatorType.CSS); if (el != null) { List<WebElement> list = MyWebDriverUtils.findElements(driver, LIST_LOCATOR, LocatorType.TAG, el); if (list != null) { WebElement activeButton; String attribute;//from w ww. j av a 2 s. c o m switch (navigateButton) { case "Next": activeButton = list.get(2); attribute = activeButton.getAttribute(ATTRIBUTE_CLASS_LOCATOR); Assert.assertEquals(attribute, "active"); break; case "Prev": activeButton = list.get(1); attribute = activeButton.getAttribute(ATTRIBUTE_CLASS_LOCATOR); Assert.assertEquals(attribute, "active"); break; default: int num = Integer.parseInt(navigateButton); activeButton = list.get(num); attribute = activeButton.getAttribute(ATTRIBUTE_CLASS_LOCATOR); Assert.assertEquals(attribute, "active"); } } } }
From source file:com.ecfeed.core.runner.java.SeleniumTestMethodInvoker.java
License:Open Source License
private boolean processCheckBox(String elementType, MethodParameterNode methodParameterNode, String argument) { if (!NodePropertyDefElemType.isCheckbox(elementType)) { return false; }/*from w ww . j a v a2 s . c om*/ WebElement webElement = findWebElement(methodParameterNode); if (!isElementOkForInput(webElement)) { reportExceptionUnavailableElement(methodParameterNode); } String type = webElement.getAttribute(ATTR_TYPE); if (!StringHelper.isEqual(type, TYPE_CHECKBOX)) { return false; } boolean isAction = BooleanHelper.parseBoolean(argument); if (isAction) { webElement.click(); } return true; }
From source file:com.ecfeed.core.runner.java.SeleniumTestMethodInvoker.java
License:Open Source License
private boolean clickRadioButton(WebElement option, String argument) { String type = option.getAttribute(ATTR_TYPE); if (!StringHelper.isEqual(type, TYPE_RADIO)) { return false; }/* w w w .jav a 2 s . c o m*/ String value = option.getAttribute(ATTR_VALUE); if (!StringHelper.isEqual(value, argument)) { return false; } option.click(); return true; }
From source file:com.ecofactor.qa.automation.insite.page.DemandSideManagementImpl.java
License:Open Source License
/** * Gets the program details.Retrieve the program data as displayed in the * screen./* ww w . j av a 2 s . com*/ * * @return the program details * @throws ParseException * the parse exception */ public Map<String, Object> getProgramDetails() throws ParseException { formatter = new SimpleDateFormat("MM-dd-yyyy"); DriverConfig.getDriver().switchTo().defaultContent(); smallWait(); DriverConfig.getDriver().switchTo().frame(0); WaitUtil.waitUntil(SHORT_TIMEOUT); logger.info("check if the form is displayed."); WebElement form1 = DriverConfig.getDriver().findElement(By.id(demandSideManagementConfig.get(FORM_ID))); WebElement programId = form1.findElement(By.id(demandSideManagementConfig.get(PROGRAM_ID_FIELDS_ID))); logger.info("programid: " + programId.getAttribute(ATTR_VALUE)); lsProgramId = Integer.parseInt(programId.getAttribute(ATTR_VALUE)); programPropertiesMap.put("ProgramId", programId.getAttribute(ATTR_VALUE)); WebElement propertiesFormElement = DriverConfig.getDriver() .findElement(By.id(demandSideManagementConfig.get(PROGRAM_TITLE_SPAN_ID))); logger.info("program name as displayed in Ui : " + propertiesFormElement.getText()); programPropertiesMap.put("ProgramName", propertiesFormElement.getText()); WebElement programProperties = DriverConfig.getDriver() .findElements(By.className(demandSideManagementConfig.get(PROGRAM_PROPERTIES_DIV_CLASS))).get(1); List<WebElement> propertyList = programProperties.findElements(By.tagName(TAG_TD)); Iterator<WebElement> iterator = propertyList.listIterator(); while (iterator.hasNext()) { programPropertiesMap.put(iterator.next().getText().replaceAll(" ", "_"), iterator.next().getText()); } return programPropertiesMap; }
From source file:com.ecofactor.qa.automation.insite.page.DemandSideManagementImpl.java
License:Open Source License
/** * Gets the program id.//from ww w .ja v a2s .c o m * * @return the program id */ public Integer getProgramId() { formatter = new SimpleDateFormat("MM-dd-yyyy"); DriverConfig.getDriver().switchTo().defaultContent(); smallWait(); DriverConfig.getDriver().switchTo().frame(0); WaitUtil.waitUntil(SHORT_TIMEOUT); WebElement form1 = DriverConfig.getDriver().findElement(By.id(demandSideManagementConfig.get(FORM_ID))); WebElement programId = form1.findElement(By.id(demandSideManagementConfig.get(PROGRAM_ID_FIELDS_ID))); logger.info("programid: " + programId.getAttribute(ATTR_VALUE)); lsProgramId = Integer.parseInt(programId.getAttribute(ATTR_VALUE)); return Integer.valueOf(lsProgramId); }