List of usage examples for org.openqa.selenium By id
public static By id(String id)
From source file:at.tugraz.ist.catroweb.admin.BadWordsFilterTests.java
License:Open Source License
@Test(groups = { "functionality", "upload" }, description = "remove word from database") public void testDeleteButton() throws Throwable { deleteAllUnapprovedWords();//w w w. ja v a 2 s. co m try { String unapprovedWord = "badwordsfilterteststestdeletebutton" + CommonData.getRandomShortString(10); String response = projectUploader .upload(CommonData.getUploadPayload(unapprovedWord, "", "", "", "", "", "", "")); assertEquals("200", CommonFunctions.getValueFromJSONobject(response, "statusCode")); openAdminLocation(); driver().findElement(By.id("aAdministrationTools")).click(); ajaxWait(); driver().findElement(By.id("aAdminToolsApproveWords")).click(); assertTrue(isTextPresent(unapprovedWord)); clickOkOnNextConfirmationBox(); driver().findElement(By.id("delete" + CommonFunctions.getUnapprovedWordId(unapprovedWord))).click(); assertTrue(isTextPresent("The word was succesfully deleted!")); assertFalse(isTextPresent(unapprovedWord)); assertProjectPresent(unapprovedWord); deletePreviouslyUploadedProjectAndUnapprovedWord(unapprovedWord); } catch (AssertionError e) { captureScreen("BadWordsFilterTests.testDeleteButton"); throw e; } catch (Exception e) { captureScreen("BadWordsFilterTests.testDeleteButton"); throw e; } }
From source file:at.tugraz.ist.catroweb.admin.EditProjectsTests.java
License:Open Source License
@Test(groups = { "functionality", "upload" }, description = "delete project button") public void deleteButton() throws Throwable { try {// w w w .j a v a2 s. c o m String projectTitle = "Testproject_delete_test_" + CommonData.getRandomLongString(200); String response = projectUploader .upload(CommonData.getUploadPayload(projectTitle, "", "", "", "", "", "", "")); String projectId = CommonFunctions.getValueFromJSONobject(response, "projectId"); // check that project is shown on index-page assertProjectPresent(projectTitle); openAdminLocation(); ajaxWait(); driver().findElement(By.id("aAdministrationTools")).click(); ajaxWait(); driver().findElement(By.id("aAdminToolsEditProjects")).click(); ajaxWait(); assertTrue(isTextPresent("Administration Tools - List of available projects")); assertTrue(isTextPresent("ID")); assertTrue(isTextPresent("Title")); assertTrue(isTextPresent("Upload Time")); assertTrue(isTextPresent("Upload IP")); assertTrue(isTextPresent("Downloads")); assertTrue(isTextPresent("Flagged")); assertTrue(isTextPresent("Visible")); assertTrue(isTextPresent("Delete")); assertTrue(isElementPresent(By.id("delete" + projectId))); assertTrue(isTextPresent(projectTitle)); clickOkOnNextConfirmationBox(); driver().findElement(By.id("delete" + projectId)).click(); assertTrue(isTextPresent("The project was succesfully deleted!")); assertFalse(isElementPresent(By.id("delete" + projectId))); assertFalse(isTextPresent(projectTitle)); // check that project is not shown on index-page assertProjectNotPresent(projectTitle); } catch (AssertionError e) { captureScreen("EditProjectsTests.deleteButton"); throw e; } catch (Exception e) { captureScreen("EditProjectsTests.deleteButton"); throw e; } }
From source file:at.tugraz.ist.catroweb.admin.EditProjectsTests.java
License:Open Source License
@Test(groups = { "functionality", "upload" }, description = "set invisible button") public void invisibleButton() throws Throwable { try {/*from w w w. j a va 2 s . co m*/ String projectTitle = "Testproject_invisible_test_" + CommonData.getRandomShortString(10); String response = projectUploader .upload(CommonData.getUploadPayload(projectTitle, "", "", "", "", "", "", "")); String projectId = CommonFunctions.getValueFromJSONobject(response, "projectId"); // check that project is shown on index-page assertProjectPresent(projectTitle); // toggle project visibility to "hidden" openAdminLocation(); ajaxWait(); driver().findElement(By.id("aAdministrationTools")).click(); ajaxWait(); driver().findElement(By.id("aAdminToolsEditProjects")).click(); ajaxWait(); assertTrue(isTextPresent("Administration Tools - List of available projects")); assertTrue(isElementPresent(By.id("toggle" + projectId))); assertTrue(isTextPresent(projectTitle)); clickOkOnNextConfirmationBox(); driver().findElement(By.id("toggle" + projectId)).click(); assertTrue(isTextPresent("The project was succesfully set to state invisible")); // project is NOT shown on index-page assertProjectNotPresent(projectTitle); // toggle project visibility to "hidden" openAdminLocation(); ajaxWait(); driver().findElement(By.id("aAdministrationTools")).click(); ajaxWait(); driver().findElement(By.id("aAdminToolsEditProjects")).click(); ajaxWait(); assertTrue(isTextPresent("Administration Tools - List of available projects")); assertTrue(isElementPresent(By.id("toggle" + projectId))); assertTrue(isTextPresent(projectTitle)); clickOkOnNextConfirmationBox(); driver().findElement(By.id("toggle" + projectId)).click(); assertTrue(isTextPresent("The project was succesfully set to state visible")); // project is shown again on index-page assertProjectPresent(projectTitle); // and delete project openAdminLocation(); driver().findElement(By.id("aAdministrationTools")).click(); ajaxWait(); driver().findElement(By.id("aAdminToolsEditProjects")).click(); assertTrue(isTextPresent("Administration Tools - List of available projects")); assertTrue(isElementPresent(By.id("delete" + projectId))); assertTrue(isTextPresent(projectTitle)); clickOkOnNextConfirmationBox(); driver().findElement(By.id("delete" + projectId)).click(); assertTrue(isTextPresent("The project was succesfully deleted!")); assertFalse(isElementPresent(By.id("delete" + projectId))); assertFalse(isTextPresent(projectTitle)); // and finally project is NOT shown on index-page assertProjectNotPresent(projectTitle); } catch (AssertionError e) { captureScreen("EditProjectsTests.invisibleButton"); throw e; } catch (Exception e) { captureScreen("EditProjectsTests.invisibleButton"); throw e; } }
From source file:at.tugraz.ist.catroweb.admin.LanguageManagementTests.java
License:Open Source License
@Test(groups = { "functionality" }, description = "update language packs") public void updateLanguagePack() throws Throwable { try {/*from w ww .j a va 2 s . com*/ openAdminLocation("?userLanguage=" + Config.SITE_DEFAULT_LANGUAGE); driver().findElement(By.id("aAdministrationTools")).click(); ajaxWait(); driver().findElement(By.id("aAdminToolsLanguageManagement")).click(); assertTrue(isTextPresent("Administration Tools - Language Management")); assertTrue(isElementPresent(By.xpath("//select[@id='supportedLanguageSelect']"))); assertTrue(isElementPresent(By.xpath("//a[@id='doUpdateLink']"))); (new Select(driver().findElement(By.id("supportedLanguageSelect")))).selectByValue("de"); driver().findElement(By.id("doUpdateLink")).click(); ajaxWait(); assertTrue(isTextPresent("The language de was successfully updated!")); driver().findElement(By.id("aAdminToolsBackToTools")).click(); assertTrue(isTextPresent("Administration Tools")); } catch (AssertionError e) { captureScreen("LanguageManagementTests.updateLanguagePack"); throw e; } catch (Exception e) { captureScreen("LanguageManagementTests.updateLanguagePack"); throw e; } }
From source file:at.tugraz.ist.catroweb.admin.SendEmailNotificationTests.java
License:Open Source License
@Test(groups = { "functionality", "sendEmail" }, description = "check elements present (text, buttons) ") public void checkElements() throws Throwable { try {//from www. jav a 2s .co m openAdminLocation(); ajaxWait(); driver().findElement(By.id("aAdministrationTools")).click(); ajaxWait(); driver().findElement(By.id("aAdminToolsSendEmailNotification")).click(); ajaxWait(); assertTrue(isTextPresent("Administration Tools - Send e-mail notification")); assertTrue(isTextPresent("ID")); assertTrue(isTextPresent("Username")); assertTrue(isTextPresent("E-Mail")); assertTrue(isTextPresent("Gender")); assertTrue(isTextPresent("Country")); assertTrue(isTextPresent("Send E-Mail?")); assertTrue(isTextPresent(" (0 user(s) selected)")); assertTrue(isTextPresent(" select all")); assertTrue(isElementPresent(By.id("aAdminToolsBackToCatroidweb"))); assertTrue(isElementPresent(By.id("chkboxSelectAll"))); assertTrue(isElementPresent(By.id("sendEmailSubmit"))); } catch (AssertionError e) { captureScreen("SendEmailNotificationTests.checkElements"); throw e; } catch (Exception e) { captureScreen("SendEmailNotificationTests.checkElements"); throw e; } }
From source file:at.tugraz.ist.catroweb.admin.SendEmailNotificationTests.java
License:Open Source License
@Test(groups = { "functionality", "sendEmail" }, description = "send e-mail notification") public void sendButton() throws Throwable { try {// w ww . j a v a2s. c o m openAdminLocation(); ajaxWait(); driver().findElement(By.id("aAdministrationTools")).click(); ajaxWait(); driver().findElement(By.id("aAdminToolsSendEmailNotification")).click(); ajaxWait(); List<WebElement> checkboxes = driver().findElements(By.className("chkBoxEmail")); clickOkOnNextConfirmationBox(); driver().findElement(By.id("sendEmailSubmit")).click(); assertFalse(isTextPresent("Answer:")); assertFalse(isTextPresent("Number of emails selected:")); driver().findElement(By.id("chkboxSelectAll")).click(); clickCancelOnNextConfirmationBox(); driver().findElement(By.id("sendEmailSubmit")).click(); assertFalse(isTextPresent("Answer:")); assertFalse(isTextPresent("Number of emails selected:")); clickOkOnNextConfirmationBox(); driver().findElement(By.id("sendEmailSubmit")).click(); assertTrue(isTextPresent("Answer:")); assertTrue(isTextPresent("Number of emails selected: " + checkboxes.size())); assertFalse(isTextPresent("Sending message to user \"anonymous\"")); assertTrue(isTextPresent("Sending message to user \"catroweb\"")); assertTrue(isTextPresent( "Status: " + checkboxes.size() + " of " + +checkboxes.size() + " e-mails sent. (0 failed)")); } catch (AssertionError e) { captureScreen("SendEmailNotificationTests.sendButton"); throw e; } catch (Exception e) { captureScreen("SendEmailNotificationTests.sendButton"); throw e; } }
From source file:at.tugraz.ist.catroweb.admin.SendEmailNotificationTests.java
License:Open Source License
@Test(groups = { "functionality", "sendEmail" }, description = "select checkboxes one by one and by using select all checkbox") public void checkCheckboxes() throws Throwable { try {//from w w w. jav a2s . c om int checked = 0; openAdminLocation(); ajaxWait(); driver().findElement(By.id("aAdministrationTools")).click(); ajaxWait(); driver().findElement(By.id("aAdminToolsSendEmailNotification")).click(); ajaxWait(); assertTrue(isTextPresent(" (" + checked + " user(s) selected)")); List<WebElement> checkboxes = driver().findElements(By.className("chkBoxEmail")); for (WebElement checkbox : checkboxes) { assertFalse(checkbox.isSelected()); } for (WebElement checkbox : checkboxes) { driver().findElement(By.id(checkbox.getAttribute("id"))).click(); checked++; assertTrue(isTextPresent(" (" + checked + " user(s) selected)")); assertTrue(checkbox.isSelected()); } assertTrue(isTextPresent("unselect all")); // unselect all checkboxes by clicking on unselect all checkbox checked = 0; driver().findElement(By.id("chkboxSelectAll")).click(); ajaxWait(); for (WebElement checkbox : checkboxes) { assertFalse(checkbox.isSelected()); } assertTrue(isTextPresent("select all")); assertTrue(isTextPresent(" (" + checked + " user(s) selected)")); // select all checkboxes by clicking on select all checkbox driver().findElement(By.id("chkboxSelectAll")).click(); for (WebElement checkbox : checkboxes) { checked++; assertTrue(checkbox.isSelected()); } assertTrue(isTextPresent("unselect all")); assertTrue(isTextPresent(" (" + checked + " user(s) selected)")); } catch (AssertionError e) { captureScreen("SendEmailNotificationTests.checkCheckboxes"); throw e; } catch (Exception e) { captureScreen("SendEmailNotificationTests.checkCheckboxes"); throw e; } }
From source file:at.tugraz.ist.catroweb.admin.UploadTest.java
License:Open Source License
@Test(groups = { "upload" }, description = "upload and delete a project") public void uploadTest() throws Throwable { try {/*from w w w .j ava2 s . c o m*/ // check for project uploader and send invalid request openAdminLocation(); driver().findElement(By.id("aProjectUploader")).click(); assertTrue(isTextPresent("Project Uploader")); driver().findElement(By.name("uploadButton")).click(); assertTrue(isTextPresent("501")); // upload a project String projectTitle = "testproject" + CommonData.getRandomLongString(200); String response = projectUploader .upload(CommonData.getUploadPayload(projectTitle, "", "", "", "", "", "", "")); String projectId = CommonFunctions.getValueFromJSONobject(response, "projectId"); // delete project openAdminLocation(); driver().findElement(By.id("aAdministrationTools")).click(); ajaxWait(); driver().findElement(By.id("aAdminToolsEditProjects")).click(); assertTrue(isTextPresent(projectTitle)); clickOkOnNextConfirmationBox(); driver().findElement(By.id("delete" + projectId)).click(); assertFalse(isTextPresent(projectTitle)); // verify deletion assertProjectNotPresent(projectTitle); } catch (AssertionError e) { captureScreen("UploadTest.uploadTest"); throw e; } catch (Exception e) { captureScreen("UploadTest.uploadTest"); throw e; } }
From source file:at.tugraz.ist.catroweb.api.UploadTests.java
License:Open Source License
@Test(groups = { "upload", "functionality" }, description = "overwrite already uploaded projects") public void uploadResubmission() throws Throwable { try {/*from w w w .jav a 2 s. c o m*/ String title = "Resubmit this project"; String response = projectUploader.upload( CommonData.getUploadPayload(title, "Resubmission test, overwrite already uploaded projects.", "test-0.7.3beta.catrobat", "649ff13ee9c1750c3276f15e509f5489", "", "", "", "")); String id = CommonFunctions.getValueFromJSONobject(response, "projectId"); assertEquals("200", CommonFunctions.getValueFromJSONobject(response, "statusCode")); openLocation("details/" + id); assertTrue(containsElementText(By.id("projectDetailsProjectTitle"), title.toUpperCase())); assertTrue(isTextPresent("version: 0.7.3beta")); //update the project response = projectUploader.upload( CommonData.getUploadPayload(title, "Resubmission test, overwrite already uploaded projects.", "test-0.7.4beta.catrobat", "c21b63f8a9a3b7c5ae85adfc9657e479", "", "", "", "")); id = CommonFunctions.getValueFromJSONobject(response, "projectId"); assertEquals("200", CommonFunctions.getValueFromJSONobject(response, "statusCode")); openLocation("details/" + id); assertTrue(containsElementText(By.id("projectDetailsProjectTitle"), title.toUpperCase())); assertTrue(isTextPresent("version: 0.7.4beta")); } catch (AssertionError e) { captureScreen("UploadTests.uploadResubmission"); throw e; } catch (Exception e) { captureScreen("UploadTests.uploadResubmission"); throw e; } }
From source file:at.tugraz.ist.catroweb.api.UploadTests.java
License:Open Source License
@Test(groups = { "upload", "functionality" }, description = "extract project title and description from xml") public void uploadXMLExtraction() throws Throwable { try {/*from w w w.j a va 2 s .com*/ String projectTitle = "testTitle"; String projectDescription = "testDescription"; String response = projectUploader.upload(CommonData.getUploadPayload(projectTitle, projectDescription, "test-0.7.3beta-xml.catrobat", "a71aa252cdd2fd4846b639bd7dcbd04e", "", "", "", "")); String id = CommonFunctions.getValueFromJSONobject(response, "projectId"); assertEquals("200", CommonFunctions.getValueFromJSONobject(response, "statusCode")); openLocation("details/" + id); assertFalse(containsElementText(By.id("projectDetailsProjectTitle"), projectTitle.toUpperCase())); assertFalse(isTextPresent(projectDescription)); assertTrue(containsElementText(By.id("projectDetailsProjectTitle"), "XML-ProjectName".toUpperCase())); assertTrue(isTextPresent("XML-ProjectDescription")); } catch (AssertionError e) { captureScreen("UploadTests.uploadXMLExtraction"); throw e; } catch (Exception e) { captureScreen("UploadTests.uploadXMLExtraction"); throw e; } }