List of usage examples for org.openqa.selenium WebElement clear
void clear();
From source file:com.dukescript.api.selenium.ExternalWebViewTest.java
License:Open Source License
@Test public void withModelAndExistingWebView() throws InterruptedException { WebElement element = driver.findElement(By.id("target")); Assert.assertEquals("Hello", element.getText()); WebElement button = driver.findElement(By.id("button")); button.click();/*www.j a v a2 s. co m*/ Assert.assertEquals("World", element.getText()); WebElement input = driver.findElement(By.id("input")); input.clear(); input.sendKeys("DukeScript"); button.click(); Assert.assertEquals("DukeScript", element.getText()); WebElement findElement = driver.findElement(By.cssSelector(".bla")); Assert.assertNotNull(findElement); Assert.assertEquals("DukeScript", findElement.getText()); List<WebElement> findElements = driver.findElements(By.cssSelector(".bla")); Assert.assertEquals(1, findElements.size()); }
From source file:com.dukescript.api.selenium.FindsByTest.java
License:Open Source License
@Test public void withModel() { // please note that this method is not executed in BrwsrCtx // to allow seeing updates in the Browser while debugging a test WebElement element = driver.findElement(By.id("target")); Assert.assertEquals("Hello", element.getText()); WebElement button = driver.findElement(By.id("button")); button.click();/*from ww w. jav a2 s. c o m*/ Assert.assertEquals("World", element.getText()); WebElement input = driver.findElement(By.id("input")); input.clear(); input.sendKeys("DukeScript"); button.click(); Assert.assertEquals("DukeScript", element.getText()); WebElement findElement = driver.findElement(By.cssSelector(".bla")); Assert.assertNotNull(findElement); Assert.assertEquals("DukeScript", findElement.getText()); }
From source file:com.easytox.automation.steps.addPhysicians.AddPhysiciansQuestSteps.java
@Given("^User should be login to the lab$") public void user_should_be_login_to_the_lab() throws Throwable { driver.navigate().to(URL);/*from www. j a v a 2s . co m*/ WebElement username = driver.findElement(By.name(FIND_USERNAME)); username.clear(); username.sendKeys(USERNAME); WebElement psw = driver.findElement(By.name(FIND_PASSWORD)); psw.clear(); psw.sendKeys(PASSWORD); driver.findElement(By.xpath("//*[@id=\"loginform\"]/div[3]/div/button")).click(); }
From source file:com.easytox.automation.steps.LabClientImpl.java
@When("^Enter all the information in the screen and click Submit$") public void enter_all_the_information_in_the_screen_and_click_submit() { WebElement business = MyWebDriverUtils.findElement(driver, BUSINESS_NAME_LOCATOR, LocatorType.NAME); if (business != null) { business.clear(); business.sendKeys(BUSINESS_NAME_VALUE); } else {/*from www . j a va 2 s.c o m*/ Assert.fail("business is null!"); } WebElement address1 = MyWebDriverUtils.findElement(driver, ADDRESS_1_LOCATOR, LocatorType.NAME); if (address1 != null) { address1.clear(); address1.sendKeys(ADDRESS_1_VALUE); } else { Assert.fail("address1 is null!"); } WebElement address2 = MyWebDriverUtils.findElement(driver, ADDRESS_2_LOCATOR, LocatorType.NAME); if (address2 != null) { address2.clear(); address2.sendKeys(ADDRESS_2_VALUE); } else { Assert.fail("address2 is null!"); } WebElement zipCode = MyWebDriverUtils.findElement(driver, ZIP_LOCATOR, LocatorType.ID); if (zipCode != null) { zipCode.clear(); zipCode.sendKeys(ZIP_VALUE); } else { Assert.fail("zipCode is null!"); } WebElement city = MyWebDriverUtils.findElement(driver, CITY_LOCATOR, LocatorType.ID); if (city != null) { city.clear(); city.sendKeys(CITY_VALUE); } else { Assert.fail("city is null!"); } WebElement state = MyWebDriverUtils.findElement(driver, STATE_LOCATOR, LocatorType.ID); if (state != null) { state.clear(); state.sendKeys(STATE_VALUE); } else { Assert.fail("state is null!"); } WebElement contactPerson = MyWebDriverUtils.findElement(driver, CONTACT_PERSON_LOCATOR, LocatorType.NAME); if (contactPerson != null) { contactPerson.clear(); contactPerson.sendKeys(CONTACT_PERSON_VALUE); } else { Assert.fail("contactPerson is null!"); } WebElement contactNumber = MyWebDriverUtils.findElement(driver, CONTACT_NUMBER_LOCATOR, LocatorType.NAME); if (contactNumber != null) { contactNumber.clear(); contactNumber.sendKeys(CONTACT_NUMBER_VALUE); } else { Assert.fail("contactNumber is null!"); } WebElement faxNumber = MyWebDriverUtils.findElement(driver, FAX_NUMBER_LOCATOR, LocatorType.NAME); if (faxNumber != null) { faxNumber.clear(); faxNumber.sendKeys(FAX_NUMBER_VALUE); } else { Assert.fail("faxNumber is null!"); } WebElement contactEmail = MyWebDriverUtils.findElement(driver, CONTACT_EMAIL_LOCATOR, LocatorType.NAME); if (contactEmail != null) { contactEmail.clear(); contactEmail.sendKeys(CONTACT_EMAIL_VALUE); } else { Assert.fail("contactEmail is null!"); } WebElement submit = MyWebDriverUtils.findElement(driver, SUBMIT_BUTTON_LOCATOR, LocatorType.CSS); WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS); boolean flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID); if (flag) { checkAndClick(submit); } else { Assert.fail("flag is false!"); } }
From source file:com.easytox.automation.steps.LabClientImpl.java
@When("^Make changes as needed and click update$") public void make_changes_as_needed_and_click_update() { WebElement address1 = MyWebDriverUtils.findElement(driver, ADDRESS_1_LOCATOR, LocatorType.NAME); if (address1 != null) { address1.clear(); address1.sendKeys(ADDRESS_1_VALUE); } else {//from w w w . j av a 2s . co m Assert.fail("address1 is null!"); } WebElement address2 = MyWebDriverUtils.findElement(driver, ADDRESS_2_LOCATOR, LocatorType.NAME); if (address2 != null) { address2.clear(); address2.sendKeys(ADDRESS_2_VALUE); } else { Assert.fail("address2 is null!"); } WebElement faxNumber = MyWebDriverUtils.findElement(driver, FAX_NUMBER_LOCATOR, LocatorType.NAME); if (faxNumber != null) { faxNumber.clear(); faxNumber.sendKeys(FAX_NUMBER_VALUE); } else { Assert.fail("faxNumber is null!"); } WebElement submit = MyWebDriverUtils.findElement(driver, SUBMIT_BUTTON_LOCATOR, LocatorType.CSS); WebDriverWait wait = new WebDriverWait(driver, TIME_OUT_IN_SECONDS); boolean flag = MyWebDriverUtils.waitInvisibilityOfElement(wait, CONTAINER_LOCATOR, LocatorType.ID); if (flag) { checkAndClick(submit); } else { Assert.fail("flag is false!"); } }
From source file:com.easytox.automation.steps.LabClientImpl.java
@When("^Enter Location Name and the remaining details and click on 'Submit'$") public void enter_location_name_and_the_remaining_details_and_click_on_submit() { WebElement labName = MyWebDriverUtils.findElement(driver, LAB_LOCATION_NAME_LOCATOR, LocatorType.NAME); if (labName != null) { labName.clear(); labName.sendKeys(LAB_LOCATION_NAME_VALUE); } else {//from w ww.j av a 2 s . c o m Assert.fail("labName is null!"); } WebElement labDepartment = MyWebDriverUtils.findElement(driver, LAB_LOCATION_DEPARTMENT_LOCATOR, LocatorType.NAME); if (labDepartment != null) { labDepartment.clear(); labDepartment.sendKeys(LAB_LOCATION_DEPARTMENT_VALUE); } else { Assert.fail("labDepartment is null!"); } WebElement labAddress = MyWebDriverUtils.findElement(driver, LAB_LOCATION_ADDRESS_LOCATOR, LocatorType.NAME); if (labAddress != null) { labAddress.clear(); labAddress.sendKeys(LAB_LOCATION_ADDRESS_VALUE); } else { Assert.fail("labAddress is null!"); } WebElement faxNumber = MyWebDriverUtils.findElement(driver, FAX_NUMBER_LOCATOR, LocatorType.NAME); if (faxNumber != null) { faxNumber.clear(); faxNumber.sendKeys(FAX_NUMBER_VALUE); } else { Assert.fail("faxNumber is null!"); } WebElement el = MyWebDriverUtils.findElement(driver, EDIT_SUBMIT_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
@When("^Make required changes and click Update$") public void make_required_changes_and_click_update() { WebElement labName = MyWebDriverUtils.findElement(driver, LAB_LOCATION_NAME_LOCATOR, LocatorType.NAME); if (labName != null) { labName.clear(); labName.sendKeys(LAB_LOCATION_NAME_VALUE); } else {//from w w w.j a v a 2 s. c o m Assert.fail("labName is null!"); } WebElement labDepartment = MyWebDriverUtils.findElement(driver, LAB_LOCATION_DEPARTMENT_LOCATOR, LocatorType.NAME); if (labDepartment != null) { labDepartment.clear(); labDepartment.sendKeys(LAB_LOCATION_DEPARTMENT_VALUE); } else { Assert.fail("labDepartment is null!"); } WebElement labAddress = MyWebDriverUtils.findElement(driver, LAB_LOCATION_ADDRESS_LOCATOR, LocatorType.NAME); if (labAddress != null) { labAddress.clear(); labAddress.sendKeys(LAB_LOCATION_ADDRESS_VALUE); } else { Assert.fail("labAddress is null!"); } WebElement faxNumber = MyWebDriverUtils.findElement(driver, FAX_NUMBER_LOCATOR, LocatorType.NAME); if (faxNumber != null) { faxNumber.clear(); faxNumber.sendKeys(FAX_NUMBER_VALUE); } else { Assert.fail("faxNumber is null!"); } WebElement el = MyWebDriverUtils.findElement(driver, UPDATE_SUBMIT_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
@When("^Enter User information, Personal information and select lab information. click on 'Submit'$") public void enter_information_and_submit() throws InterruptedException { Thread.sleep(TIME_STOP);/*from ww w. ja v a 2 s .c o m*/ WebElement userName = MyWebDriverUtils.findElement(driver, USER_USERNAME_LOCATOR, LocatorType.NAME); if (userName != null) { userNameValue = StringUtils.generateRandom(); userName.clear(); userName.sendKeys(userNameValue); } else { Assert.fail("userName is null!"); } WebElement password = MyWebDriverUtils.findElement(driver, USER_PASSWORD_LOCATOR, LocatorType.NAME); if (password != null) { password.clear(); password.sendKeys(USER_PASSWORD_VALUE); } else { Assert.fail("password is null!"); } WebElement firstName = MyWebDriverUtils.findElement(driver, USER_FIRST_NAME_LOCATOR, LocatorType.CSS); if (firstName != null) { firstName.clear(); firstName.sendKeys(USER_FIRST_NAME_VALUE); } else { Assert.fail("firstName is null!"); } WebElement lastName = MyWebDriverUtils.findElement(driver, USER_LAST_NAME_LOCATOR, LocatorType.CSS); if (lastName != null) { lastName.clear(); lastName.sendKeys(USER_LAST_NAME_VALUE); } else { Assert.fail("lastName is null!"); } WebElement email = MyWebDriverUtils.findElement(driver, USER_EMAIL_LOCATOR, LocatorType.NAME); if (email != null) { email.clear(); email.sendKeys(USER_EMAIL_VALUE); } else { Assert.fail("email is null!"); } WebElement phoneNumber = MyWebDriverUtils.findElement(driver, USER_PHONE_NUMBER_LOCATOR, LocatorType.NAME); if (phoneNumber != null) { phoneNumber.clear(); phoneNumber.sendKeys(USER_PHONE_NUMBER_VALUE); } else { Assert.fail("phoneNumber is null!"); } new Select(driver.findElement(By.cssSelector(SELECT_ROLE_LOCATOR))).selectByVisibleText(ROLE); new Select(driver.findElement(By.id(LAB_LOCATIONS_LOCATOR))).selectByVisibleText(LAB_LOCATIONS_VALUE); WebElement el = MyWebDriverUtils.findElement(driver, USER_SUBMIT_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
@When("^Make changes to Personal Information and click update$") public void make_changes_to_personal_information_and_click_update() { WebElement firstName = MyWebDriverUtils.findElement(driver, USER_FIRST_NAME_LOCATOR, LocatorType.CSS); if (firstName != null) { firstName.clear(); firstName.sendKeys(USER_FIRST_NAME_VALUE); } else {/*from w w w . j a v a 2 s. c om*/ Assert.fail("firstName is null!"); } WebElement lastName = MyWebDriverUtils.findElement(driver, USER_LAST_NAME_LOCATOR, LocatorType.CSS); if (lastName != null) { lastName.clear(); lastName.sendKeys(USER_LAST_NAME_VALUE); } else { Assert.fail("lastName is null!"); } WebElement email = MyWebDriverUtils.findElement(driver, USER_EMAIL_LOCATOR, LocatorType.NAME); if (email != null) { email.clear(); email.sendKeys(USER_EMAIL_VALUE); } else { Assert.fail("email is null!"); } WebElement phoneNumber = MyWebDriverUtils.findElement(driver, USER_PHONE_NUMBER_LOCATOR, LocatorType.NAME); if (phoneNumber != null) { phoneNumber.clear(); phoneNumber.sendKeys(USER_PHONE_NUMBER_VALUE); } else { Assert.fail("phoneNumber is null!"); } new Select(driver.findElement(By.id(LAB_LOCATIONS_LOCATOR))).selectByVisibleText(LAB_LOCATIONS_VALUE); WebElement el = MyWebDriverUtils.findElement(driver, UPDATE_BUTTON_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("^Account locked message should be populated and user should not be able to login to application$") public void account_locked_message_should_be_populated() { String currentUrl = driver.getCurrentUrl(); Assert.assertEquals(currentUrl, LOGIN_PAGE_URL); WebElement element = driver.findElement(By.name(FIND_USERNAME)); element.clear(); element.sendKeys(LOCK_USER);/*from www .j a va 2 s . c om*/ WebElement el = driver.findElement(By.name(FIND_LOGIN)); el.clear(); el.sendKeys(PASSWORD); driver.findElement(By.xpath(LOGIN_BUTTON_XPATH)).click(); WebElement message = driver.findElement(By.cssSelector(LOCKED_MESSAGE_LOCATOR)); Assert.assertTrue(message.isDisplayed()); }