List of usage examples for org.openqa.selenium By xpath
public static By xpath(String xpathExpression)
From source file:com.cengage.mindtap.keywords.MasterPageActions.java
public Boolean verifiyAppLibraryIcon() { try {/*from ww w . j a va2 s .co m*/ driver.findElement(By.xpath("//*[@class='deployApp']")); return false; } catch (Exception e) { return true; } }
From source file:com.cengage.mindtap.keywords.MasterPageActions.java
public void closePushToSnapshotWindow() { driver.findElement(By.xpath("//a[@title='Close']")).click(); }
From source file:com.cengage.mindtap.keywords.PrintPageActions.java
License:Open Source License
public void verifySLAPrintPreview() { wait.hardWait(5);//ww w . j a v a2 s . co m windowHandle = driver.getWindowHandle(); ArrayList<String> tabs2 = new ArrayList<String>(driver.getWindowHandles()); System.out.println(tabs2.size()); driver.switchTo().window(tabs2.get(1)); //ReportMsg.info("tab switched"); //changeWindow(1); waitTOSync(); String Url = driver.getTitle(); System.out.println(Url); WebElement ele = driver.findElement(By.xpath("//button[@class='cancel' and @i18n-content='cancel']")); ele.sendKeys(Keys.ESCAPE); //switchToPrintPreviewIFrame(); }
From source file:com.cengage.mindtap.keywords.searchPageAction.java
/** * Select page no./*from ww w. j ava 2 s .c o m*/ * * @param searchTerm the search term */ public void selectPageNo(String searchTerm) { waitForElementPresent("suggestion_box"); //******** Search for the Term amongst the list *********** for (WebElement searchItem : elements("suggestion_list")) { if (searchItem.getText().contains(searchTerm)) { pageNoSearchTitle = searchItem.findElement(By.xpath(".//div[@class='hit-highlights']")).getText(); Reporter.log("Searched Page Title = " + pageNoSearchTitle); searchItem.findElement(By.xpath(".//div[@class='info']/*[@class='name']")).click(); break; } } }
From source file:com.cengage.mindtap.keywords.searchPageAction.java
/** * Verify text highlighted.//from w w w . ja v a2 s . c o m * * @param searchTerm the search term * @return true, if successful */ public boolean verifyTextHighlighted(String searchTerm) { boolean flag = false; searchTerm = searchTerm.toUpperCase(); // switchToMainIFrame(); List<WebElement> highlightField_list = driver.findElements(By.xpath("//span[@class='searchHighlight']")); for (WebElement highlight : highlightField_list) { Reporter.log("Actual Text = " + highlight.getText() + " Expected Result = " + searchTerm); if (highlight.getText().toUpperCase().contains(searchTerm)) { flag = true; break; } } deselectFrame(); return flag; }
From source file:com.cengage.mindtap.keywords.searchPageAction.java
/** * Select search term./*from w w w .jav a 2s . com*/ * * @param searchTerm the search term */ public void selectSearchTerm(String searchTerm) { waitForElementPresent("suggestion_box"); searchTerm = searchTerm.toUpperCase(); boolean flag = true; while (flag) { List<WebElement> suggestion_list = driver.findElements(By.xpath("//div[@class='hits']//ul/li")); for (WebElement searchItem : suggestion_list) { try { searchItem.findElement(By.xpath(".//div[@class='hit-highlights']")).click(); System.out.println(searchItem.getText() + "Test Passed"); flag = false; break; } catch (Exception e) { continue; } } //***** Click on Show More button if text not found ******** if (flag = true) { System.out.println("Test Failing"); try { //To avoid stale element exception driver.findElement(By.className("showMore")); element("showMore_btn").click(); } catch (Exception e) { flag = false; } } } //******* Clear the search term from search box ************* // clearSearchResult(); //******* Hide the dock app ************* //clickOnHideApp(); }
From source file:com.cengage.mindtap.keywords.StudentMyHomePageActions.java
public void studentLaunchCourse(String courseKey, String env) { waitForElementPresent("courseAndMaterials_txt"); waitForElementPresent("open_btn_student"); try {/* ww w .j ava2 s.co m*/ String attValue = element("open_btn", courseKey).getAttribute("onclick"); String[] url = attValue.split("http.*.ng.cengage.com"); url = url[1].split("','MTC',"); if (env.equals("STAGE")) { driver.navigate().to("http://mindtap-staging.cengage.com" + url[0]); System.out.println("Navigated To Environment :: " + "http://mindtap-staging.cengage.com" + url[0]); } } catch (Exception e) { waitForElementPresent("open_btn_student"); element("open_btn_student", courseKey).click(); String url = driver.findElement(By.xpath("//*[@id='courseURL']")).getAttribute("value"); //String url =executeJavascriptWithReturn("document.getElementById('courseURL').value;").toString(); System.out.println(url); if (env.equals("STAGE")) { driver.navigate().to(url); System.out.println("Navigated To Environment :: " + url); } } }
From source file:com.cengage.mindtap.keywords.StudyHubPageActions.java
public void selectDropDownValue() { WebElement dropdownSelect = driver.findElement(By.xpath("//div[@class='content-select']//select")); Select dropdown = new Select(dropdownSelect); dropdown.selectByIndex(9);//from w w w.j ava2s .c o m StudyKeyTitle = element("SelectedUnit_Title").getText(); System.out.println("Study Guide selected Title is : " + StudyKeyTitle); }
From source file:com.cengage.mindtap.keywords.StudyHubPageActions.java
public void StudentStudyGuideLaunch(String SGName) { waitTOSync();//from w w w . ja v a2s . c om Assert.assertTrue(element("StudyLaunch", SGName).isDisplayed(), "Student created Study Guide is not present"); element("StudyLaunch", SGName).click(); String title = element("LaunchTitle").getText(); Assert.assertTrue(title.contentEquals(SGName), "Title matches"); Assert.assertTrue(element("PrintIcon").isDisplayed(), "Print Icon is not present"); Assert.assertTrue(element("SortText").isDisplayed(), "Sort Link is not present"); Assert.assertTrue(element("TypeSort").isDisplayed(), "Type Sort Link is not present"); Assert.assertTrue(element("UnitSort").isDisplayed(), "Unit Sort Link is not present"); Assert.assertTrue(element("HighlightHeading").isDisplayed(), "Highlight Heading is not present"); Assert.assertTrue(element("KeyHeading").isDisplayed(), "Key Term Heading is not present"); Assert.assertTrue(element("NotesHeading").isDisplayed(), "My Notes Heading is not present"); Assert.assertTrue(element("FlashHeading").isDisplayed(), "Flashcard Heading is not present"); Assert.assertTrue(element("HighlightContent").isDisplayed(), "Highlight Content is not present"); Assert.assertTrue(element("FlashHeading").isDisplayed(), "Flashcard content is not present"); Assert.assertTrue(element("NotesHeading").isDisplayed(), "My Notes COntent is not present"); List<WebElement> li = driver.findElements(By.xpath("//dt[@class='ng-binding ng-isolate-scope']")); System.out.println("list value : " + li.get(1).getText()); li.get(1).isDisplayed(); waitTOSync(); }