List of usage examples for org.openqa.selenium WebElement clear
void clear();
From source file:org.auraframework.component.ui.datePickerManager.DatePickerManagerUITest.java
License:Apache License
/** * This test is checking for instances where an inputDateTrigger does not have a value attribute set, and that it * still opens to the correct value// w w w .j av a 2s. c o m * * @throws Exception */ public void testDatepickerOpensToCorrectValue() throws Exception { open(URL); // Test Begins // Making sure the textBox is empty so we always start at the same date WebElement element = findDomElement(By.cssSelector(DATE_INPUT_BOX_SEL)); element.clear(); element.sendKeys(TEST_DATE_TO_USE); // Reopening the calendar and Grabbing date directly above it, clicking on it, then verifying that it is the // correct date. openAndCheckDate(By.linkText("8"), "04/08/2013"); }
From source file:org.auraframework.components.ui.inputDate.BaseInputDateUITester.java
License:Apache License
private String pageUpDownHelper(int iterCondition, String keyString) { WebDriver driver = getDriver();// ww w . jav a2 s .com // Test Begins // Making sure the textBox is empty so we always start at the same date WebElement element = findDomElement(By.cssSelector(DATE_INPUT_BOX_SEL)); element.clear(); element.sendKeys(TEST_DATE_TO_USE); // Grabbing the Date Icon and click on it to open the calendar element = findDomElement(By.cssSelector(DATE_ICON_SEL)); element.click(); String classOfActiveElem = "" + auraUITestingUtil.getEval(CLASSNAME); element = findDomElement(By.cssSelector("a[class*='" + classOfActiveElem + "']")); element = loopThroughKeys(element, driver, keyString, iterCondition, ARIA_SELECTED_SEL, "Shift+Page Up/Down"); // Selecting the date that we are on to get the value and compare it to what it should be element.sendKeys(Keys.SPACE); // Setting the input box in focus to get its value element = findDomElement(By.cssSelector(DATE_INPUT_BOX_SEL)); // Checking if the values are equal return element.getAttribute("value"); }
From source file:org.auraframework.components.ui.inputDate.BaseInputDateUITester.java
License:Apache License
private String iterateCal(int monthIter, int yearIter, String monthSel, String yearSel) { // Start at specific date WebElement element = findDomElement(By.cssSelector(DATE_INPUT_BOX_SEL)); element.clear(); element.click();/*from w ww .ja v a 2 s . co m*/ element.sendKeys(TEST_DATE_TO_USE); // Clicking on the the textbox to gain focus element = findDomElement(By.cssSelector(DATE_ICON_SEL)); element.click(); // Finding either the increasing or decreasing month arrow element = findDomElement(By.cssSelector(monthSel)); // Increasing or decreasing the month for (int i = 0; i < monthIter; i++) { element.click(); element = findDomElement(By.cssSelector(monthSel)); assertTrue("Page up/down could not find aria-selected='true'", element != null); } // Finding either the increasing or decreasing year arrow element = findDomElement(By.cssSelector(yearSel)); // Increasing or decreasing the year for (int i = 0; i < yearIter; i++) { element.click(); element = findDomElement(By.cssSelector(yearSel)); assertTrue("Shift + Page up/down could not find aria-selected='true'", element != null); } /* * Returning a Boolean value, whether the label in the calendar matches the month and year that we were * expecting */ return findDomElement(By.cssSelector("h4[class*='monthYear']")).getText(); }
From source file:org.auraframework.components.ui.inputDate.BaseInputDateUITester.java
License:Apache License
private String homeEndButtonHelper(String initDate, Keys buttonToPress) { // Getting the input box, making sure it is clear, and sending in the the starting date WebElement element = findDomElement(By.cssSelector(DATE_INPUT_BOX_SEL)); element.clear(); element.sendKeys(initDate);/*from w w w. j a v a2s . co m*/ // Opening the calendar icon to grab the date we are looking for element = findDomElement(By.cssSelector(DATE_ICON_SEL)); element.click(); // Grabbing the correct focus cell date element = findDomElement(By.cssSelector(SELECTED_DATE)); // Pressing the home or End button and grabbing the associated date element.sendKeys(buttonToPress); element = findDomElement(By.cssSelector(ARIA_SELECTED_SEL)); // Clicking on that element to compare it to the date we should receive element.sendKeys(Keys.SPACE); // Repointing to the InputTextBox element = findDomElement(By.cssSelector(DATE_INPUT_BOX_SEL)); // Making sure they are equal return element.getAttribute("value"); }
From source file:org.auraframework.components.ui.inputNumber.InputNumberUITest.java
License:Apache License
public void testInputNumber() throws Exception { WebDriver d = getDriver();/*from w ww. ja v a2 s. c o m*/ open("/uitest/inputNumber_Test.cmp"); WebElement input = d.findElement(By.xpath("//input")); WebElement submit = d.findElement(By.xpath("//button")); WebElement output = d.findElement(By.xpath("//span[@class='uiOutputText']")); // integer input.clear(); input.sendKeys("987654321"); submit.click(); waitForElementTextPresent(output, "987654321"); // negative integer input.clear(); input.sendKeys("-123"); submit.click(); waitForElementTextPresent(output, "-123"); }
From source file:org.auraframework.components.ui.inputNumber.InputNumberUITest.java
License:Apache License
public void testLocalizedInputNumber() throws Exception { WebDriver d = getDriver();//from w w w .j ava 2s . co m open("/uitest/inputLocalizedNumber_Test.cmp"); WebElement input = d.findElement(By.xpath("//input")); WebElement submit = d.findElement(By.xpath("//button")); WebElement output = d.findElement(By.xpath("//span[@class='uiOutputText']")); // integer input.clear(); input.sendKeys("123456789"); submit.click(); waitForElementTextPresent(output, "123456789"); // decimal input.clear(); input.sendKeys("123456.789"); submit.click(); waitForElementTextPresent(output, "123456.789"); // negative integer input.clear(); input.sendKeys("-123456"); submit.click(); waitForElementTextPresent(output, "-123456"); // negative decimal input.clear(); input.sendKeys("-123.456"); submit.click(); waitForElementTextPresent(output, "-123.456"); }
From source file:org.auraframework.components.ui.inputNumber.InputNumberUITest.java
License:Apache License
public void _testInputNumberWithError() throws Exception { WebDriver d = getDriver();// w ww .j av a2s . co m open("/uitest/inputNumber_Test.cmp"); WebElement input = d.findElement(By.xpath("//input")); WebElement submit = d.findElement(By.xpath("//button")); WebElement output = d.findElement(By.xpath("//span[@class='uiOutputText']")); // induce error input.clear(); input.sendKeys("abcdef"); submit.click(); waitForElementTextPresent(output, "Got Error!"); auraUITestingUtil.waitForElementText(By.className("uiInputDefaultError"), "Invalid value for inVar: java://long", true, "Error element never inserted into DOM"); // clear error input.clear(); input.sendKeys("1234"); submit.click(); waitForElementTextPresent(output, "1234"); assertFalse("Did not expect an error message", isElementPresent(By.className("uiInputDefaultError"))); }
From source file:org.auraframework.components.ui.InputNumberUITest.java
License:Apache License
public void testInputNumberWithError() throws Exception { WebDriver d = getDriver();/*from w ww.j a v a2s . c om*/ open("/uitest/inputNumber_Test.cmp"); WebElement input = d.findElement(By.xpath("//input")); WebElement submit = d.findElement(By.xpath("//button")); WebElement output = d.findElement(By.xpath("//span[@class='uiOutputText']")); // induce error input.clear(); input.sendKeys("abcdef"); submit.click(); waitForElementTextPresent(output, "Got Error!"); WebElement error = d.findElement(By.className("uiInputDefaultError")); assertEquals("Incorrect error message", "Invalid value for inVar: java://long", error.getText()); // clear error input.clear(); input.sendKeys("1234"); submit.click(); waitForElementTextPresent(output, "1234"); error = d.findElement(By.className("uiInputDefaultError")); assertEquals("Error message should be gone", "", error.getText()); }
From source file:org.auraframework.components.ui.inputTextArea.InputTextAreaUITest.java
License:Apache License
/** * Test Case for W-1731003 ui:inputTextArea throws error when value is changed *///from w w w.j a va2 s. c om public void testInputTextAreaWithLabel() throws Exception { open(TEST_CMP); WebElement div = findDomElement(By.id("textAreaWithLabel")); WebElement input = div.findElement(By.tagName("textarea")); WebElement outputDiv = findDomElement(By.id("output")); String inputAuraId = "textAreaWithLabel"; String valueExpression = auraUITestingUtil.getValueFromCmpRootExpression(inputAuraId, "v.value"); String defExpectedValue = (String) auraUITestingUtil.getEval(valueExpression); assertEquals("Default value for inputTextArea should be the same", inputAuraId, defExpectedValue); // AndroidDriver likes to type things in all caps so modify input to accommodate. String inputText = "UPDATEDTEXT"; input.clear(); input.click(); input.sendKeys(inputText); outputDiv.click(); // to simulate tab behavior for touch browsers String actualText = (String) auraUITestingUtil.getEval(valueExpression); assertEquals("Value of Input text Area shoud be updated", inputText, actualText); }
From source file:org.auraframework.components.ui.inputTextArea.InputTextAreaUITest.java
License:Apache License
public void testEncodedTextAreaBehavior() throws Exception { open(TEST_CMP);/* ww w .j a v a 2 s. c o m*/ WebElement div = findDomElement(By.id("textAreaWithLabel")); WebElement input = div.findElement(By.tagName("textarea")); WebElement outputDiv = findDomElement(By.id("output")); String inputAuraId = "textAreaWithLabel"; String valueExpression = auraUITestingUtil.getValueFromCmpRootExpression(inputAuraId, "v.value"); String inputText = String.format("%s%n%s%n%s%n%s", "LINE1", "LINE2", "LINE3", "LINE4"); input.clear(); input.click(); input.sendKeys(inputText); outputDiv.click(); // to simulate tab behavior for touch browsers String actualText = (String) auraUITestingUtil.getEval(valueExpression); assertEquals("Total number of bytes with \r\n does not match", inputText.getBytes().length + 3, actualText.getBytes().length); assertEquals("Value of Input text Area shoud be updated after removing carriage return", inputText, actualText.replaceAll("(\\r)", "")); }