List of usage examples for org.openqa.selenium.support.ui ExpectedConditions invisibilityOfElementLocated
public static ExpectedCondition<Boolean> invisibilityOfElementLocated(final By locator)
From source file:com.formkiq.web.OAuthFederationIntegrationTest.java
License:Apache License
/** * testOauth02().//from w w w .jav a 2 s .c o 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 av a 2 s .c om*/ * 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.UserSeleniumTest.java
License:Apache License
/** * testUsers02().//from w w w . j a v a2s .c o 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.WorkflowAddControllerIntegrationTest.java
License:Apache License
/** * testCreateWorkflow11().//from w w w . j ava2 s. c o m * 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 w ww .j av a 2 s . 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)); }
From source file:com.formkiq.web.WorkflowEditorControllerIntegrationTest.java
License:Apache License
/** * Edits Field.// w ww . j a v a 2s . c o m * * @param fieldid {@link String} * @param values {@link Map} * @throws InterruptedException InterruptedException */ private void editField(final String fieldid, final Map<String, String> values) throws InterruptedException { clickEditFieldButton(fieldid); getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("fieldeditorform"))); for (Map.Entry<String, String> e : values.entrySet()) { String field = e.getKey(); String value = e.getValue(); By by = By.xpath("//*[self::textarea|self::input|self::select|self::button]" + "[@data-fieldid='" + field + "']"); WebElement element = findElementBy(by); assertTrue(element.isDisplayed()); String tagname = element.getTagName(); switch (tagname) { case "select": Select select = new Select(element); waitUntilSelectOptionsPopulated(select); select.selectByVisibleText(extractLabelAndValue(value).getLeft()); break; case "button": element.click(); break; default: element.clear(); element.sendKeys(value); break; } } //findElementBy(By.className("form-modal-update-button")).click(); click(By.name("_eventId_next")); getWait().until(ExpectedConditions.invisibilityOfElementLocated(By.id("fieldeditorform"))); }
From source file:com.formkiq.web.WorkflowEditorControllerIntegrationTest.java
License:Apache License
/** * testAddWorkflow16().//from w w w . j a v a2 s .com * change workflow name. * * @throws Exception Exception */ @Test public void testAddWorkflow16() throws Exception { // given // when - add step clickAddNewWorkflow(); findElementBy(By.id("tab_s1e1")).click(); getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("fieldeditorform"))); findElementBy(By.name("name")).clear(); findElementBy(By.name("name")).sendKeys("samplewf"); findElementBy(By.name("21")).click(); //findElementBy(By.className("form-modal-update-button")).click(); click(By.name("_eventId_next")); // then getWait().until(ExpectedConditions.invisibilityOfElementLocated(By.id("fieldeditorform"))); assertEquals("samplewf", findElementBy(By.id("tab_s1e1")).getText()); findElementBy(By.id("tab_s1e1")).click(); getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("fieldeditorform"))); assertEquals("samplewf", findElementBy(By.name("name")).getAttribute("value")); assertTrue(findElementBy(By.name("21")).isSelected()); }
From source file:com.formkiq.web.WorkflowEditorControllerIntegrationTest.java
License:Apache License
/** * testAddWorkflow17()./* w w w. j av a 2 s. co m*/ * change form name & step / print steps order. * * @throws Exception Exception */ @Test public void testAddWorkflow17() throws Exception { // given String stepsSel = "#steps_table tbody > tr"; String printstepsSel = "#printsteps_table tbody > tr"; // when - add step clickAddNewWorkflow(); addBlankForm(); findElementBy(By.id("tab_s1e2")).click(); getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("fieldeditorform"))); findElementBy(By.name("name")).sendKeys("samplewf"); //findElementBy(By.className("form-modal-update-button")).click(); click(By.name("_eventId_next")); // then getWait().until(ExpectedConditions.invisibilityOfElementLocated(By.id("fieldeditorform"))); assertTrue(findElementBy(By.id("tab_s1e2")).getText().endsWith("New Formsamplewf")); addBlankForm(); findElementBy(By.id("tab_s1e1")).click(); // then assertRowEquals(findElements(By.cssSelector(stepsSel)), Arrays.asList("Form Name", "New Formsamplewf", "New Form")); assertRowEquals(findElements(By.cssSelector(printstepsSel)), Arrays.asList("Form Name", "New Formsamplewf", "New Form")); // when findElementBy(By.id("stepup_0")).click(); findElementBy(By.id("printstepup_0")).click(); // then assertRowEquals(findElements(By.cssSelector(stepsSel)), Arrays.asList("Form Name", "New Formsamplewf", "New Form")); assertRowEquals(findElements(By.cssSelector(printstepsSel)), Arrays.asList("Form Name", "New Formsamplewf", "New Form")); // when findElementBy(By.id("stepup_1")).click(); findElementBy(By.id("printstepup_1")).click(); // then assertRowEquals(findElements(By.cssSelector(stepsSel)), Arrays.asList("Form Name", "New Form", "New Formsamplewf")); assertRowEquals(findElements(By.cssSelector(printstepsSel)), Arrays.asList("Form Name", "New Form", "New Formsamplewf")); // when findElementBy(By.id("stepdown_0")).click(); findElementBy(By.id("printstepdown_0")).click(); // then assertRowEquals(findElements(By.cssSelector(stepsSel)), Arrays.asList("Form Name", "New Formsamplewf", "New Form")); assertRowEquals(findElements(By.cssSelector(printstepsSel)), Arrays.asList("Form Name", "New Formsamplewf", "New Form")); // when findElementBy(By.id("stepdown_1")).click(); findElementBy(By.id("printstepdown_1")).click(); // then assertRowEquals(findElements(By.cssSelector(stepsSel)), Arrays.asList("Form Name", "New Formsamplewf", "New Form")); assertRowEquals(findElements(By.cssSelector(printstepsSel)), Arrays.asList("Form Name", "New Formsamplewf", "New Form")); }
From source file:com.formkiq.web.WorkflowEditorControllerIntegrationTest.java
License:Apache License
/** * testAddWorkflow19()./*w ww . j a v a 2 s . c om*/ * change section name. * * @throws Exception Exception */ @Test public void testAddWorkflow19() throws Exception { // given // when - add step clickAddNewWorkflow(); addBlankForm(); menuDragAndDrop("menu-textbox"); findElementBy(By.className("button-section-edit")).click(); getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("fieldeditorform"))); findElementBy(By.name("title")).sendKeys("samplesection"); //findElementBy(By.className("form-modal-update-button")).click(); click(By.name("_eventId_next")); // then getWait().until(ExpectedConditions.invisibilityOfElementLocated(By.id("fieldeditorform"))); assertEquals("samplesection", findElementBy(By.className("button-section-edit")).getText().trim()); // when findElementBy(By.className("button-section-edit")).click(); // then getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("fieldeditorform"))); assertEquals("samplesection", findElementBy(By.name("title")).getAttribute("value")); }
From source file:com.formkiq.web.WorkflowEditorControllerIntegrationTest.java
License:Apache License
/** * testAddWorkflow20().// ww w. j a va 2 s . co m * set source form * * @throws Exception Exception */ @Test public void testAddWorkflow20() throws Exception { // given FormJSONFieldType typeSelect = FormJSONFieldType.TEXTBOX; ImmutableMap<String, String> values0 = ImmutableMap.of("20", "Sample Label123", "40", "Immediate[immediate]", "25", "Currency"); // when - add step clickAddNewWorkflow(); addBlankForm(); findElementBy(By.id("tab_s1e2")).click(); getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("fieldeditorform"))); findElementBy(getBy("input", "data-fieldid", "20")).sendKeys("samplewf"); //findElementBy(By.className("form-modal-update-button")).click(); click(By.name("_eventId_next")); // then getWait().until(ExpectedConditions.invisibilityOfElementLocated(By.id("fieldeditorform"))); assertTrue(findElementBy(By.id("tab_s1e2")).getText().endsWith("New Formsamplewf")); // when - add field to first form menuDragAndDrop("menu-textbox"); editField("1", values0); // given ImmutableMap<String, String> values1 = ImmutableMap.of("20", "Sample Label", "40", "Immediate[immediate]", "25", "Currency", "81", "New Formsamplewf", "82", "Sample Label123"); addBlankForm(); menuDragAndDrop("menu-textbox"); editField("1", values1); // then checkEditField("1", typeSelect, values1); }