List of usage examples for org.openqa.selenium By xpath
public static By xpath(String xpathExpression)
From source file:facets_testing.java
@Test public void testDepartmentLinkNotPresent() { List<String> dept_names = new ArrayList<>(); driver.setJavascriptEnabled(true);/* w w w .j av a 2 s .c om*/ try { driver.get(page_url); Thread.sleep(14); List<WebElement> dept_list = driver .findElements(By.xpath("//div[@id=\"drs_drs_department_ssim\"]/div/div[2]/a/div[1]")); for (WebElement dept : dept_list) { dept_names.add(dept.getText()); } assertThat(dept_names, not(JUnitMatchers.hasItem("abcdef"))); } catch (Exception e) { System.out.println("Department falsely is present.Error : " + e); } }
From source file:facets_testing.java
@Test public void testDegreeFacet() { driver.setJavascriptEnabled(true);//from w ww . jav a 2 s.c o m try { driver.get(page_url); // Thread.sleep(14); String element_text = driver.findElement(By.xpath("//div[@id=\"drs_drs_degree_ssim\"]/div/div[1]/b")) .getText(); System.out.println( driver.findElement(By.xpath("//div[@id=\"drs_drs_degree_ssim\"]/div/div[1]/b")).getText()); assertEquals(element_text, "Course Degree"); } catch (Exception e) { System.out.println("Course Degree facet not found. Error : " + e); fail(); } }
From source file:facets_testing.java
@Test public void testDegreeLinkPresent() { List<String> degree_names = new ArrayList<>(); driver.setJavascriptEnabled(true);// ww w . java2 s.c o m try { driver.get(page_url); Thread.sleep(14); List<WebElement> degree_list = driver .findElements(By.xpath("//div[@id=\"drs_drs_degree_ssim\"]/div/div[2]/a/div[1]")); for (WebElement degree : degree_list) { degree_names.add(degree.getText()); } assertThat(degree_names, JUnitMatchers.hasItem("Ed.D.")); } catch (Exception e) { System.out.println("Degree is not present.Error : " + e); } }
From source file:facets_testing.java
@Test public void testDegreeLinkNotPresent() { List<String> degree_names = new ArrayList<>(); driver.setJavascriptEnabled(true);//from ww w. ja v a 2 s . c om try { driver.get(page_url); Thread.sleep(14); List<WebElement> degree_list = driver .findElements(By.xpath("//div[@id=\"drs_drs_degree_ssim\"]/div/div[2]/a/div[1]")); for (WebElement degree : degree_list) { degree_names.add(degree.getText()); } assertThat(degree_names, not(JUnitMatchers.hasItem("abcdef"))); } catch (Exception e) { System.out.println("Degree is falsely present.Error : " + e); } }
From source file:facets_testing.java
@Test public void testTitleFacet() { driver.setJavascriptEnabled(true);//from w ww .j av a 2 s.c o m try { driver.get(page_url); // Thread.sleep(14); String element_text = driver .findElement(By.xpath("//div[@id=\"drs_drs_course_title_ssim\"]/div/div[1]/b")).getText(); System.out.println(driver.findElement(By.xpath("//div[@id=\"drs_drs_course_title_ssim\"]/div/div[1]/b")) .getText()); assertEquals(element_text, "Course Title"); } catch (Exception e) { System.out.println("Course Title facet not found. Error : " + e); fail(); } }
From source file:facets_testing.java
@Test public void testTitleLinkPresent() { List<String> title_names = new ArrayList<>(); driver.setJavascriptEnabled(true);/*from w w w .ja va2 s. c o m*/ try { driver.get(page_url); Thread.sleep(14); List<WebElement> title_list = driver .findElements(By.xpath("//div[@id=\"drs_drs_course_title_ssim\"]/div/div[2]/a/div[1]")); for (WebElement title : title_list) { title_names.add(title.getText()); } assertThat(title_names, JUnitMatchers.hasItem("English")); } catch (Exception e) { System.out.println("Title is not present.Error : " + e); } }
From source file:facets_testing.java
@Test public void testTitleLinkNotPresent() { // System.setProperty("webdriver.chrome.driver", "C:\\Users\\Kartik\\Downloads\\chromedriver.exe"); List<String> title_names = new ArrayList<>(); HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.BEST_SUPPORTED); driver.setJavascriptEnabled(true);//from w w w. j a v a 2 s.c o m try { driver.get(page_url); Thread.sleep(14); List<WebElement> title_list = driver .findElements(By.xpath("//div[@id=\"drs_drs_course_title_ssim\"]/div/div[2]/a/div[1]")); for (WebElement title : title_list) { title_names.add(title.getText()); } assertThat(title_names, not(JUnitMatchers.hasItem("abcdef"))); } catch (Exception e) { System.out.println("Title is falsely present.Error : " + e); } }
From source file:ExpiredLicenseSelenium.java
@Test public void testAddLicenseWebDriver() throws Exception { Date now = new java.util.Date(); String ts = new Timestamp(now.getTime()).toString(); String validTill = addDays(now, 15); driver.get(baseUrl + "#/"); driver.findElement(By.linkText("Start licensing process")).click(); driver.findElement(By.id("nameOrganization")).clear(); driver.findElement(By.id("nameOrganization")).sendKeys(ts); driver.findElement(By.id("applicationArea")).clear(); driver.findElement(By.id("applicationArea")).sendKeys("ApplicationAreaTest"); driver.findElement(By.id("nameContact")).clear(); driver.findElement(By.id("nameContact")).sendKeys("NameTest"); driver.findElement(By.id("email")).clear(); driver.findElement(By.id("email")).sendKeys("email@test"); driver.findElement(By.id("skype")).clear(); driver.findElement(By.id("skype")).sendKeys("SkypeTest"); driver.findElement(By.id("phone")).clear(); driver.findElement(By.id("phone")).sendKeys("PhoneTest"); driver.findElement(By.cssSelector("div.form-group > button.btn.btn-default")).click(); new Select(driver.findElement(By.id("product"))).selectByVisibleText("i-Voting 11.2"); driver.findElement(/* w w w . ja v a 2 s . c o m*/ By.cssSelector("form[name=\"chooseProductForm\"] > div.form-group > button.btn.btn-default")) .click(); driver.findElement(By.id("validFrom")).clear(); driver.findElement(By.id("validFrom")).sendKeys("1900-01-01"); driver.findElement(By.id("validTill")).clear(); driver.findElement(By.id("validTill")).sendKeys(validTill); driver.findElement(By.id("addLicenseSubmit")).click(); //Check if license is expiring driver.findElement(By.xpath("//div[@id='bs-example-navbar-collapse-1']/ul[2]/li[2]/a/span/i[2]")).click(); //TODO Add a check based on id instead of validFrom/validTill dates List<WebElement> list = driver.findElements(By.xpath("//*[contains(text(),'" + "1900-01-01" + "')]")); Assert.assertTrue("License not found!", list.size() > 0); List<WebElement> list2 = driver.findElements(By.xpath("//*[contains(text(),'" + validTill + "')]")); Assert.assertTrue("License not found!", list2.size() > 0); }
From source file:EditTask.java
@Test public void testEditTask() throws Exception { driver.get(baseUrl + "/LoginWebApp/taskPage.jsp?username=admin"); driver.findElement(By.xpath("//button[@onclick='editTask(this)']")).click(); driver.findElement(By.id("taskmessage1")).clear(); driver.findElement(By.id("taskmessage1")).sendKeys("ola"); driver.findElement(By.xpath("(//button[@type='button'])[7]")).click(); assertEquals("Task successfully Updated!", closeAlertAndGetItsText()); }
From source file:facetsTest.java
@Test public void findSearchBar() { driver.setJavascriptEnabled(true);/*ww w. j a va2 s .c om*/ try { driver.get(page_url); Thread.sleep(14); WebElement searchBar = driver.findElement(By.xpath("//div[@id=\"search-and-facet\"]/form/input")); assertTrue(searchBar.isDisplayed()); System.out.println("Search bar found"); } catch (Exception e) { System.out.println("Search Bar is not present.Error : " + e); } }