@Test public void testLoginToCamcast() throws Exception { driver.get(DataServiceProperties.APPURL); assertTrue( driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*User name[\\s\\S]*$")); Thread.sleep(1000); assertTrue( driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*Password[\\s\\S]*$")); userLogin.UserLoginCredentials(driver); // userLogin.ChangePassword(driver); assertTrue( driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*Sign out[\\s\\S]*$")); driver.findElement(By.linkText("Sign out")).click(); }
@Test public void testEditXidioAddressInProfileManagement() throws Exception { UserLoginFunctions userLogin = new UserLoginFunctions(); driver.get(AppProperties.APPURL); assertTrue( driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*Sign In[\\s\\S]*$")); userLogin.UserLoginCredentials(driver); driver.findElement(By.linkText(AppProperties._USER_NAME)).click(); driver.findElement(By.name("user[address]")).clear(); driver.findElement(By.name("user[address]")).sendKeys(AppProperties._UPD_ADDRESS); driver.findElement(By.linkText("Save profile")).click(); assertTrue( driver.findElement(By.cssSelector("BODY")).getText().matches("^[\\s\\S]*XIDIO[\\s\\S]*$")); driver.findElement(By.linkText(AppProperties._USER_NAME)).click(); driver.findElement(By.linkText("Sign out")).click(); assertTrue( driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*User Account[\\s\\S]*$")); assertEquals( AppProperties._UPD_ADDRESS, driver.findElement(By.name("user[address]")).getAttribute("value")); }
@Test public void testGotoFinalReview() throws Exception { // Goto Final Review page driver.findElement(By.xpath("//a[contains(text(), 'Final Review')]")).click(); try { assertEquals( "Final Review", driver.findElement(By.xpath("//*[@id='container']/h3")).getText()); } catch (Error e) { screenShots.takeScreenShot("gotoFinalReview"); verificationErrors.append(e.toString()); } Thread.sleep(300); // Find where the warning is displayed and scroll it into view, then screenshot it. // We look for 'Scholarship and Sponsorship' since the warning is in the 'Qualifications' area // and the scrolling is causing a heading right where we scroll to and covers it. WebElement elem = driver.findElement(By.xpath("//h4[contains(text(), 'Scholarship and Sponsorship')]")); ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", elem); Thread.sleep(300); screenShots.takeScreenShot("FinalReviewWarnMsgNoQualifEntrd"); // Go back to application driver.findElement(By.cssSelector("#link_to_application > span")).click(); }
private void SpecialNeeds() throws IOException { // Click Special Needs driver .findElement( By.xpath( "//ul[@class='vertical-tabs-list']/li/a/strong[contains(text(), \"Special Needs\")]")) .click(); // Select Special Needs Select SpecialNeeds = new Select(driver.findElement(By.id("edit-special-needs"))); // Select Learning Center SpecialNeeds.selectByVisibleText("Learning Center"); // Select Early Syllabus SpecialNeeds.selectByVisibleText("Early syllabus"); // Click Apply driver.findElement(By.id("edit-special-needs-apply-filter")).click(); // Check Result Received or Not try { assertTrue( func.isTextPresent(driver.findElement(By.className("search-total-results")).getText())); } catch (Error e) { verificationErrors.append(e.toString()); } // Click All Selections driver.findElement(By.linkText("Clear All Selections")).click(); }
// Method checking if the edited profile is displayed back to the user and if illegal string like // URL and email id are stripped off from "profile essay" sections private void verifyChanges() { List<WebElement> allElements = driver.findElements(By.cssSelector("div[id='about_myself'] p")); for (WebElement element1 : allElements) { if (element1.getText().contains("www.") || element1.getText().contains(".com")) ; ripOffTextAboutMe++; } List<WebElement> allElements2 = driver.findElements(By.cssSelector("div[id='who_im_looking_for'] p")); for (WebElement element2 : allElements2) { if (element2.getText().contains("www.") || element2.getText().contains(".com")) ; ripOffTextPartnerSearch++; } List<WebElement> allElement3 = driver.findElements(By.cssSelector("ul[class='profileInformation'] li")); for (WebElement element3 : allElement3) { // System.out.println(element3.getText()); if (element3.getText().contains("Mixed") || element3.getText().contains("4ft. 10in.")) profileChangeCheck++; } if (profileChangeCheck > 0) System.out.println("SUCCESS: The changes made in the basic profile are visible"); if (ripOffTextAboutMe != 0) System.out.println( "SUCCESS: The About Myself section has ripped off any illegal strings like URL and Email id"); if (ripOffTextPartnerSearch != 0) System.out.println( "SUCCESS: The What I am Looking For section has ripped off any illegal strings like URL and Email id"); }
@Test(expected = NoSuchElementException.class) public void shouldBeAbleToClickInAFrame() throws InterruptedException { WebDriver d = getDriver(); d.get("http://docs.wpm.neustar.biz/testscript-api/index.html"); assertEquals("__MAIN_FRAME__", getCurrentFrameName(d)); d.switchTo().frame("classFrame"); assertEquals("classFrame", getCurrentFrameName(d)); // This should cause a reload in the frame "classFrame" d.findElement(By.linkText("HttpClient")).click(); // Wait for new content to load in the frame. WebDriverWait wait = new WebDriverWait(d, 10); wait.until(ExpectedConditions.titleContains("HttpClient")); // Frame should still be "classFrame" assertEquals("classFrame", getCurrentFrameName(d)); // Check if a link "clearCookies()" is there where expected assertEquals("clearCookies", d.findElement(By.linkText("clearCookies")).getText()); // Make sure it was really frame "classFrame" which was replaced: // 1. move to the other frame "packageFrame" d.switchTo().defaultContent().switchTo().frame("packageFrame"); assertEquals("packageFrame", getCurrentFrameName(d)); // 2. the link "clearCookies()" shouldn't be there anymore d.findElement(By.linkText("clearCookies")); }
@Test public void testBookSearch5() throws Exception { driver.get(baseUrl + "/proyectoBiblioteca/"); new Select(driver.findElement(By.name("type"))).selectByVisibleText("Editorial"); driver.findElement(By.name("search")).clear(); driver.findElement(By.name("search")).sendKeys("De Bolsillo"); driver.findElement(By.xpath("//button[@type='submit']")).click(); assertEquals( "Libros Encontrados", driver.findElement(By.cssSelector("div.panel-heading")).getText()); }
@Test public void testGoogleJunit4WDriver() throws Exception { driver.get("https://www.google.com.ua/"); driver.findElement(By.id("lst-ib")).sendKeys("обучение собак"); driver.findElement(By.name("btnG")).click(); // WebElement weblink= driver.findElement(By.xpath("//*[@id='rso']//a")); // Actions builder = new Actions(driver); // builder.contextClick(weblink).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.RETURN).build().perform(); }
@Test public void testSearchFeature() { // find search, check if search works by sending a search time, see that results exist WebElement element = driver.findElement(By.name("search_block_form")); element.sendKeys("Laboon"); element.sendKeys(Keys.RETURN); assert (driver.findElement(By.name("Laboon")) != null); // is it good enough? }
@Test public void testUntitled2() throws Exception { driver.get(baseUrl + "php4dvd/"); WebElement userNameWebEdit = driver.findElement(By.id("username")); WebElement passwordWebEdit = driver.findElement(By.name("password")); WebElement subminButton = driver.findElement(By.name("submit")); userNameWebEdit.clear(); userNameWebEdit.sendKeys("admin"); passwordWebEdit.clear(); passwordWebEdit.sendKeys("admin"); subminButton.click(); }
@Test public void switchToFrameByElement() { WebDriver d = getDriver(); d.get("http://docs.wpm.neustar.biz/testscript-api/index.html"); assertEquals("__MAIN_FRAME__", getCurrentFrameName(d)); d.switchTo().frame(d.findElement(By.name("packageFrame"))); assertEquals("packageFrame", getCurrentFrameName(d)); d.switchTo().defaultContent(); assertEquals("__MAIN_FRAME__", getCurrentFrameName(d)); d.switchTo().frame(d.findElement(By.name("packageFrame"))); assertEquals("packageFrame", getCurrentFrameName(d)); }
@Test public void testCreateFilm() throws Exception { driver.findElement(By.cssSelector("img[alt=\"Add movie\"]")).click(); driver.findElement(By.name("name")).clear(); driver.findElement(By.name("name")).sendKeys("Новый фильм"); driver.findElement(By.name("year")).clear(); driver.findElement(By.name("year")).sendKeys("1999"); driver.findElement(By.name("duration")).clear(); driver.findElement(By.name("duration")).sendKeys("90"); driver.findElement(By.id("own_no")).click(); driver.findElement(By.id("seen_no")).click(); driver.findElement(By.id("submit")).click(); }
// Delete CSR @Test public void Test5() throws Exception { driver.get(baseUrl + "/#/host/magehostmanager.magemojo.com/configuration/ssl"); driver.findElement(By.xpath("//a[contains(text(),'www.Testing5.com')]")).click(); assertEquals( "Download CSR www.Testing5.com", driver.findElement(By.xpath("//legend[4]")).getText()); driver.findElement(By.xpath("(//button[@type='button'])[8]")).click(); assertEquals( "Confirmation Window", driver.findElement(By.cssSelector("h3.modal-title.ng-binding")).getText()); assertTrue(isElementPresent(By.xpath("//div[3]/button[2]"))); driver.findElement(By.xpath("//div[3]/button")).click(); for (int second = 0; ; second++) { if (second >= 60) fail("timeout"); try { if ("Successfully deleted the CSR." .equals(driver.findElement(By.xpath("//div[@id='toast-container']/div")).getText())) break; } catch (Exception e) { } Thread.sleep(1000); } for (int second = 0; ; second++) { if (second >= 60) fail("timeout"); try { if (!isElementPresent(By.xpath("//a[contains(text(),'www.Testing5.com')]"))) break; } catch (Exception e) { } Thread.sleep(1000); } }
private void TypesOfSchool() throws IOException { // Click Type of School driver.findElement(By.cssSelector("strong")).click(); // Click Private driver.findElement(By.id("edit-public-private-private")).click(); // Move School Size Slider // TODO Slider not working properly WebElement Slider1 = driver.findElement(By.id("population_jq_slider")); Actions moveSlider1 = new Actions(driver); Action action1 = moveSlider1.dragAndDropBy(Slider1, 0, 10).build(); action1.perform(); // Select Religious Affiliation new Select(driver.findElement(By.id("edit-religious-affiliation"))) .selectByVisibleText("Church of Christ"); // Move Tuition Range Slider // TODO Slider not working properly WebElement Slider2 = driver.findElement(By.id("tuition_range_jq_slider")); Actions moveSlider2 = new Actions(driver); Action action2 = moveSlider2.dragAndDropBy(Slider2, 0, 10).build(); action2.perform(); // Click Apply driver.findElement(By.id("edit-type-of-school-apply-filter")).click(); // Check Result Received or Not try { assertTrue( func.isTextPresent(driver.findElement(By.className("search-total-results")).getText())); } catch (Error e) { verificationErrors.append(e.toString()); } // Click All Selections driver.findElement(By.linkText("Clear All Selections")).click(); }
@Test public void testRegisterToXidioApplicationWithoutFirstName() throws Exception { driver.get("http://*****:*****@www.xidio.com"); driver.findElement(By.linkText("Register")).click(); userRegValFun.validateFirstName(driver); driver.findElement(By.linkText("Next")).click(); Thread.sleep(2000); assertTrue( driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*First name is required[\\s\\S]*$")); }
private void SearchButton() throws IOException { // Enter Text To Be Search driver.findElement(By.id("edit-keys")).clear(); driver.findElement(By.id("edit-keys")).sendKeys("Abilene"); // Click Search driver.findElement(By.id("edit-submit")).click(); // Check Result Received or Not try { assertTrue( func.isTextPresent(driver.findElement(By.className("search-total-results")).getText())); } catch (Error e) { verificationErrors.append(e.toString()); } // Click All Selections driver.findElement(By.linkText("Clear All Selections")).click(); }
@Override public void checkAfterLogout(String lang) { // Check bye msg assertEquals( "h2 element text doesn't match", getLabelText(lang, "LL_BYE_BYE"), driver.findElement(By.tagName("h2")).getText()); }
@Test public void testWeather() throws Exception { driver.get(baseUrl + "/"); driver.findElement(By.linkText("Edmonton")).click(); for (int second = 0; ; second++) { if (second >= 60) fail("timeout"); try { if (isElementPresent(By.id("cityjump"))) break; } catch (Exception e) { } Thread.sleep(1000); } // Warning: verifyTextPresent may require manual changes try { assertTrue( driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*Current Conditions[\\s\\S]*$")); } catch (Error e) { verificationErrors.append(e.toString()); } // Warning: verifyTextPresent may require manual changes try { assertTrue( driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*Forecast[\\s\\S]*$")); } catch (Error e) { verificationErrors.append(e.toString()); } // Warning: verifyTextPresent may require manual changes try { assertTrue( driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*Edmonton City Centre Airport[\\s\\S]*$")); } catch (Error e) { verificationErrors.append(e.toString()); } }
@Test public void testContactAdd() throws Exception { driver.get(LoginHelper.baseUrl + "/Account/Login?ReturnUrl=%2f"); LoginHelper.login(driver); try { Thread.sleep(2000); } catch (InterruptedException x) { } driver.findElement(By.id("tileContactModule")).click(); driver.findElement(By.linkText("Добавить новый")).click(); driver.findElement(By.id("FirstName")).click(); driver.findElement(By.id("FirstName")).clear(); driver.findElement(By.id("FirstName")).sendKeys("AutoName"); driver.findElement(By.id("LastName")).click(); driver.findElement(By.id("LastName")).clear(); driver.findElement(By.id("LastName")).sendKeys("Auto2Name"); new Select(driver.findElement(By.id("SpecialityId"))).selectByVisibleText("Chirurg"); driver.findElement(By.id("bntSave")).click(); }
@Test public void testIncorrectIncorrect() throws Exception { driver.get(baseUrl + "/"); driver.findElement(By.linkText("Log In")).click(); driver.findElement(By.id("navbar_username")).clear(); driver.findElement(By.id("navbar_username")).sendKeys("wrong"); driver.findElement(By.id("navbar_password")).clear(); driver.findElement(By.id("navbar_password")).sendKeys("wrong"); driver.findElement(By.cssSelector("input.button")).click(); assertEquals("Log In", driver.findElement(By.linkText("Log In")).getText()); driver.findElement(By.cssSelector("img[alt=\"Myth-Weavers\"]")).click(); }
@Test(expected = TimeoutException.class) public void shouldTimeoutWhileChangingIframeSource() { final String iFrameId = "iframeId"; // Define HTTP response for test server.setGetHandler( new HttpRequestCallback() { @Override public void call(HttpServletRequest req, HttpServletResponse res) throws IOException { String pathInfo = req.getPathInfo(); ServletOutputStream out = res.getOutputStream(); if (pathInfo.endsWith("iframe_content.html")) { // nested frame 1 out.println("iframe content"); } else { // main page out.println( "<html>\n" + "<body>\n" + " <iframe id='" + iFrameId + "'></iframe>\n" + " <script>\n" + " setTimeout(function() {\n" + " document.getElementById('" + iFrameId + "').src='iframe_content.html';\n" + " }, 2000);\n" + " </script>\n" + "</body>\n" + "</html>"); } } }); // Launch Driver against the above defined server WebDriver d = getDriver(); d.get(server.getBaseUrl()); // Switch to iframe d.switchTo().frame(iFrameId); assertEquals(0, d.findElements(By.id(iFrameId)).size()); assertFalse(d.getPageSource().toLowerCase().contains("iframe content")); new WebDriverWait(d, 5) .until( new Predicate<WebDriver>() { @Override public boolean apply(@Nullable WebDriver driver) { assertEquals(0, driver.findElements(By.id(iFrameId)).size()); return (Boolean) ((JavascriptExecutor) driver).executeScript("return false;"); } }); }
private void checkDemoPage(String lang) throws InterruptedException { checkElementVisible("page_loader", false); checkElementVisible("login_widget", false); checkElementVisible("webapp_ctx", true); checkElementVisible("error_window", false); checkElementVisible("success_window", true); // Extra check checkWidgetsOnLogin(); // Check success message assertEquals( "Success message doesn't match", getLabelText(lang, "LL_DEMO_MSG"), driver.findElement(By.id("ok_msg")).getText()); // Click on close button driver.findElement(By.id("success_window")).findElement(By.className("b-close")).click(); Thread.sleep(1000); checkElementVisible("webapp_ctx", true); checkElementVisible("error_window", false); checkElementVisible("success_window", false); // Check color of message WebElement dmsg = driver.findElement(By.className("demo")); assertEquals( "demo message color doesn't match", "rgba(128, 128, 128, 1)", dmsg.getCssValue("color")); checkButtonById(lang, "ll_error", true); checkButtonById(lang, "ll_logout", true); // Check & Press error button WebElement err = driver.findElement(By.id("ll_error")); err.click(); Thread.sleep(500); checkErrorWin( lang, "C-DEMO", getLabelText(lang, "LL_INFO_MSG"), getLabelText(lang, "LL_DETAIL_MSG_1") + "\n" + getLabelText(lang, "LL_DETAIL_MSG_2")); }
@Test public void shouldSwitchBackToMainFrameIfLinkInFrameCausesTopFrameReload() throws Exception { WebDriver d = getDriver(); String expectedTitle = "Unique title"; d.get("http://localhost:2310/common/frameset.html"); assertEquals(expectedTitle, d.getTitle()); d.switchTo().frame(0); d.findElement(By.linkText("top")).click(); // Wait for new content to load in the frame. expectedTitle = "XHTML Test Page"; WebDriverWait wait = new WebDriverWait(d, 10); wait.until(ExpectedConditions.titleIs(expectedTitle)); assertEquals(expectedTitle, d.getTitle()); WebElement element = d.findElement(By.id("amazing")); assertNotNull(element); }
@Test public void testHasContact() { // Check if webpage has "contact us" // these is not found, fail the test try { driver.findElement(By.xpath("//*[@id='nodesinblock-21']/article/section/p[1]/a")); } catch (NoSuchElementException nseex) { fail(); } }
private void ActivitiesOfInterest() throws IOException { // Click Activities of Interest driver .findElement( By.xpath( "//ul[@class='vertical-tabs-list']/li/a/strong[contains(text(), \"Activities of Interest\")]")) .click(); // Click Student Newspaper Checkbox // TODO Do not use number in locator driver.findElement(By.xpath("//div[11]/input")).click(); // Click TV Station Checkbox // TODO Do not use number in locator driver.findElement(By.xpath("//div[13]/input")).click(); // Click Apply driver.findElement(By.id("edit-activities-interests-apply-filter")).click(); // Check Result Received or Not try { assertTrue( func.isTextPresent(driver.findElement(By.className("search-total-results")).getText())); } catch (Error e) { verificationErrors.append(e.toString()); } // Click All Selections driver.findElement(By.linkText("Clear All Selections")).click(); }
private void AreaOfStudy() throws IOException, InterruptedException { // Click Area of School driver .findElement( By.xpath( "//ul[@class='vertical-tabs-list']/li/a/strong[contains(text(), \"Area of Study\")]")) .click(); // Select One Area Study new Select(driver.findElement(By.id("edit-area-of-study-parent"))) .selectByVisibleText("Area, Ethnic, Cultural, and Gender Studies"); // Wait For Another Select List To Load Thread.sleep(5000); // Select Subareas of Study new Select(driver.findElement(By.xpath("//div[@id='child-area-of-study-wrapper']//select"))) .selectByVisibleText("Area, Ethnic, Cultural, and Gender Studies, Other"); // Click Apply driver.findElement(By.id("edit-area-of-study-apply-filter")).click(); // Check Result Received or Not try { assertTrue( func.isTextPresent(driver.findElement(By.className("search-total-results")).getText())); } catch (Error e) { verificationErrors.append(e.toString()); } // Click All Selections driver.findElement(By.linkText("Clear All Selections")).click(); }
private void Location() throws IOException { // Click Location driver .findElement( By.xpath( "//ul[@class='vertical-tabs-list']/li/a/strong[contains(text(), \"Location\")]")) .click(); // Click West Checkbox // TODO Do not use number in Locator driver.findElement(By.xpath("//fieldset[6]/div/div[4]/div/div[3]/input")).click(); // Click South Checkbox // TODO Do not use number in Locator driver.findElement(By.xpath("//fieldset[6]/div/div[4]/div/div[6]/input")).click(); // Click Apply driver.findElement(By.id("edit-location-apply-filter")).click(); // Check Result Received or Not try { assertTrue( func.isTextPresent(driver.findElement(By.className("search-total-results")).getText())); } catch (Error e) { verificationErrors.append(e.toString()); } // Click All Selections driver.findElement(By.linkText("Clear All Selections")).click(); }
@Test public void testOtsi() throws Exception { driver.get(baseUrl + "/"); driver.findElement(By.linkText("Kandidaadid")).click(); // Warning: waitForTextPresent may require manual changes for (int second = 0; ; second++) { if (second >= 60) fail("timeout"); try { if (driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*Vana Kala[\\s\\S]*$")) break; } catch (Exception e) { } Thread.sleep(1000); } driver.findElement(By.id("nimi")).clear(); driver.findElement(By.id("nimi")).sendKeys("Magdalena"); try { assertEquals("Magdalena", driver.findElement(By.id("nimi")).getAttribute("value")); } catch (Error e) { verificationErrors.append(e.toString()); } driver.findElement(By.id("sButton")).click(); // Warning: waitForTextPresent may require manual changes for (int second = 0; ; second++) { if (second >= 60) fail("timeout"); try { if (driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*Magdalena Malejeva[\\s\\S]*$")) break; } catch (Exception e) { } Thread.sleep(1000); } // Warning: verifyTextNotPresent may require manual changes try { assertFalse( driver .findElement(By.cssSelector("BODY")) .getText() .matches("^[\\s\\S]*Vana Kala[\\s\\S]*$")); } catch (Error e) { verificationErrors.append(e.toString()); } }
@Test public void testMyFirstWebDriver() throws Exception { driver.get(baseUrl + "/HotelApp/"); driver.findElement(By.linkText("New User Register Here")).isDisplayed(); driver.findElement(By.xpath(".//*[@id='username']")).clear(); driver.findElement(By.xpath(".//*[@id='username']")).sendKeys(""); driver.findElement(By.id("password")).clear(); driver.findElement(By.id("password")).sendKeys(""); driver.findElement(By.id("login")).click(); // actualText = driver.findElement(By.id("username_span")).getText(); actualText = driver.findElement(By.cssSelector(".login_error")).getText(); assertEquals(expectedText, actualText); }
private void Sports() throws IOException { // Click Sports driver .findElement( By.xpath("//ul[@class='vertical-tabs-list']/li/a/strong[contains(text(), \"Sports\")]")) .click(); // Select Sports Select Sports = new Select(driver.findElement(By.id("edit-varsity-sports"))); // Select Baseball Sports.selectByVisibleText("baseball"); // Select Basketball Sports.selectByVisibleText("basketball"); // Click Apply driver.findElement(By.id("edit-varsity-sports-apply-filter")).click(); // Check Result Received or Not try { assertTrue( func.isTextPresent(driver.findElement(By.className("search-total-results")).getText())); } catch (Error e) { verificationErrors.append(e.toString()); } // Click All Selections driver.findElement(By.linkText("Clear All Selections")).click(); }