Here are the examples of the java api class org.openqa.selenium.WebElement taken from open source projects.
1. EditQuestionPage#edit()
Project: mamute
File: EditQuestionPage.java
File: EditQuestionPage.java
public QuestionPage edit(String title, String description, String tags) { WebElement editQuestionForm = byClassName("question-form"); WebElement questionTitle = editQuestionForm.findElement(By.name("title")); questionTitle.clear(); questionTitle.sendKeys(title); WebElement questionDescription = editQuestionForm.findElement(By.name("description")); questionDescription.clear(); questionDescription.sendKeys(description); WebElement questionTags = editQuestionForm.findElement(By.name("tagNames")); questionTags.clear(); questionTags.sendKeys(tags); WebElement editComment = editQuestionForm.findElement(By.name("comment")); editComment.clear(); editComment.sendKeys("my comment"); editQuestionForm.submit(); return new QuestionPage(driver); }
2. EditAnswerPage#edit()
Project: mamute
File: EditAnswerPage.java
File: EditAnswerPage.java
public QuestionPage edit(String description, String editComment) { WebElement editAnswerForm = byClassName("answer-form"); WebElement descriptionInput = editAnswerForm.findElement(By.name("description")); descriptionInput.clear(); descriptionInput.sendKeys(description); WebElement commentInput = editAnswerForm.findElement(By.name("comment")); commentInput.clear(); commentInput.sendKeys(editComment); descriptionInput.submit(); return new QuestionPage(driver); }
3. InputPromptGetTextTest#test()
Project: vaadin
File: InputPromptGetTextTest.java
File: InputPromptGetTextTest.java
@Test public void test() { openTestURL(); WebElement field = getDriver().findElement(By.id(InputPromptGetText.FIELD)); WebElement button = getDriver().findElement(By.id(InputPromptGetText.BUTTON)); String string = getRandomString(); field.sendKeys(string + "\n"); String selectAll = Keys.chord(Keys.CONTROL, "a"); field.sendKeys(selectAll); field.sendKeys(Keys.BACK_SPACE); button.click(); WebElement label = getDriver().findElement(By.id(InputPromptGetText.LABEL2)); Assert.assertEquals("Your input was:", label.getText().trim()); }
4. SayHelloWebviewTest#assertThatWebviewSaysHello()
Project: selendroid
File: SayHelloWebviewTest.java
File: SayHelloWebviewTest.java
@Test public void assertThatWebviewSaysHello() throws Exception { WebElement button = driver().findElement(By.id("buttonStartWebview")); button.click(); WebDriverWait wait = new WebDriverWait(driver(), 10); wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText("Go to home screen"))); driver().switchTo().window("WEBVIEW"); WebElement inputField = driver().findElement(By.id("name_input")); Assert.assertNotNull(inputField); inputField.clear(); inputField.sendKeys("Dominik"); WebElement car = driver().findElement(By.name("car")); Select preferedCar = new Select(car); preferedCar.selectByValue("audi"); inputField.submit(); WaitingConditions.pageTitleToBe(driver(), "Hello: Dominik"); }
5. ViewAccessScopedWebAppTest#testForward()
Project: deltaspike
File: ViewAccessScopedWebAppTest.java
File: ViewAccessScopedWebAppTest.java
@Test @RunAsClient public void testForward() throws Exception { driver.get(new URL(contextPath, "page1.xhtml").toString()); WebElement inputFieldX = driver.findElement(By.id("testForm1:valueInputX")); inputFieldX.sendKeys("abc"); WebElement inputFieldY = driver.findElement(By.id("testForm1:valueInputY")); inputFieldY.sendKeys("xyz"); WebElement button = driver.findElement(By.id("testForm1:next")); button.click(); Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("valueX"), "abc").apply(driver)); button = driver.findElement(By.id("testForm2:back")); button.click(); Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("valueOutputX"), "abc").apply(driver)); Assert.assertFalse(ExpectedConditions.textToBePresentInElement(By.id("valueOutputY"), "xyz").apply(driver)); }
6. GitblitDashboardView#login()
Project: gitblit
File: GitblitDashboardView.java
File: GitblitDashboardView.java
public void login(String id, String pw) { String pathID = LOGIN_AREA_SELECTOR + "/input[@name = \"username\" ]"; String pathPW = LOGIN_AREA_SELECTOR + "/input[@name = \"password\" ]"; String pathSubmit = LOGIN_AREA_SELECTOR + "/button[@type = \"submit\" ]"; // System.out.println("DRIVER:"+getDriver()); // List<WebElement> findElement = // getDriver().findElements(By.xpath("//span[@class = \"form-search\" ]")); // // System.out.println("ELEM: "+findElement); // System.out.println("SIZE: "+findElement.size()); // System.out.println("XPath: "+pathID); WebElement idField = getDriver().findElement(By.xpath(pathID)); // System.out.println("IDFIELD:"+idField); idField.sendKeys(id); WebElement pwField = getDriver().findElement(By.xpath(pathPW)); // System.out.println(pwField); pwField.sendKeys(pw); WebElement submit = getDriver().findElement(By.xpath(pathSubmit)); submit.click(); }
7. ViewAccessScopedWithFViewActionWebAppTest#testForward()
Project: deltaspike
File: ViewAccessScopedWithFViewActionWebAppTest.java
File: ViewAccessScopedWithFViewActionWebAppTest.java
@Test @RunAsClient public void testForward() throws Exception { driver.get(new URL(contextPath, "index.xhtml").toString()); WebElement inputFieldX = driver.findElement(By.id("form:firstValue")); inputFieldX.sendKeys("abc"); WebElement inputFieldY = driver.findElement(By.id("form:secondValue")); inputFieldY.sendKeys("xyz"); WebElement button = driver.findElement(By.id("form:next")); button.click(); Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("firstValue"), "abc").apply(driver)); Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("secondValue"), "xyz").apply(driver)); }
8. TasklistIT#testLogin()
Project: camunda-bpm-platform
File: TasklistIT.java
File: TasklistIT.java
@Test public void testLogin() { driver.get(appUrl + "/#/login"); WebDriverWait wait = new WebDriverWait(driver, 10); WebElement user = wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("input[type=\"text\"]"))); user.sendKeys("demo"); WebElement password = wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("input[type=\"password\"]"))); password.sendKeys("demo"); WebElement submit = wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("button[type=\"submit\"]"))); submit.submit(); }
9. DashboardIT#testLogin()
Project: camunda-bpm-platform
File: DashboardIT.java
File: DashboardIT.java
@Test public void testLogin() throws URISyntaxException { driver.get(appUrl + "/#/login"); WebDriverWait wait = new WebDriverWait(driver, 10); WebElement user = wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("input[type=\"text\"]"))); user.sendKeys("demo"); WebElement password = wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("input[type=\"password\"]"))); password.sendKeys("demo"); WebElement submit = wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("button[type=\"submit\"]"))); submit.submit(); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector("[ng-repeat=\"propName in procDefStatsKeys\"]:first-child > .value"), "1")); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.cssSelector("[ng-repeat=\"propName in procDefStatsKeys\"]:first-child > a"), "process definition")); wait.until(currentURIIs(new URI(appUrl + "/default/#/dashboard"))); }
10. CheckBoxRpcCountTest#numberOfRpcCallsIsEqualToClicks()
Project: vaadin
File: CheckBoxRpcCountTest.java
File: CheckBoxRpcCountTest.java
@Test public void numberOfRpcCallsIsEqualToClicks() { openTestURL(); CheckBoxElement checkBoxElement = $(CheckBoxElement.class).first(); WebElement labelElem = checkBoxElement.findElement(By.tagName("label")); WebElement inputElem = checkBoxElement.findElement(By.tagName("input")); final WebElement countElem = $(LabelElement.class).id("count-label"); // Click on the actual checkbox. inputElem.click(); // Have to use waitUntil to make this test more stable. waitUntilLabelIsUpdated(countElem, "1 RPC call(s) made."); // Click on the checkbox label. labelElem.click(); waitUntilLabelIsUpdated(countElem, "2 RPC call(s) made."); // Again on the label. labelElem.click(); waitUntilLabelIsUpdated(countElem, "3 RPC call(s) made."); }
11. RemoteUIAElementTest#canOnlyClickVisibleElement()
Project: ios-driver
File: RemoteUIAElementTest.java
File: RemoteUIAElementTest.java
//(dependsOnMethods ="isVisibleTests") @Test(enabled = false) public void canOnlyClickVisibleElement() { WebElement navBar = driver.findElement(By.tagName("UIANavigationBar")); Assert.assertTrue(navBar.isDisplayed(), "nav bar"); navBar.click(); List<WebElement> imgs = navBar.findElements(By.className("UIAImage")); Assert.assertEquals(imgs.size(), 2, "number of images in the menu"); for (WebElement el : imgs) { Assert.assertFalse(el.isDisplayed(), "image"); try { el.click(); Assert.fail("click on not visible should throw."); } catch (ElementNotVisibleException e) { } } WebElement text = navBar.findElement(By.className("UIAStaticText")); Assert.assertTrue(text.isDisplayed(), "nav bar text"); text.click(); }
12. FormHandlingTest#testShouldBeAbleToUploadTheSameFileTwice()
Project: ios-driver
File: FormHandlingTest.java
File: FormHandlingTest.java
// @Ignore(value = { SELENESE, IPHONE, ANDROID, OPERA, SAFARI }, reason = // "Does not yet support file uploads", issues = { 4220 }) @Test(enabled = false) public void testShouldBeAbleToUploadTheSameFileTwice() throws IOException { File file = File.createTempFile("test", "txt"); file.deleteOnExit(); driver.get(pages.formPage); WebElement uploadElement = driver.findElement(By.id("upload")); assertEquals(uploadElement.getAttribute("value"), ("")); uploadElement.sendKeys(file.getAbsolutePath()); uploadElement.submit(); driver.get(pages.formPage); uploadElement = driver.findElement(By.id("upload")); assertEquals(uploadElement.getAttribute("value"), ("")); uploadElement.sendKeys(file.getAbsolutePath()); uploadElement.submit(); // If we get this far, then we're all good. }
13. FileUploadTest#checkUploadingTheSameFileMultipleTimes()
Project: ghostdriver
File: FileUploadTest.java
File: FileUploadTest.java
@Test public void checkUploadingTheSameFileMultipleTimes() throws IOException { WebDriver d = getDriver(); File file = File.createTempFile("test", "txt"); file.deleteOnExit(); d.get(server.getBaseUrl() + "/common/formPage.html"); WebElement uploadElement = d.findElement(By.id("upload")); uploadElement.sendKeys(file.getAbsolutePath()); uploadElement.submit(); d.get(server.getBaseUrl() + "/common/formPage.html"); uploadElement = d.findElement(By.id("upload")); uploadElement.sendKeys(file.getAbsolutePath()); uploadElement.submit(); }
14. ElementMethodsTest#checkClickOnINPUTSUBMITCausesPageLoad()
Project: ghostdriver
File: ElementMethodsTest.java
File: ElementMethodsTest.java
@Test public void checkClickOnINPUTSUBMITCausesPageLoad() { WebDriver d = getDriver(); d.get("http://www.duckduckgo.com"); WebElement textInput = d.findElement(By.cssSelector("#search_form_input_homepage")); WebElement submitInput = d.findElement(By.cssSelector("#search_button_homepage")); assertFalse(d.getTitle().contains("clicking")); textInput.click(); assertFalse(d.getTitle().contains("clicking")); textInput.sendKeys("clicking"); assertFalse(d.getTitle().contains("clicking")); submitInput.click(); assertTrue(d.getTitle().contains("clicking")); }
15. StandardFunctionsFlowTest#editConfiguration()
Project: crawljax
File: StandardFunctionsFlowTest.java
File: StandardFunctionsFlowTest.java
private void editConfiguration() { WebElement maxCrawlStates = driver.findElements(By.xpath("//label[contains(text(),'Maximum Crawl States:')]/following-sibling::input")).get(0); maxCrawlStates.clear(); maxCrawlStates.sendKeys("3"); maxCrawlStates = driver.findElements(By.xpath("//label[contains(text(),'Maximum Crawl States:')]/following-sibling::input")).get(0); assertTrue(maxCrawlStates.getAttribute("value").equals("3")); WebElement crawlRulesLink = driver.findElements(By.linkText("Crawl Rules")).get(0); followLink(crawlRulesLink); WebElement clickDefaultElements = driver.findElements(By.xpath("//label[@class='checkbox']")).get(0); followLink(clickDefaultElements); WebElement addANewClickRule = driver.findElements(By.linkText("Add a New Click Rule")).get(0); followLink(addANewClickRule); WebElement addANewConditionLink = driver.findElements(By.linkText("Add a New Condition")).get(0); followLink(addANewConditionLink); WebElement pageConditionInput = driver.findElements(By.xpath("//legend[contains(text(),'Page Conditions')]/following-sibling::table//input[@type='text']")).get(0); pageConditionInput.clear(); pageConditionInput.sendKeys("ConditionInput"); WebElement addANewFilter = driver.findElements(By.linkText("Add a New Filter")).get(0); followLink(addANewFilter); WebElement filterInput = driver.findElements(By.xpath("//legend[contains(text(),'State Filters')]/following-sibling::table//input[@type='text']")).get(0); filterInput.clear(); filterInput.sendKeys("FilterInput"); WebElement addANewField = driver.findElements(By.linkText("Add a New Field")).get(0); followLink(addANewField); WebElement fieldIdInput = driver.findElements(By.xpath("//legend[contains(text(),'Form Field Input Values')]/following-sibling::table//input[@type='text']")).get(0); fieldIdInput.clear(); fieldIdInput.sendKeys("FieldID"); WebElement fieldValueInput = driver.findElements(By.xpath("//legend[contains(text(),'Form Field Input Values')]/following-sibling::table//input[@type='text']")).get(1); fieldValueInput.clear(); fieldValueInput.sendKeys("FieldValue"); ((JavascriptExecutor) driver).executeScript("scroll(250,0);"); WebElement assertionsLink = driver.findElements(By.partialLinkText("Assertions")).get(0); followLink(assertionsLink); addANewConditionLink = driver.findElements(By.linkText("Add a New Condition")).get(0); followLink(addANewConditionLink); WebElement newConditionInput = driver.findElements(By.xpath("//legend[contains(text(),'Invariants')]/following-sibling::table//input[@type='text']")).get(0); newConditionInput.clear(); newConditionInput.sendKeys("crawljax"); List<WebElement> saveConfigurationLink = driver.findElements(By.linkText("Save Configuration")); followLink(saveConfigurationLink.get(0)); ExpectedCondition<Boolean> isSaved = new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver driver) { WebElement notification = driver.findElements(By.id("notification")).get(0); return notification.getText().equals("Configuration Saved"); } }; WebDriverWait wait = new WebDriverWait(driver, 10); wait.until(isSaved); }
16. MoveToTopTest#testBringToFrontViaHeader()
Project: vaadin
File: MoveToTopTest.java
File: MoveToTopTest.java
@Test public void testBringToFrontViaHeader() throws IOException { openTestURL(); WebElement firstWindow = driver.findElement(By.className("first-window")); WebElement secondWindow = driver.findElement(By.className("second-window")); secondWindow.click(); compareScreen("second-window-over-first"); WebElement headerFirst = firstWindow.findElement(By.className("v-window-outerheader")); headerFirst.click(); compareScreen("first-window-over-second"); }
17. AddSelectionToRemovedRangeTest#addAndRemoveItemToRemovedRange()
Project: vaadin
File: AddSelectionToRemovedRangeTest.java
File: AddSelectionToRemovedRangeTest.java
@Test public void addAndRemoveItemToRemovedRange() throws IOException { openTestURL(); List<WebElement> rows = driver.findElements(By.className("v-table-cell-wrapper")); WebElement rangeStart = rows.get(0); WebElement rangeEnd = rows.get(1); rangeStart.click(); new Actions(driver).keyDown(Keys.SHIFT).perform(); rangeEnd.click(); new Actions(driver).keyUp(Keys.SHIFT).perform(); driver.findElement(By.className("v-button")).click(); WebElement extraRow = driver.findElements(By.className("v-table-cell-wrapper")).get(1); new Actions(driver).keyDown(Keys.CONTROL).click(extraRow).click(extraRow).keyUp(Keys.CONTROL).perform(); driver.findElement(By.className("v-button")).click(); try { driver.findElement(By.vaadin("Root/VNotification[0]")); Assert.fail("Notification is shown"); } catch (NoSuchElementException e) { } }
18. GridEditorBufferedTest#testSave()
Project: vaadin
File: GridEditorBufferedTest.java
File: GridEditorBufferedTest.java
@Test public void testSave() { selectMenuPath(EDIT_ITEM_100); WebElement textField = getEditorWidgets().get(0); textField.click(); // without this, the click in the middle of the field might not be after // the old text on some browsers new Actions(getDriver()).sendKeys(Keys.END).perform(); textField.sendKeys(" changed"); WebElement saveButton = getEditor().findElement(By.className("v-grid-editor-save")); saveButton.click(); assertEquals("(100, 0) changed", getGridElement().getCell(100, 0).getText()); }
19. GridEditorClientTest#testSave()
Project: vaadin
File: GridEditorClientTest.java
File: GridEditorClientTest.java
@Test public void testSave() { selectMenuPath(EDIT_ROW_100); WebElement textField = getEditor().findElements(By.className("gwt-TextBox")).get(0); textField.clear(); textField.sendKeys("Changed"); WebElement saveButton = getEditor().findElement(By.className("v-grid-editor-save")); saveButton.click(); assertEquals("Changed", getGridElement().getCell(100, 0).getText()); }
20. ModalWindowFocusTest#testModalWindowFocusPressButtonInWindow()
Project: vaadin
File: ModalWindowFocusTest.java
File: ModalWindowFocusTest.java
/** * Second scenario: press button -> two windows appear, press button in the * 2nd window -> 3rd window appears on top, press Esc three times -> all * windows should be closed */ @Test public void testModalWindowFocusPressButtonInWindow() throws IOException { waitForElementPresent(By.id("firstButton")); WebElement button = findElement(By.id("firstButton")); button.click(); waitForElementPresent(By.id("windowButton")); WebElement buttonInWindow = findElement(By.id("windowButton")); buttonInWindow.click(); waitForElementPresent(By.id("window3")); assertTrue("Third window should be opened", findElements(By.id("window3")).size() == 1); pressEscAndWait(); pressEscAndWait(); pressEscAndWait(); assertTrue("All windows should be closed", findElements(By.className("v-window")).size() == 0); }
21. TreeTableOutOfSyncTest#testNotification()
Project: vaadin
File: TreeTableOutOfSyncTest.java
File: TreeTableOutOfSyncTest.java
@Test public void testNotification() throws InterruptedException { openTestURL(); TreeTableElement treeTable = $(TreeTableElement.class).first(); List<WebElement> rows = treeTable.findElement(By.className("v-table-body")).findElements(By.tagName("tr")); WebElement treeSpacer = rows.get(0).findElement(By.className("v-treetable-treespacer")); treeSpacer.click(); sleep(100); rows = treeTable.findElement(By.className("v-table-body")).findElements(By.tagName("tr")); WebElement button = rows.get(2).findElement(By.className("v-button")); button.click(); List<WebElement> notifications = findElements(By.className("v-Notification-system")); assertTrue(notifications.isEmpty()); }
22. TreeTableContainerHierarchicalWrapperTest#testStructure()
Project: vaadin
File: TreeTableContainerHierarchicalWrapperTest.java
File: TreeTableContainerHierarchicalWrapperTest.java
@Test public void testStructure() throws InterruptedException { openTestURL(); TreeTableElement treeTable = $(TreeTableElement.class).first(); WebElement findElement = treeTable.getCell(0, 0).findElement(By.className("v-treetable-treespacer")); findElement.click(); TestBenchElement cell = treeTable.getCell(5, 0); WebElement findElement2 = cell.findElement(By.className("v-treetable-treespacer")); assertEquals("Item 0-5", cell.getText()); findElement2.click(); TestBenchElement cell2 = treeTable.getCell(10, 0); assertEquals("Item 0-5-5", cell2.getText()); }
23. LeftColumnAlignmentTest#testLeftColumnAlignment()
Project: vaadin
File: LeftColumnAlignmentTest.java
File: LeftColumnAlignmentTest.java
@Test public void testLeftColumnAlignment() throws Exception { openTestURL(); // Do align columns to the left WebElement webElement = driver.findElement(By.className("v-button")); webElement.click(); Assert.assertTrue("Table caption is not aligned to the left", isElementPresent(By.className("v-table-caption-container-align-left"))); WebElement footer = driver.findElement(By.className("v-table-footer-container")); Assert.assertEquals("Table footer is not aligned to the left", "left", footer.getCssValue("text-align")); WebElement cell = driver.findElement(By.className("v-table-cell-wrapper")); Assert.assertEquals("Table cell is not aligned to the left", "left", cell.getCssValue("text-align")); }
24. HorizontalLayoutFullsizeContentWithErrorMsgTest#test()
Project: vaadin
File: HorizontalLayoutFullsizeContentWithErrorMsgTest.java
File: HorizontalLayoutFullsizeContentWithErrorMsgTest.java
@Test public void test() { openTestURL(); WebElement element = getDriver().findElement(By.id(HorizontalLayoutFullsizeContentWithErrorMsg.FIELD_ID)); Point location = element.getLocation(); WebElement errorToggleButton = getDriver().findElement(By.id(HorizontalLayoutFullsizeContentWithErrorMsg.BUTTON_ID)); errorToggleButton.click(); Assert.assertEquals(location, element.getLocation()); errorToggleButton.click(); Assert.assertEquals(location, element.getLocation()); }
25. NativeSelectsAndChromeKeyboardNavigationTest#testValueChangeListenerWithKeyboardNavigation()
Project: vaadin
File: NativeSelectsAndChromeKeyboardNavigationTest.java
File: NativeSelectsAndChromeKeyboardNavigationTest.java
@Test public void testValueChangeListenerWithKeyboardNavigation() throws InterruptedException { setDebug(true); openTestURL(); Thread.sleep(1000); menu("Component"); menuSub("Listeners"); menuSub("Value change listener"); getDriver().findElement(By.tagName("body")).click(); WebElement select = getDriver().findElement(By.tagName("select")); select.sendKeys(Keys.ARROW_DOWN); select.sendKeys(Keys.ARROW_DOWN); select.sendKeys(Keys.ARROW_DOWN); String bodytext = getDriver().findElement(By.tagName("body")).getText(); Assert.assertTrue(bodytext.contains("new value: 'Item 1'")); Assert.assertTrue(bodytext.contains("new value: 'Item 2'")); Assert.assertTrue(bodytext.contains("new value: 'Item 3'")); }
26. FormHandlingTest#testShouldBeAbleToSendKeysFromAuxiliaryKeyboardWithOutNativeEvents()
Project: ios-driver
File: FormHandlingTest.java
File: FormHandlingTest.java
@Test public void testShouldBeAbleToSendKeysFromAuxiliaryKeyboardWithOutNativeEvents() { Configurable c = IOSDriverAugmenter.augment(driver); c.setConfiguration(WebDriverLikeCommand.SET_VALUE, "nativeEvents", false); driver.get(pages.formPage); WebElement input = driver.findElement(By.id("working")); input.sendKeys("1-800-FLOWERS"); assertEquals("1-800-FLOWERS", input.getAttribute("value")); input.clear(); input.sendKeys(AUXILIARY_KEYS); assertEquals(AUXILIARY_KEYS, input.getAttribute("value")); }
27. LogTest#shouldReturnLogTypeBrowser()
Project: ghostdriver
File: LogTest.java
File: LogTest.java
@Test public void shouldReturnLogTypeBrowser() { WebDriver d = getDriver(); d.get(server.getBaseUrl() + "/common/errors.html"); // Throw 3 errors that are logged in the Browser's console WebElement throwErrorButton = d.findElement(By.cssSelector("input[type='button']")); throwErrorButton.click(); throwErrorButton.click(); throwErrorButton.click(); // Retrieve and count the errors LogEntries logEntries = d.manage().logs().get("browser"); assertEquals(3, logEntries.getAll().size()); for (LogEntry logEntry : logEntries) { System.out.println(logEntry); } // Clears logs logEntries = d.manage().logs().get("browser"); assertEquals(0, logEntries.getAll().size()); }
28. MirrorWizardPage#setEndTime()
Project: falcon
File: MirrorWizardPage.java
File: MirrorWizardPage.java
public void setEndTime(String validityEndStr) { final DateTime validityEnd = TimeUtil.oozieDateToDate(validityEndStr); clearAndSetByNgModel("UIModel.validity.end", DateTimeFormat.forPattern("MM/dd/yyyy").print(validityEnd)); final WebElement startTimeBox = driver.findElement(By.className("endTimeBox")); final List<WebElement> startHourAndMinute = startTimeBox.findElements(By.tagName("input")); final WebElement hourText = startHourAndMinute.get(0); final WebElement minuteText = startHourAndMinute.get(1); clearAndSet(hourText, DateTimeFormat.forPattern("hh").print(validityEnd)); clearAndSet(minuteText, DateTimeFormat.forPattern("mm").print(validityEnd)); final WebElement amPmButton = startTimeBox.findElement(By.tagName("button")); if (!amPmButton.getText().equals(DateTimeFormat.forPattern("a").print(validityEnd))) { amPmButton.click(); } }
29. MirrorWizardPage#setStartTime()
Project: falcon
File: MirrorWizardPage.java
File: MirrorWizardPage.java
public void setStartTime(String validityStartStr) { final DateTime startDate = TimeUtil.oozieDateToDate(validityStartStr); clearAndSetByNgModel("UIModel.validity.start", DateTimeFormat.forPattern("MM/dd/yyyy").print(startDate)); final WebElement startTimeBox = driver.findElement(By.className("startTimeBox")); final List<WebElement> startHourAndMinute = startTimeBox.findElements(By.tagName("input")); final WebElement hourText = startHourAndMinute.get(0); final WebElement minuteText = startHourAndMinute.get(1); clearAndSet(hourText, DateTimeFormat.forPattern("hh").print(startDate)); clearAndSet(minuteText, DateTimeFormat.forPattern("mm").print(startDate)); final WebElement amPmButton = startTimeBox.findElement(By.tagName("button")); if (!amPmButton.getText().equals(DateTimeFormat.forPattern("a").print(startDate))) { amPmButton.click(); } }
30. WindowScopedContextTest#testWindowId()
Project: deltaspike
File: WindowScopedContextTest.java
File: WindowScopedContextTest.java
@Test @RunAsClient public void testWindowId() throws Exception { System.out.println("contextpath= " + contextPath); //X comment this in if you like to debug the server //X I've already reported ARQGRA-213 for it //X Thread.sleep(600000L); driver.get(new URL(contextPath, "page.xhtml").toString()); WebElement inputField = driver.findElement(By.id("test:valueInput")); inputField.sendKeys("23"); WebElement button = driver.findElement(By.id("test:saveButton")); button.click(); Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("valueOutput"), "23").apply(driver)); }
31. ViewScopedContextTest#testViewScopedContext()
Project: deltaspike
File: ViewScopedContextTest.java
File: ViewScopedContextTest.java
@Test @RunAsClient public void testViewScopedContext() throws Exception { driver.get(new URL(contextPath, "page.xhtml").toString()); WebElement inputField = driver.findElement(By.id("test:valueInput")); inputField.sendKeys("23"); WebElement button = driver.findElement(By.id("test:saveButton")); button.click(); Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("test:valueOutput"), "23").apply(driver)); }
32. InjectionDroneTest#testValidatorWithError()
Project: deltaspike
File: InjectionDroneTest.java
File: InjectionDroneTest.java
@Test @RunAsClient public void testValidatorWithError() throws MalformedURLException { driver.get(new URL(contextPath, "testValidatorConverter.xhtml").toString()); WebElement convertedValue = driver.findElement(By.id("validator:stringValue")); convertedValue.sendKeys("Wrong Value"); WebElement testConveterButton = driver.findElement(By.id("validator:testValidatorButton")); testConveterButton.click(); Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("validator:errorMessage"), "The valid value should be DeltaSpike").apply(driver)); }
33. InjectionDroneTest#testValidatorWithError()
Project: deltaspike
File: InjectionDroneTest.java
File: InjectionDroneTest.java
@Test @RunAsClient public void testValidatorWithError() throws MalformedURLException { driver.get(new URL(contextPath, "testValidatorConverter.xhtml").toString()); WebElement convertedValue = driver.findElement(By.id("validator:stringValue")); convertedValue.sendKeys("Wrong Value"); WebElement testConveterButton = driver.findElement(By.id("validator:testValidatorButton")); testConveterButton.click(); Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("validator:errorMessage"), "Not a valid value").apply(driver)); }
34. InjectionDroneTest#testConverterWithError()
Project: deltaspike
File: InjectionDroneTest.java
File: InjectionDroneTest.java
@Test @RunAsClient public void testConverterWithError() throws MalformedURLException { driver.get(new URL(contextPath, "testValidatorConverter.xhtml").toString()); WebElement convertedValue = driver.findElement(By.id("converter:convertedValue")); convertedValue.sendKeys("String Value"); WebElement testConveterButton = driver.findElement(By.id("converter:testConveterButton")); testConveterButton.click(); Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("converter:errorMessage"), "Value is not an Integer").apply(driver)); }
35. ColorPickerInputFormatsTest#setColorpickerValue()
Project: vaadin
File: ColorPickerInputFormatsTest.java
File: ColorPickerInputFormatsTest.java
private void setColorpickerValue(String value) { // Open colorpicker getDriver().findElement(By.id("colorpicker1")).click(); // Add RGB value WebElement field = getDriver().findElement(By.className("v-colorpicker-preview-textfield")); // Select all text field.sendKeys(Keys.chord(Keys.CONTROL, "a")); // Replace with rgb value field.sendKeys(value); // Submit field.sendKeys(Keys.RETURN); }
36. WebElementInteractionTest#shouldSubmitAnElement()
Project: selendroid
File: WebElementInteractionTest.java
File: WebElementInteractionTest.java
@Test() public void shouldSubmitAnElement() { openWebdriverTestPage(HtmlTestData.SAY_HELLO_DEMO); WebElement inputField = driver().findElement(By.id("name_input")); Assert.assertNotNull(inputField); inputField.clear(); inputField.sendKeys("Selendroid"); inputField.submit(); String name = (String) executeJavaScript("return document.title"); Assert.assertEquals(name, "Hello: Selendroid"); }
37. MenuNavigator#getMenuItem()
Project: rstudio
File: MenuNavigator.java
File: MenuNavigator.java
public static WebElement getMenuItem(WebDriver driver, String level1, String level2) { WebElement menuBar = driver.findElement(By.className("gwt-MenuBar")); WebElement menu1 = findMenuItemByName(menuBar, level1); menu1.click(); WebElement menu1Popup = (new WebDriverWait(driver, 1)).until(ExpectedConditions.presenceOfElementLocated(By.className("gwt-MenuBarPopup"))); return findMenuItemByName(menu1Popup, level2); }
38. LanguagePage#getMemberUsernames()
Project: zanata-server
File: LanguagePage.java
File: LanguagePage.java
public List<String> getMemberUsernames() { log.info("Query username list"); if (getMemberCount().equals("0")) { log.info("No members yet for this language"); return Collections.emptyList(); } List<String> names = new ArrayList<>(); WebElement form = existingElement(By.id("members-form")); for (WebElement listEntry : form.findElements(By.className("list__item--actionable"))) { names.add(listEntry.findElement(By.className("list__item__info")).getText().trim()); } log.info("Found {}", names); return names; }
39. PushErrorHandlingTest#testErrorHandling()
Project: vaadin
File: PushErrorHandlingTest.java
File: PushErrorHandlingTest.java
@Test public void testErrorHandling() { setPush(true); openTestURL(); vaadinElementById("npeButton").click(); int idx = 1; if (BrowserUtil.isPhantomJS(getDesiredCapabilities())) { // PhantomJS sends an extra event when page gets loaded. // This results as an extra error label. ++idx; } Assert.assertEquals("An error! Unable to invoke method click in com.vaadin.shared.ui.button.ButtonServerRpc", $(LabelElement.class).get(idx).getText()); WebElement table = vaadinElementById("testtable"); WebElement row = table.findElement(By.xpath("//div[text()='Click for NPE']")); row.click(); Assert.assertEquals("Internal error", vaadinElement("Root/VNotification[0]/HTML[0]/domChild[0]").getText()); }
40. BottomComponentScrollsUpTest#windowScrollTest()
Project: vaadin
File: BottomComponentScrollsUpTest.java
File: BottomComponentScrollsUpTest.java
@Test public void windowScrollTest() throws IOException, InterruptedException { TestBenchElement panelScrollable = (TestBenchElement) getDriver().findElement(By.className("v-panel-content")); Dimension panelScrollableSize = panelScrollable.getSize(); WebElement verticalLayout = panelScrollable.findElement(By.className("v-verticallayout")); Dimension verticalLayoutSize = verticalLayout.getSize(); panelScrollable.scroll(verticalLayoutSize.height); WebElement button = verticalLayout.findElement(By.className("v-button")); button.click(); // Loose the focus from the button. new Actions(getDriver()).moveToElement(panelScrollable, panelScrollableSize.width / 2, panelScrollableSize.height / 2).click().build().perform(); compareScreen("window"); }
41. TableWidthItemRemoveTest#testWidthResizeOnItemAdd()
Project: vaadin
File: TableWidthItemRemoveTest.java
File: TableWidthItemRemoveTest.java
@Test public void testWidthResizeOnItemAdd() { openTestURL(); WebElement populateButton = driver.findElement(By.vaadin("//Button[caption=\"Populate\"]")); WebElement table = driver.findElement(By.vaadin("//Table[caption=\"My table\"]")); int original_width = table.getSize().getWidth(); populateButton.click(); Assert.assertTrue("Width changed on item add.", original_width == table.getSize().getWidth()); }
42. TableTooManyColumnsTest#testDropdownTable()
Project: vaadin
File: TableTooManyColumnsTest.java
File: TableTooManyColumnsTest.java
@Test public void testDropdownTable() throws IOException { openTestURL(); WebElement element = findElement(By.className("v-table-column-selector")); element.click(); WebElement menu = findElement(By.className("gwt-MenuBar-vertical")); TestBenchElementCommands scrollable = testBenchElement(menu); scrollable.scroll(3000); compareScreen(getScreenshotBaseName()); }
43. TableScrollUpOnSelectTest#TestThatSelectingDoesntScroll()
Project: vaadin
File: TableScrollUpOnSelectTest.java
File: TableScrollUpOnSelectTest.java
@Test public void TestThatSelectingDoesntScroll() { openTestURL(); // WebElement table = driver.findElement(By.vaadin("//Table")); WebElement row = $(TableElement.class).first().getCell(49, 0); final WebElement scrollPositionDisplay = getDriver().findElement(By.className("v-table-scrollposition")); waitUntilNot(new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver input) { return scrollPositionDisplay.isDisplayed(); } }, 10); int rowLocation = row.getLocation().getY(); row.click(); int newRowLocation = row.getLocation().getY(); Assert.assertTrue("Table has scrolled.", rowLocation == newRowLocation); }
44. ReadOnlyOptionGroupTest#testOptionGroup()
Project: vaadin
File: ReadOnlyOptionGroupTest.java
File: ReadOnlyOptionGroupTest.java
@Test public void testOptionGroup() { setDebug(true); openTestURL(); WebElement checkbox = driver.findElement(By.className("v-checkbox")); WebElement checkboxInput = checkbox.findElement(By.tagName("input")); checkboxInput.click(); assertNoErrorNotifications(); Assert.assertFalse("Radio button in option group is still disabled " + "after unset reaonly", isElementPresent(By.className("v-radiobutton-disabled"))); }
45. GridSidebarPositionTest#popupAbove()
Project: vaadin
File: GridSidebarPositionTest.java
File: GridSidebarPositionTest.java
@Test public void popupAbove() { openTestURL(); GridElement gridPopupAbove = $(GridElement.class).id(GridSidebarPosition.POPUP_ABOVE); WebElement sidebarOpenButton = getSidebarOpenButton(gridPopupAbove); sidebarOpenButton.click(); WebElement sidebarPopup = getSidebarPopup(); Dimension popupSize = sidebarPopup.getSize(); Point popupLocation = sidebarPopup.getLocation(); int popupBottom = popupLocation.getY() + popupSize.getHeight(); int sideBarButtonTop; if (BrowserUtil.isIE8(getDesiredCapabilities())) { // IE8 gets the top coordinate for the button completely wrong for // some reason sideBarButtonTop = 660; } else { sideBarButtonTop = sidebarOpenButton.getLocation().getY(); } Assert.assertTrue(popupBottom <= sideBarButtonTop); }
46. GridSelectionTest#testSelectAllAndSort()
Project: vaadin
File: GridSelectionTest.java
File: GridSelectionTest.java
@Test public void testSelectAllAndSort() { openTestURL(); setSelectionModelMulti(); GridCellElement header = getGridElement().getHeaderCell(0, 0); header.findElement(By.tagName("input")).click(); getGridElement().getHeaderCell(0, 1).click(); WebElement selectionBox = getGridElement().getCell(4, 0).findElement(By.tagName("input")); selectionBox.click(); selectionBox.click(); assertFalse("Exception occured on row reselection.", logContainsText("Exception occured, java.lang.IllegalStateException: No item id for key 101 found.")); }
47. GridEditorBufferedTest#makeInvalidEdition()
Project: vaadin
File: GridEditorBufferedTest.java
File: GridEditorBufferedTest.java
private void makeInvalidEdition() { selectMenuPath(EDIT_ITEM_5); assertFalse(logContainsText("Exception occured, java.lang.IllegalStateException")); GridEditorElement editor = getGridElement().getEditor(); assertFalse("Field 7 should not have been marked with an error before error", editor.isFieldErrorMarked(7)); WebElement intField = editor.getField(7); intField.clear(); intField.sendKeys("banana phone"); }
48. GridEditorBufferedTest#testProgrammaticSave()
Project: vaadin
File: GridEditorBufferedTest.java
File: GridEditorBufferedTest.java
@Test public void testProgrammaticSave() { selectMenuPath(EDIT_ITEM_100); WebElement textField = getEditorWidgets().get(0); textField.click(); // without this, the click in the middle of the field might not be after // the old text on some browsers new Actions(getDriver()).sendKeys(Keys.END).perform(); textField.sendKeys(" changed"); selectMenuPath("Component", "Editor", "Save"); assertEquals("(100, 0) changed", getGridElement().getCell(100, 0).getText()); }
49. GridEditorBufferedTest#testKeyboardSave()
Project: vaadin
File: GridEditorBufferedTest.java
File: GridEditorBufferedTest.java
@Test public void testKeyboardSave() { selectMenuPath(EDIT_ITEM_100); WebElement textField = getEditorWidgets().get(0); textField.click(); // without this, the click in the middle of the field might not be after // the old text on some browsers new Actions(getDriver()).sendKeys(Keys.END).perform(); textField.sendKeys(" changed"); // Save from keyboard new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); assertEditorClosed(); assertEquals("(100, 0) changed", getGridElement().getCell(100, 0).getText()); }
50. GridEditorClientTest#testProgrammaticSave()
Project: vaadin
File: GridEditorClientTest.java
File: GridEditorClientTest.java
@Test public void testProgrammaticSave() { selectMenuPath(EDIT_ROW_100); WebElement textField = getEditor().findElements(By.className("gwt-TextBox")).get(0); textField.clear(); textField.sendKeys("Changed"); selectMenuPath("Component", "Editor", "Save"); assertEquals("Changed", getGridElement().getCell(100, 0).getText()); }
51. GridDetailsClientTest#widgetsInUpdaterWorkAsExpected()
Project: vaadin
File: GridDetailsClientTest.java
File: GridDetailsClientTest.java
@Test public void widgetsInUpdaterWorkAsExpected() { selectMenuPath(SET_GENERATOR); toggleDetailsFor(1); TestBenchElement detailsElement = getGridElement().getDetails(1); WebElement button = detailsElement.findElement(By.className("gwt-Button")); button.click(); WebElement label = detailsElement.findElement(By.className("gwt-Label")); assertEquals("clicked", label.getText()); }
52. DragAndDropTextAreaTest#testTextAreaDndImage()
Project: vaadin
File: DragAndDropTextAreaTest.java
File: DragAndDropTextAreaTest.java
@Test public void testTextAreaDndImage() { openTestURL(); WebElement wrapper = driver.findElement(By.className("v-verticallayout")); Actions actions = new Actions(driver); actions.clickAndHold(wrapper); actions.moveByOffset(50, 50); actions.perform(); WebElement dragElement = driver.findElement(By.className("v-drag-element")); List<WebElement> children = dragElement.findElements(By.xpath(".//*")); boolean found = false; for (WebElement child : children) { if ("text".equals(child.getAttribute("value"))) { found = true; } } Assert.assertTrue("Text value is not found in the DnD image of text area", found); }
53. DateFieldKeyboardInputTest#testValueChangeEvent()
Project: vaadin
File: DateFieldKeyboardInputTest.java
File: DateFieldKeyboardInputTest.java
@Test public void testValueChangeEvent() { openTestURL(); WebElement dateFieldText = $(DateFieldElement.class).first().findElement(By.tagName("input")); dateFieldText.clear(); int numLabelsBeforeUpdate = $(LabelElement.class).all().size(); dateFieldText.sendKeys("20.10.2013", Keys.RETURN); int numLabelsAfterUpdate = $(LabelElement.class).all().size(); assertTrue("Changing the date failed.", numLabelsAfterUpdate == numLabelsBeforeUpdate + 1); }
54. ComboBoxSuggestionPopupWidthTest#suggestionPopupWidthTest()
Project: vaadin
File: ComboBoxSuggestionPopupWidthTest.java
File: ComboBoxSuggestionPopupWidthTest.java
@Test public void suggestionPopupWidthTest() throws Exception { openTestURL(); waitForElementVisible(By.className("width-as-percentage")); WebElement selectTextbox = $(ComboBoxElement.class).first().findElement(By.vaadin("#textbox")); selectTextbox.click(); CustomComboBoxElement cb = $(CustomComboBoxElement.class).first(); cb.openPopup(); WebElement popup = cb.getSuggestionPopup(); int width = popup.getSize().getWidth(); assertTrue(width == 200); }
55. ComboBoxSuggestionPopupWidthPixelsTest#suggestionPopupFixedWidthTest()
Project: vaadin
File: ComboBoxSuggestionPopupWidthPixelsTest.java
File: ComboBoxSuggestionPopupWidthPixelsTest.java
@Test public void suggestionPopupFixedWidthTest() throws Exception { openTestURL(); waitForElementVisible(By.className("pixels")); WebElement selectTextbox = $(ComboBoxElement.class).first().findElement(By.vaadin("#textbox")); selectTextbox.click(); CustomComboBoxElement cb = $(CustomComboBoxElement.class).first(); cb.openPopup(); WebElement popup = cb.getSuggestionPopup(); int width = popup.getSize().getWidth(); assertTrue(width == 300); }
56. ComboBoxSuggestionPopupWidthPercentageTest#suggestionPopupPersentageWidthTest()
Project: vaadin
File: ComboBoxSuggestionPopupWidthPercentageTest.java
File: ComboBoxSuggestionPopupWidthPercentageTest.java
@Test public void suggestionPopupPersentageWidthTest() throws Exception { openTestURL(); waitForElementVisible(By.className("percentage")); WebElement selectTextbox = $(ComboBoxElement.class).first().findElement(By.vaadin("#textbox")); selectTextbox.click(); CustomComboBoxElement cb = $(CustomComboBoxElement.class).first(); cb.openPopup(); WebElement popup = cb.getSuggestionPopup(); int width = popup.getSize().getWidth(); assertTrue(width == 400); }
57. ComboBoxSuggestionPopupWidthLegacyTest#suggestionPopupLegacyWidthTest()
Project: vaadin
File: ComboBoxSuggestionPopupWidthLegacyTest.java
File: ComboBoxSuggestionPopupWidthLegacyTest.java
@Test public void suggestionPopupLegacyWidthTest() throws Exception { openTestURL(); waitForElementVisible(By.className("legacy")); WebElement selectTextbox = $(ComboBoxElement.class).first().findElement(By.vaadin("#textbox")); selectTextbox.click(); CustomComboBoxElement cb = $(CustomComboBoxElement.class).first(); cb.openPopup(); WebElement popup = cb.getSuggestionPopup(); int width = popup.getSize().getWidth(); assertGreater("Legacy mode popup should be quite wide", width, 600); assertLessThan("Even legacy mode popup should not be over 1000px wide with the set item captions ", width, 1000); }
58. ComboBoxSetNullWhenNewItemsAllowedTest#testNewValueIsClearedAppropriately()
Project: vaadin
File: ComboBoxSetNullWhenNewItemsAllowedTest.java
File: ComboBoxSetNullWhenNewItemsAllowedTest.java
@Test public void testNewValueIsClearedAppropriately() throws InterruptedException { setDebug(true); openTestURL(); WebElement element = $(ComboBoxElement.class).first().findElement(By.vaadin("#textbox")); ((TestBenchElementCommands) element).click(8, 7); element.clear(); element.sendKeys("New value"); assertEquals("New value", element.getAttribute("value")); if (BrowserUtil.isPhantomJS(getDesiredCapabilities())) { new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); Thread.sleep(500); } else { element.sendKeys(Keys.RETURN); } assertEquals("", element.getAttribute("value")); }
59. ComboBoxClosePopupRetainTextTest#testClosePopupRetainText_selectingAValue()
Project: vaadin
File: ComboBoxClosePopupRetainTextTest.java
File: ComboBoxClosePopupRetainTextTest.java
@Test public void testClosePopupRetainText_selectingAValue() throws Exception { openTestURL(); ComboBoxElement cb = $(ComboBoxElement.class).first(); cb.selectByText("Item 3"); WebElement textbox = cb.findElement(By.vaadin("#textbox")); textbox.clear(); textbox.sendKeys("I"); cb.openPopup(); // Entered value should remain in the text field even though the popup // is opened assertEquals("I", textbox.getAttribute("value")); }
60. AccordionRemoveTabTest#testConsoleErrorOnSwitch()
Project: vaadin
File: AccordionRemoveTabTest.java
File: AccordionRemoveTabTest.java
@Test public void testConsoleErrorOnSwitch() { setDebug(true); openTestURL(); WebElement firstItem = driver.findElement(By.className("v-accordion-item-first")); WebElement caption = firstItem.findElement(By.className("v-accordion-item-caption")); caption.click(); Assert.assertEquals("Errors present in console", 0, findElements(By.className("SEVERE")).size()); }
61. AccordionRemoveTabTest#testRemoveTab()
Project: vaadin
File: AccordionRemoveTabTest.java
File: AccordionRemoveTabTest.java
@Test public void testRemoveTab() { openTestURL(); WebElement button = driver.findElement(By.className("v-button")); button.click(); checkFirstItemHeight("On second tab"); button.click(); checkFirstItemHeight("On third tab"); }
62. WebChildElementFindingTest#shouldFindElementsByPartialTextAndClick()
Project: selendroid
File: WebChildElementFindingTest.java
File: WebChildElementFindingTest.java
@Test public void shouldFindElementsByPartialTextAndClick() throws Exception { openWebdriverTestPage(HtmlTestData.XHTML_TEST_PAGE); WebElement rootElement = driver().findElement(By.className("content")); WebElement clickMe = rootElement.findElements(By.partialLinkText("click m")).get(0); clickMe.click(); TestWaiter.waitFor(WaitingConditions.pageTitleToBe(driver(), "We Arrive Here"), 15, TimeUnit.SECONDS); Assert.assertEquals(driver().getTitle(), "We Arrive Here"); }
63. WebChildElementFindingTest#shouldFindElementByCss()
Project: selendroid
File: WebChildElementFindingTest.java
File: WebChildElementFindingTest.java
@Test public void shouldFindElementByCss() { openWebdriverTestPage(HtmlTestData.XHTML_TEST_PAGE); WebElement rootElement = driver().findElement(By.className("content")); WebElement e = rootElement.findElement(By.cssSelector("a[id='linkId']")); try { Thread.sleep(2000); } catch (InterruptedException e1) { e1.printStackTrace(); } e.click(); TestWaiter.waitFor(WaitingConditions.pageTitleToBe(driver(), "We Arrive Here"), 15, TimeUnit.SECONDS); Assert.assertEquals(driver().getTitle(), "We Arrive Here"); }
64. CommandConfigurationTest#shouldSetJapaneseTextIntoWebInputField()
Project: selendroid
File: CommandConfigurationTest.java
File: CommandConfigurationTest.java
@Test public void shouldSetJapaneseTextIntoWebInputField() { openWebdriverTestPage(HtmlTestData.SAY_HELLO_DEMO); Configuration configurable = (Configuration) driver(); configurable.setConfiguration(DriverCommand.SEND_KEYS_TO_ELEMENT, "nativeEvents", false); String text = "?????"; WebElement inputField = driver().findElement(By.id("name_input")); Assert.assertNotNull(inputField); inputField.clear(); inputField.sendKeys(text); Assert.assertEquals(text, inputField.getAttribute("value")); }
65. RemoteUIAElementTest#isVisibleTests()
Project: ios-driver
File: RemoteUIAElementTest.java
File: RemoteUIAElementTest.java
@Test public void isVisibleTests() { WebElement navBar = driver.findElement(By.tagName("UIANavigationBar")); Assert.assertTrue(navBar.isDisplayed(), "nav bar"); List<WebElement> imgs = navBar.findElements(By.className("UIAImage")); Assert.assertEquals(imgs.size(), 2, "number of images in the menu"); for (WebElement el : imgs) { Assert.assertFalse(el.isDisplayed(), "image"); } WebElement text = navBar.findElement(By.className("UIAStaticText")); Assert.assertTrue(text.isDisplayed(), "nav bar text"); }
66. ActionSheetTest#findWhenAlertAreGone()
Project: ios-driver
File: ActionSheetTest.java
File: ActionSheetTest.java
@Test public void findWhenAlertAreGone() throws Exception { By b = By.xpath(actionOKCancel); WebElement el = driver.findElement(b); el.click(); Alert alert = driver.switchTo().alert(); try { el.click(); Assert.fail(); } catch (UnhandledAlertException e) { } alert.accept(); el.click(); driver.switchTo().alert(); alert.accept(); }
67. FrameSwitchingTest#testShouldContinueToReferToTheSameFrameOnceItHasBeenSelected()
Project: ios-driver
File: FrameSwitchingTest.java
File: FrameSwitchingTest.java
// ---------------------------------------------------------------------------------------------- // // General frame handling behavior tests // // ---------------------------------------------------------------------------------------------- //@Ignore(ANDROID) @Test public void testShouldContinueToReferToTheSameFrameOnceItHasBeenSelected() { driver.get(pages.framesetPage); driver.switchTo().frame(2); WebElement checkbox = driver.findElement(By.xpath("//input[@name='checky']")); checkbox.click(); // IOS click takes some time to register. Need to wait for the result of that click before // continuing. waitFor(WaitingConditions.elementSelectionToBe(checkbox, true)); checkbox.submit(); // TODO(simon): this should not be needed, and is only here because IE's // submit returns too // soon. waitFor(WaitingConditions.elementTextToEqual(driver, By.xpath("//p"), "Success!")); }
68. FormHandlingTest#testShouldBeAbleToClearTextFromTextAreas()
Project: ios-driver
File: FormHandlingTest.java
File: FormHandlingTest.java
@Test public void testShouldBeAbleToClearTextFromTextAreas() { driver.get(pages.formPage); WebElement element = driver.findElement(By.id("withText")); element.sendKeys("Some text"); String value = element.getAttribute("value"); assertTrue(value.length() > 0); element.clear(); value = element.getAttribute("value"); assertEquals(value.length(), (0)); }
69. FormHandlingTest#testShouldBeAbleToClearTextFromInputElements()
Project: ios-driver
File: FormHandlingTest.java
File: FormHandlingTest.java
@Test public void testShouldBeAbleToClearTextFromInputElements() { driver.get(pages.formPage); WebElement element = driver.findElement(By.id("working")); element.sendKeys("Some text"); String value = element.getAttribute("value"); assertTrue(value.length() > 0); element.clear(); value = element.getAttribute("value"); assertEquals(value.length(), (0)); }
70. FormHandlingTest#testShouldScrollWhenZoomed()
Project: ios-driver
File: FormHandlingTest.java
File: FormHandlingTest.java
@Test public // end up where the tap was done. void testShouldScrollWhenZoomed() throws InterruptedException { driver.get(pages.formPage); WebElement element = driver.findElement(By.id("email")); element.sendKeys("[email protected]"); element = driver.findElement(By.id("vsearchGadget")); element.sendKeys("test"); }
71. FormHandlingTest#testSendingKeyboardEventsShouldAppendTextInInputs()
Project: ios-driver
File: FormHandlingTest.java
File: FormHandlingTest.java
// @Ignore(value = { IPHONE, OPERA }, reason = // "iPhone: sendKeys implemented incorrectly.") @Test public // end up where the tap was done. void testSendingKeyboardEventsShouldAppendTextInInputs() { driver.get(pages.formPage); WebElement element = driver.findElement(By.id("working")); element.sendKeys("some"); String value = element.getAttribute("value"); assertEquals(value, ("some")); element.sendKeys(" text"); value = element.getAttribute("value"); assertEquals(value, ("some text")); }
72. FormHandlingTest#testShouldEnterDataIntoFormFields()
Project: ios-driver
File: FormHandlingTest.java
File: FormHandlingTest.java
@Test public void testShouldEnterDataIntoFormFields() { driver.get(pages.xhtmlTestPage); WebElement element = driver.findElement(By.xpath("//form[@name='someForm']/input[@id='username']")); String originalValue = element.getAttribute("value"); assertEquals(originalValue, ("change")); element.clear(); element.sendKeys("some text"); element = driver.findElement(By.xpath("//form[@name='someForm']/input[@id='username']")); String newFormValue = element.getAttribute("value"); assertEquals(newFormValue, ("some text")); }
73. GoogleSearchTest#searchForCheese()
Project: ghostdriver
File: GoogleSearchTest.java
File: GoogleSearchTest.java
@Test public void searchForCheese() { String strToSearchFor = "Cheese!"; WebDriver d = getDriver(); // Load Google.com d.get(" http://www.google.com"); // Locate the Search field on the Google page WebElement element = d.findElement(By.name("q")); // Type Cheese element.sendKeys(strToSearchFor); // Submit form element.submit(); // Check results contains the term we searched for assertTrue(d.getTitle().toLowerCase().contains(strToSearchFor.toLowerCase())); }
74. FileUploadTest#checkOnChangeEventIsFiredOnFileUpload()
Project: ghostdriver
File: FileUploadTest.java
File: FileUploadTest.java
@Test public void checkOnChangeEventIsFiredOnFileUpload() throws IOException { WebDriver d = getDriver(); d.get(server.getBaseUrl() + "/common/formPage.html"); WebElement uploadElement = d.findElement(By.id("upload")); WebElement result = d.findElement(By.id("fileResults")); assertEquals("", result.getText()); File file = File.createTempFile("test", "txt"); file.deleteOnExit(); uploadElement.sendKeys(file.getAbsolutePath()); // Shift focus to something else because send key doesn't make the focus leave d.findElement(By.id("id-name1")).click(); assertEquals("changed", result.getText()); }
75. ElementMethodsTest#shouldUsePageTimeoutToWaitForPageLoadOnInput()
Project: ghostdriver
File: ElementMethodsTest.java
File: ElementMethodsTest.java
@Test public void shouldUsePageTimeoutToWaitForPageLoadOnInput() throws InterruptedException { WebDriver d = getDriver(); String inputString = "clicking"; d.get("http://www.duckduckgo.com"); WebElement textInput = d.findElement(By.cssSelector("#search_form_input_homepage")); assertFalse(d.getTitle().contains(inputString)); textInput.click(); assertFalse(d.getTitle().contains(inputString)); // This input will ALSO submit the search form, causing a Page Load textInput.sendKeys(inputString + "\n"); assertTrue(d.getTitle().contains(inputString)); }
76. ElementMethodsTest#SubmittingFormShouldFireOnSubmitForThatForm()
Project: ghostdriver
File: ElementMethodsTest.java
File: ElementMethodsTest.java
@Test public void SubmittingFormShouldFireOnSubmitForThatForm() { WebDriver d = getDriver(); d.get(server.getBaseUrl() + "/common/javascriptPage.html"); WebElement formElement = d.findElement(By.id("submitListeningForm")); formElement.submit(); WebDriverWait wait = new WebDriverWait(d, 30); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("result"), "form-onsubmit")); WebElement result = d.findElement(By.id("result")); String text = result.getText(); boolean conditionMet = text.contains("form-onsubmit"); assertTrue(conditionMet); }
77. PageHeader#validateNotificationCountAndCheckLast()
Project: falcon
File: PageHeader.java
File: PageHeader.java
/** * Validates number of notifications contained by notification bar and last notification message. */ public void validateNotificationCountAndCheckLast(int count, String message) { WebElement notificationButton = getNotificationButton(); notificationButton.click(); waitForAngularToFinish(); // Test notifications dropdown visibility WebElement notificationDropdown = notificationButton.findElement(By.className("messages")); Assert.assertTrue(notificationDropdown.getAttribute("style").contains("display: block;"), "Notifications are not visible."); // Test validity of number of notifications List<WebElement> notifications = notificationDropdown.findElements(By.xpath("div")); Assert.assertEquals(notifications.size() - 1, count, "Invalid notification count."); // Test validity of last notification String lastNotification = notifications.get(0).getText(); Assert.assertTrue(lastNotification.contains(message), "Invalid last notification text."); }
78. NavigationParameterTest#testNavigationActionWithParameter()
Project: deltaspike
File: NavigationParameterTest.java
File: NavigationParameterTest.java
@Test @RunAsClient public void testNavigationActionWithParameter() throws MalformedURLException { //first click driver.get(new URL(contextPath, "origin.xhtml").toString()); WebElement button = driver.findElement(By.id("parameter:pb004ActionMethod")); button.click(); //second click driver.get(new URL(contextPath, "origin.xhtml").toString()); button = driver.findElement(By.id("parameter:pb004ActionMethod")); button.click(); Assert.assertTrue(ExpectedConditions.textToBePresentInElement(By.id("simplePageConfig"), "You arrived at simplePageConfig page").apply(driver)); Assert.assertTrue(driver.getCurrentUrl().contains("&cv=")); }
79. StandardFunctionsFlowTest#addRemotePlugin()
Project: crawljax
File: StandardFunctionsFlowTest.java
File: StandardFunctionsFlowTest.java
private void addRemotePlugin() { open("plugins"); List<WebElement> refreshLink = driver.findElements(By.linkText("Refresh List")); followLink(refreshLink.get(0)); WebElement urlInput = driver.findElement(By.xpath("//label[contains(text(),'URL:')]/following-sibling::input[@type='text']")); urlInput.sendKeys(REMOTE_PLUGIN_URL); List<WebElement> downloadLink = driver.findElements(By.linkText("Download Remote Plugin")); followLink(downloadLink.get(0)); WebElement uploaded = (new WebDriverWait(driver, 10)).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//legend[contains(text(),'Available Plugins')]/following-sibling::table//tbody//tr" + "//td[contains(text(),'" + REMOTE_PLUGIN_NAME + "')]"))); assertNotNull(uploaded); }
80. StandardFunctionsFlowTest#addLocalPlugin()
Project: crawljax
File: StandardFunctionsFlowTest.java
File: StandardFunctionsFlowTest.java
private void addLocalPlugin() { open("plugins"); List<WebElement> refreshLink = driver.findElements(By.linkText("Refresh List")); followLink(refreshLink.get(0)); WebElement fileInput = driver.findElement(By.xpath("//input[@type='file']")); String fileName = getClass().getClassLoader().getResource(LOCAL_PLUGIN_ID + ".jar").toExternalForm(); fileInput.sendKeys(fileName); List<WebElement> uploadLink = driver.findElements(By.linkText("Upload Local Plugin")); followLink(uploadLink.get(0)); WebElement uploaded = (new WebDriverWait(driver, 10)).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//legend[contains(text(),'Available Plugins')]/following-sibling::table//tbody//tr" + "//td[contains(text(),'" + LOCAL_PLUGIN_NAME + "')]"))); assertNotNull(uploaded); }
81. CreateVersionPage#selectProjectType()
Project: zanata-server
File: CreateVersionPage.java
File: CreateVersionPage.java
public CreateVersionPage selectProjectType(final String projectType) { log.info("Click project type {}", projectType); WebElement projectTypeCheck = waitForAMoment().until((Function<WebDriver, WebElement>) webDriver -> { for (WebElement item : readyElement(projectTypeSelection).findElements(By.tagName("li"))) { if (item.findElement(By.tagName("label")).getText().startsWith(projectType)) { return item; } } return null; }); projectTypeCheck.click(); return new CreateVersionPage(getDriver()); }
82. PageForm#select()
Project: vraptor4
File: PageForm.java
File: PageForm.java
public PageForm select(By by, String value) { WebElement select = form.findElement(by); By byOption = tagName("option"); List<WebElement> options = select.findElements(byOption); for (WebElement option : options) { String optionValue = option.getAttribute("value"); if (optionValue.equals(value)) option.click(); } return this; }
83. TooltipWidthUpdatingTest#testTooltipWidthUpdating()
Project: vaadin
File: TooltipWidthUpdatingTest.java
File: TooltipWidthUpdatingTest.java
@Test public void testTooltipWidthUpdating() { openTestURL(); WebElement btnLongTooltip = vaadinElementById("longTooltip"); WebElement btnShortTooltip = vaadinElementById("shortTooltip"); moveMouseToTopLeft(btnLongTooltip); testBenchElement(btnLongTooltip).showTooltip(); moveMouseToTopLeft(btnShortTooltip); testBenchElement(btnShortTooltip).showTooltip(); assertThat(getDriver().findElement(By.className("popupContent")).getSize().getWidth(), lessThan(TooltipWidthUpdating.MAX_WIDTH)); }
84. ButtonTooltipsTest#tooltipSizeWhenMovingBetweenElements()
Project: vaadin
File: ButtonTooltipsTest.java
File: ButtonTooltipsTest.java
@Test public void tooltipSizeWhenMovingBetweenElements() throws Exception { openTestURL(); WebElement buttonOne = $(ButtonElement.class).caption("One").first(); WebElement buttonTwo = $(ButtonElement.class).caption("Two").first(); checkTooltip(buttonOne, ButtonTooltips.longDescription); int originalWidth = getTooltipElement().getSize().getWidth(); int originalHeight = getTooltipElement().getSize().getHeight(); clearTooltip(); checkTooltip(buttonTwo, ButtonTooltips.shortDescription); moveMouseTo(buttonOne, 5, 5); sleep(100); assertThat(getTooltipElement().getSize().getWidth(), is(originalWidth)); assertThat(getTooltipElement().getSize().getHeight(), is(originalHeight)); }
85. ResponsiveStylesTest#testValoMenuResponsiveParentSize()
Project: vaadin
File: ResponsiveStylesTest.java
File: ResponsiveStylesTest.java
/** * Tests that valo-menu-responsive can be used in any element on the page, * not just as top-level component. * * @throws Exception */ @Test public void testValoMenuResponsiveParentSize() throws Exception { openTestURL(); List<WebElement> menus = findElements(com.vaadin.testbench.By.className(MENU_STYLENAME)); WebElement narrowMenu = menus.get(NARROW_ELEMENT_INDEX); int narrowWidth = narrowMenu.getSize().width; assertThat(narrowWidth, equalTo(NARROW_WIDTH)); WebElement wideMenu = menus.get(WIDE_ELEMENT_INDEX); int wideWidth = wideMenu.getSize().width; assertThat(wideWidth, equalTo(WIDE_WIDTH)); compareScreen("defaultMenuWidths"); }
86. NotificationStyleTest#testNotificationPStyle()
Project: vaadin
File: NotificationStyleTest.java
File: NotificationStyleTest.java
@Test public void testNotificationPStyle() { openTestURL(); $(ButtonElement.class).get(1).click(); new Actions(getDriver()).moveByOffset(10, 10).perform(); waitUntil(notificationPresentCondition(), 2); WebElement notification = findElement(By.className("v-Notification")); WebElement description = notification.findElement(By.className("v-Notification-description")); String display = description.getCssValue("display"); String displayP2 = notification.findElement(By.className("tested-p")).getCssValue("display"); Assert.assertNotEquals("Styles for notification defined 'p' tag " + "and custom HTML tag are the same", display, displayP2); }
87. DisabledLabelTest#disabledLabelOpacity()
Project: vaadin
File: DisabledLabelTest.java
File: DisabledLabelTest.java
@Test public void disabledLabelOpacity() { openTestURL(); WebElement enabled = findElement(By.className("my-enabled")); String enabledOpacity = enabled.getCssValue("opacity"); WebElement disabled = findElement(By.className("my-disabled")); String disabledOpacity = disabled.getCssValue("opacity"); Assert.assertNotEquals("Opacity value is the same for enabled and disabled label", enabledOpacity, disabledOpacity); }
88. AlignTopIconInButtonTest#iconIsCenteredInsideButton()
Project: vaadin
File: AlignTopIconInButtonTest.java
File: AlignTopIconInButtonTest.java
@Test public void iconIsCenteredInsideButton() { openTestURL(); WebElement wrapper = findElement(By.className("v-button-wrap")); WebElement icon = wrapper.findElement(By.className("v-icon")); int leftSpace = icon.getLocation().getX() - wrapper.getLocation().getX(); int rightSpace = wrapper.getLocation().getX() + wrapper.getSize().getWidth() - icon.getLocation().getX() - icon.getSize().getWidth(); assertThat(Math.abs(rightSpace - leftSpace), is(lessThanOrEqualTo(2))); }
89. LegacyComponentThemeChangeTest#assertEmbeddedTheme()
Project: vaadin
File: LegacyComponentThemeChangeTest.java
File: LegacyComponentThemeChangeTest.java
private void assertEmbeddedTheme(String theme) { if (BrowserUtil.isIE8(getDesiredCapabilities()) || BrowserUtil.isChrome(getDesiredCapabilities())) { // IE8 and Chrome 47 won't initialize the dummy flash properly return; } EmbeddedElement e = $(EmbeddedElement.class).first(); WebElement movieParam = e.findElement(By.xpath(".//param[@name='movie']")); WebElement embed = e.findElement(By.xpath(".//embed")); assertAttributePrefix(movieParam, "value", theme); assertAttributePrefix(embed, "src", theme); assertAttributePrefix(embed, "movie", theme); }
90. TooltipTest#checkTooltip()
Project: vaadin
File: TooltipTest.java
File: TooltipTest.java
protected void checkTooltip(String value) throws Exception { WebElement body = findElement(By.cssSelector("body")); WebElement tooltip = getTooltip(); Assert.assertEquals(value, tooltip.getText()); Assert.assertTrue("Tooltip overflowed to the left", tooltip.getLocation().getX() >= 0); Assert.assertTrue("Tooltip overflowed up", tooltip.getLocation().getY() >= 0); Assert.assertTrue("Tooltip overflowed to the right", tooltip.getLocation().getX() + tooltip.getSize().getWidth() < body.getSize().getWidth()); Assert.assertTrue("Tooltip overflowed down", tooltip.getLocation().getY() + tooltip.getSize().getHeight() < body.getSize().getHeight()); }
91. BasicCrudGridEditorRowTest#editorRowOneInvalidValue()
Project: vaadin
File: BasicCrudGridEditorRowTest.java
File: BasicCrudGridEditorRowTest.java
@Test public void editorRowOneInvalidValue() throws Exception { GridCellElement ritaBirthdate = grid.getCell(2, 3); // Open editor row new Actions(getDriver()).doubleClick(ritaBirthdate).perform(); GridEditorElement editor = grid.getEditor(); DateFieldElement dateField = editor.$(DateFieldElement.class).first(); WebElement input = dateField.findElement(By.xpath("input")); // input.click(); input.sendKeys("Invalid", Keys.TAB); editor.save(); Assert.assertTrue("Editor wasn't displayed.", editor.isDisplayed()); Assert.assertTrue("DateField wasn't displayed.", dateField.isDisplayed()); Assert.assertTrue("DateField didn't have 'v-invalid' css class.", hasCssClass(dateField, "v-datefield-error")); }
92. DnDOnSubtreeTest#testDragAndDropOnSubTrees()
Project: vaadin
File: DnDOnSubtreeTest.java
File: DnDOnSubtreeTest.java
@Test public void testDragAndDropOnSubTrees() throws Exception { openTestURL(); TreeElement tree = $(TreeElement.class).first(); WebElement bar2 = tree.findElement(By.vaadin("#n[3]")); WebElement bar5 = tree.findElement(By.vaadin("#n[6]")); new Actions(driver).moveToElement(bar2, 11, 8).clickAndHold().moveByOffset(10, 10).perform(); /* Drop on Bar5, which is a subtree target */ new Actions(driver).moveToElement(bar5, 34, 9).release().perform(); testBenchElement(tree.findElement(By.vaadin("#n[5]/expand"))).click(5, 5); /* Assert that the dragged & dropped node is now a child of Bar5 */ waitUntilElementPresent(tree, "#n[5]/n[0]"); }
93. WindowShadowTest#dragBackgroundWindow()
Project: vaadin
File: WindowShadowTest.java
File: WindowShadowTest.java
@Test public void dragBackgroundWindow() throws AWTException, IOException, InterruptedException { openTestURL(); WebElement wnd = getDriver().findElement(By.id("topwindow")); // There is some bug in Selenium. Can't move window using header // need use footer instead. WebElement wnd1Footer = wnd.findElement(By.className("v-window-footer")); Point startLoc = wnd.getLocation(); Coordinates footerCoordinates = ((Locatable) wnd1Footer).getCoordinates(); Mouse mouse = ((HasInputDevices) getDriver()).getMouse(); mouse.mouseDown(footerCoordinates); mouse.mouseMove(footerCoordinates, 200, 200); mouse.mouseUp(footerCoordinates); Point endLoc = wnd.getLocation(); // don't compare to specific coordinate, because in IE9 and IE11 // the window position is random. // So, checkt that the window was moved org.junit.Assert.assertNotEquals(startLoc, endLoc); }
94. ToolTipInWindowTest#testToolTipInContent()
Project: vaadin
File: ToolTipInWindowTest.java
File: ToolTipInWindowTest.java
@Test public void testToolTipInContent() throws Exception { openTestURL(); WebElement header = driver.findElement(By.className("v-window-contents")); new Actions(driver).moveToElement(driver.findElement(By.className("v-ui")), 0, 300).perform(); sleep(500); new Actions(driver).moveToElement(header).perform(); sleep(1000); WebElement ttip = findElement(By.className("v-tooltip")); assertNotNull(ttip); assertEquals("Tooltip", ttip.getText()); }
95. ToolTipInWindowTest#testToolTipInHeader()
Project: vaadin
File: ToolTipInWindowTest.java
File: ToolTipInWindowTest.java
@Test public void testToolTipInHeader() throws Exception { openTestURL(); WebElement header = driver.findElement(By.className("v-window-outerheader")); new Actions(driver).moveToElement(driver.findElement(By.className("v-ui")), 0, 0).perform(); sleep(500); new Actions(driver).moveToElement(header).perform(); sleep(1100); WebElement ttip = findElement(By.className("v-tooltip")); assertNotNull(ttip); assertEquals("Tooltip", ttip.getText()); }
96. ModalWindowFocusTest#testModalWindowFocusTwoWindows()
Project: vaadin
File: ModalWindowFocusTest.java
File: ModalWindowFocusTest.java
/** * First scenario: press button -> two windows appear, press Esc two times * -> all windows should be closed */ @Test public void testModalWindowFocusTwoWindows() throws IOException { waitForElementPresent(By.id("firstButton")); WebElement button = findElement(By.id("firstButton")); button.click(); waitForElementPresent(By.id("windowButton")); assertTrue("Second window should be opened", findElements(By.id("windowButton")).size() == 1); pressEscAndWait(); pressEscAndWait(); assertTrue("All windows should be closed", findElements(By.className("v-window")).size() == 0); }
97. UploadTitleWithTooltipTest#testDropdownTable()
Project: vaadin
File: UploadTitleWithTooltipTest.java
File: UploadTitleWithTooltipTest.java
@Test public void testDropdownTable() throws Exception { openTestURL(); List<WebElement> elements = findElements(By.tagName("input")); WebElement input = null; for (WebElement element : elements) { if ("file".equals(element.getAttribute("type"))) { input = element; } } Assert.assertNotNull("Input element with type 'file' is not found", input); checkTooltip(input, "tootlip"); compareScreen(getScreenshotBaseName()); }
98. FirstTabNotVisibleWhenTabsheetNotClippedTest#testShowPreviouslyHiddenTab()
Project: vaadin
File: FirstTabNotVisibleWhenTabsheetNotClippedTest.java
File: FirstTabNotVisibleWhenTabsheetNotClippedTest.java
@Test public void testShowPreviouslyHiddenTab() { openTestURL(); $(ButtonElement.class).caption("show tab D").get(0).click(); $(ButtonElement.class).caption("show tab C").get(0).click(); WebElement firstTab = $(TabSheetElement.class).get(2).findElement(By.className("v-tabsheet-tabitemcell-first")); String firstCaption = firstTab.findElement(By.className("v-captiontext")).getText(); org.junit.Assert.assertEquals("tab C", firstCaption); $(ButtonElement.class).caption("show tab D").get(1).click(); $(ButtonElement.class).caption("show tab C").get(1).click(); WebElement secondTab = $(TabSheetElement.class).get(3).findElement(By.className("v-tabsheet-tabitemcell-first")); String secondCaption = secondTab.findElement(By.className("v-captiontext")).getText(); org.junit.Assert.assertEquals("tab C", secondCaption); }
99. ReloadWidgetsTest#testScrollingThenUpdatingContents()
Project: vaadin
File: ReloadWidgetsTest.java
File: ReloadWidgetsTest.java
@Test public void testScrollingThenUpdatingContents() throws Exception { // Scroll down to row 44 so that we get the cut-off point where the // problem becomes apparent testBenchElement(wrapper).scroll(44 * rowHeight); waitForScrollToFinish(); // Assert that we have the button widget. Assert.assertTrue("Button widget was not found after scrolling for the first time", !findElements(By.id("46")).isEmpty()); // Now refresh the container contents WebElement refreshButton = findElement(By.id("refresh")); refreshButton.click(); // Again scroll down to row 44 so we get the cut-off point visible testBenchElement(wrapper).scroll(44 * rowHeight); waitForScrollToFinish(); // Assert that we still get the button Assert.assertTrue("Button widget was not found after refreshing container items.", !findElements(By.id("46")).isEmpty()); }
100. DndEmptyTableTest#testDndEmptyTable()
Project: vaadin
File: DndEmptyTableTest.java
File: DndEmptyTableTest.java
@Test public void testDndEmptyTable() { setDebug(true); openTestURL(); WebElement source = driver.findElement(By.className("v-ddwrapper")); WebElement target = driver.findElement(By.className("v-table-body")); Actions actions = new Actions(driver); actions.clickAndHold(source).moveToElement(target).release(); assertNoErrorNotifications(); }