List of usage examples for org.openqa.selenium.support.ui ExpectedConditions visibilityOfElementLocated
public static ExpectedCondition<WebElement> visibilityOfElementLocated(final By locator)
From source file:com.formkiq.web.OAuthFederationIntegrationTest.java
License:Apache License
/** * testOauth01().//from w w w . j a va 2s.co m * save blank oauth federation * * @throws Exception Exception */ @Test public void testOauth01() throws Exception { // given // when findElementBy(By.id("oauth_add_button")).click(); getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("form-modal"))); click(By.name("_eventId_next")); // then waitUntilPageSourceText("Field required"); }
From source file:com.formkiq.web.OAuthFederationIntegrationTest.java
License:Apache License
/** * testOauth02()./*from w ww .ja v a 2 s . co m*/ * add oauth federation * * @throws Exception Exception */ @Test public void testOauth02() throws Exception { // given // when findElementBy(By.id("oauth_add_button")).click(); getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("form-modal"))); findElementBy("input", "data-valuekey", "domain").sendKeys("222"); findElementBy("input", "data-valuekey", "username").sendKeys("333"); findElementBy("input", "data-valuekey", "host").sendKeys("444"); click(By.name("_eventId_next")); // then getWait().until(ExpectedConditions.invisibilityOfElementLocated(By.id("form-modal"))); assertEquals(1, getTableRowCount("results")); List<WebElement> tablecells = findElements(By.tagName("td")); assertRowEquals(tablecells, Arrays.asList("333", "444", "")); // when findElementBy(By.id("delete_0")).click(); // then assertNoOAuthSetup(); }
From source file:com.formkiq.web.OAuthFederationIntegrationTest.java
License:Apache License
/** * testOauth03()./*w w w .j a v a2s .c o m*/ * add oauth federation, domain only * * @throws Exception Exception */ @Test public void testOauth03() throws Exception { // given // when findElementBy(By.id("oauth_add_button")).click(); getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("form-modal"))); findElementBy("input", "data-valuekey", "domain").sendKeys("222"); findElementBy("input", "data-valuekey", "host").sendKeys("444"); click(By.name("_eventId_next")); // then getWait().until(ExpectedConditions.invisibilityOfElementLocated(By.id("form-modal"))); assertEquals(1, getTableRowCount("results")); List<WebElement> tablecells = findElements(By.tagName("td")); assertRowEquals(tablecells, Arrays.asList("222", "444", "")); // when findElementBy(By.id("delete_0")).click(); // then assertNoOAuthSetup(); }
From source file:com.formkiq.web.SeleniumTestBase.java
License:Apache License
/** * @param by {@link By}//from ww w . j a va 2 s . c o m * @return {@link WebElement} */ public WebElement findElementBy(final By by) { // getWait().until(ExpectedConditions.presenceOfElementLocated(by)); waitUntil(new Predicate<WebDriver>() { @Override public boolean apply(final WebDriver d) { try { getDriver().findElement(by); return true; } catch (Exception e) { return false; } } }); getWait().until(ExpectedConditions.visibilityOfElementLocated(by)); return getDriver().findElement(by); }
From source file:com.formkiq.web.SeleniumTestBase.java
License:Apache License
/** * @param by {@link By}/*from w w w. j a va 2s . c o m*/ * @return {@link WebElement} */ public List<WebElement> findElements(final By by) { getWait().until(ExpectedConditions.presenceOfElementLocated(by)); getWait().until(ExpectedConditions.visibilityOfElementLocated(by)); return getDriver().findElements(by); }
From source file:com.formkiq.web.UserSeleniumTest.java
License:Apache License
/** * testUsers01()./* w ww .j a v a 2s .co m*/ * Add User - missing values * * @throws Exception Exception */ @Test public void testUsers01() throws Exception { // given // when findElementBy(By.id("user_add_button")).click(); getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("form-modal"))); click(By.name("_eventId_next")); // then waitUntilPageSourceText("Field required"); }
From source file:com.formkiq.web.UserSeleniumTest.java
License:Apache License
/** * testUsers02().//from www . j a va 2 s .co m * Add User * * @throws Exception Exception */ @Test public void testUsers02() throws Exception { // given String email = "test2@formkiq.com"; // when findElementBy(By.id("user_add_button")).click(); getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("form-modal"))); findElementBy("input", "data-valuekey", "email").sendKeys(email); // then assertEquals("ROLE_USER", getSelectedValue(findElementBy("select", "data-valuekey", "role"))); assertEquals("ACTIVE", getSelectedValue(findElementBy("select", "data-valuekey", "status"))); WebElement el = findElementBy(By.name("_eventId_next")); assertEquals("Add User", el.getText()); // when el.click(); // then getWait().until(ExpectedConditions.invisibilityOfElementLocated(By.id("form-modal"))); assertEquals(2, getTableRowCount("results")); List<WebElement> cells = findElements(By.tagName("td")); WebElement e = cells.stream().filter(s -> s.getText().contains(email)).findFirst().get(); int index = cells.indexOf(e); assertEquals("test2@formkiq.com", e.getText()); assertEquals("ROLE_USER", cells.get(index + 1).getText()); assertEquals("INVITE", cells.get(index + 2).getText()); // when click(By.id("edit_" + getDefaultEmail())); // then getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("form-modal"))); el = findElementBy(By.name("_eventId_next")); assertEquals("Update User", el.getText()); assertEquals(getDefaultEmail(), findElementBy("input", "data-valuekey", "email").getAttribute("value")); assertFalse(getDriver().findElement(getBy("input", "data-valuekey", "password")).isDisplayed()); assertFalse(getDriver().findElement(getBy("input", "data-valuekey", "confirmpassword")).isDisplayed()); assertEquals("ROLE_ADMIN", getSelectedValue(findElementBy("select", "data-valuekey", "role"))); assertEquals("ACTIVE", getSelectedValue(findElementBy("select", "data-valuekey", "status"))); LoggerMailSender l = (LoggerMailSender) this.mail.getMailSender(); assertEquals(0, l.getMessages().size()); assertEquals(1, l.getMimeMessages().size()); MimeMessage m = l.getMimeMessages().get(0); Multipart mp = (Multipart) m.getContent(); assertEquals(2, mp.getCount()); MimeBodyPart part = (MimeBodyPart) mp.getBodyPart(0); assertNull(m.getFrom()); assertEquals(email, String.join(",", Arrays.asList(m.getRecipients(Message.RecipientType.TO)).stream() .map(s -> s.toString()).collect(Collectors.toList()))); assertEquals("Welcome to FormKiQ", m.getSubject()); assertTrue(part.getContent().toString() .contains(getDefaultHostAndPort() + "/register?email=" + email + "&resettoken=")); // given logout(); String url = extractUrl(part.getContent().toString()); // when getDriver().navigate().to(url); // then assertEquals("FormKiQ Server - User Registration", getTitle()); // given // when findElementBy(By.name("password")).sendKeys(getDefaultPass()); findElementBy(By.name("confirmpassword")).sendKeys(getDefaultEmail()); click(By.name("_eventId_next")); // then waitUntilPageSourceText("Passwords do not match"); // given // when findElementBy(By.name("password")).clear(); findElementBy(By.name("confirmpassword")).clear(); findElementBy(By.name("password")).sendKeys(getDefaultPass()); findElementBy(By.name("confirmpassword")).sendKeys(getDefaultPass()); click(By.name("_eventId_next")); // then waitUntilPageSourceText("Registration is complete"); // when login(email); // then assertEquals("FormKiQ Server - Dashboard", getTitle()); }
From source file:com.formkiq.web.UserSeleniumTest.java
License:Apache License
/** * testUsers03()./*from w w w . java2s .co m*/ * duplicate email address * * @throws Exception Exception */ @Test public void testUsers03() throws Exception { // given String email = getDefaultEmail(); // when findElementBy(By.id("user_add_button")).click(); getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("form-modal"))); findElementBy("input", "data-valuekey", "email").sendKeys(email); click(By.name("_eventId_next")); // then waitUntilPageSourceText("Email is already registered"); assertFalse(getPageSource().contains("Field required")); }
From source file:com.formkiq.web.WorkflowAddControllerIntegrationTest.java
License:Apache License
/** * testCreateWorkflow11().// www . j a v a2 s . c om * fillout and generate and sign fillable PDF * @throws Exception Exception */ @Test public void testCreateWorkflow11() throws Exception { // given String pdfname = "sample-form2.pdf"; byte[] data = Resources.getResourceAsBytes("/" + pdfname); ArchiveDTO archive = buildArchiveDTO(pdfname); this.pdfEditorService.generate(archive, pdfname, data); String token = login(); String folder = createFolder(token, getDefaultEmail()); addFileToFolder(token, folder, archive); // when login(getDefaultEmail()); getDriver().navigate().to(getDefaultHostAndPort() + "/user/dashboard"); waitForJSandJQueryToLoad(); assertEquals("FormKiQ Server - Dashboard", getTitle()); findElementBy(By.className("add_0")).click(); // then (verify on correct page) assertEquals(getDefaultHostAndPort() + "/flow/workflow?execution=s1e1", getDriver().getCurrentUrl()); assertEquals(SAMPLE_FORM_2_HTML_TITLE, getTitle()); fillSampleForm2(); // when (submit) submitByName("_eventId_next", "Next"); // then verify summary assertEquals(getDefaultHostAndPort() + "/flow/workflow?execution=s1e2", getDriver().getCurrentUrl()); assertEquals("FormKiQ Server - Signature", getTitle()); assertEquals(1, findElements(getBy("button", "data-fieldid", "55")).size()); assertEquals(0, getDriver().findElements(getBy("img", "data-fieldid", "55")).size()); // when (go back submitByName("_eventId_prev", "Previous"); // then assertEquals(getDefaultHostAndPort() + "/flow/workflow?execution=s1e1", getDriver().getCurrentUrl()); assertEquals(SAMPLE_FORM_2_HTML_TITLE, getTitle()); // when findElementBy(By.name("1")).sendKeys("Smith123"); submitByName("_eventId_next", "Next"); // then assertEquals(getDefaultHostAndPort() + "/flow/workflow?execution=s1e2", getDriver().getCurrentUrl()); assertEquals("FormKiQ Server - Signature", getTitle()); // when (signature) click(By.className("button-sig")); JavascriptExecutor jsExecutor = (JavascriptExecutor) getDriver(); jsExecutor.executeScript("signaturemetadata('555','999');"); // then getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("form-modal"))); // when click(By.className("form-modal-close-button")); // then getWait().until(ExpectedConditions.invisibilityOfElementLocated(By.id("form-modal"))); // when (signature) click(By.className("button-sig")); // then fillSignature("55"); // when click(By.className("form-modal-update-button")); // then getWait().until(ExpectedConditions.invisibilityOfElementLocated(By.id("form-modal"))); assertEquals(0, getDriver().findElements(getBy("button", "data-fieldid", "55")).size()); assertEquals(1, findElements(getBy("img", "data-fieldid", "55")).size()); // when submitByName("_eventId_next", " Submit", TIMEOUT * 2); // then complete page assertEquals(getDefaultHostAndPort() + "/flow/workflow?execution=s1e3", getDriver().getCurrentUrl()); assertEquals("FormKiQ Server - sample-form2.pdf Complete", getTitle()); Workflow workflow = archive.getWorkflow(); Pair<Workflow, Map<String, byte[]>> pwf = verifyFolderFileList(token, folder, workflow, "ACTIVE", "sample-form2.pdf"); workflow = pwf.getLeft(); Map<String, byte[]> map = pwf.getRight(); assertEquals(getDefaultHostAndPort() + "/api/folders/files/" + folder + "/" + workflow.getUUID() + ".pdf", findElementBy(By.id("pdflink")).getAttribute("href")); assertEquals(SAMPLE_FORM2 + ".pdf", map.keySet().stream().filter(s -> s.endsWith(".pdf")).collect(Collectors.joining(", "))); assertEquals(1, map.keySet().stream().filter(s -> s.endsWith(".pdf")).count()); assertEquals(1, map.keySet().stream().filter(s -> s.endsWith(".signature")).count()); FormJSON f1 = this.jsonService.readValue(map.get(workflow.getSteps().get(1) + ".form"), FormJSON.class); assertTrue(f1.getAssetData().containsKey(f1.getSections().get(0).getFields().get(0).getValue())); assertEquals("555", findValueByKey(f1, "latitude").get().getValue()); assertEquals("999", findValueByKey(f1, "longitude").get().getValue()); assertEquals("0:0:0:0:0:0:0:1", findValueByKey(f1, "ipaddress").get().getValue()); assertEquals("", findValueByKey(f1, "xforwardedfor").get().getValue()); assertNotNull(this.jsonService.stringToDate(findValueByKey(f1, "inserteddate").get().getValue())); byte[] pdf = map.get(SAMPLE_FORM2 + ".pdf"); PDDocument document = PDDocument.load(pdf); try { PDAcroForm acroForm = document.getDocumentCatalog().getAcroForm(); assertEquals("SmithSmith123", acroForm.getField("lastName").getValueAsString()); assertEquals("John", acroForm.getField("firstName").getValueAsString()); assertEquals(1, document.getSignatureDictionaries().size()); } finally { document.close(); } // TODO verify audit }
From source file:com.formkiq.web.WorkflowEditorControllerIntegrationTest.java
License:Apache License
/** * Add New Step./*from www . ja v a 2s . c o m*/ * @param event int * @param title {@link String} */ private void addNewStep(final int event, final String title) { addBlankForm(); click(By.id("tab_s1e" + event)); getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("fieldeditorform"))); findElementBy(getBy("input", "data-fieldid", "20")).sendKeys(title); //click(By.className("form-modal-update-button")); click(By.name("_eventId_next")); getWait().until(ExpectedConditions.invisibilityOfElementLocated(By.id("fieldeditorform"))); assertTrue(findElementBy(By.id("tab_s1e" + event)).getText().endsWith(title)); }