List of usage examples for org.openqa.selenium By xpath
public static By xpath(String xpathExpression)
From source file:co.edu.uniandes.csw.RigitalApp.test.RepositorioTest.java
@Test public void testDesactivarMaquina() throws Exception { Thread.sleep(2000);//w w w . j a v a 2 s. c o m List<WebElement> table = driver .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr")); for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); if (elems.get(3).getText().equals("true")) { elems.get(0).findElement(By.tagName("input")).click(); } } Thread.sleep(2000); driver.findElement(By.xpath("//button[contains(@id,'button-desactivar')]")).click(); driver.get(baseUrl + "/RigitalApp.web/repositorio.html"); Thread.sleep(2000); List<WebElement> table2 = driver .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr")); boolean def = true; for (WebElement webElement : table2) { List<WebElement> elems = webElement.findElements(By.xpath("td")); String val = elems.get(3).getText(); boolean temp = !val.equals("true"); System.out.println(temp); def = def && temp; } Thread.sleep(4000); assertTrue(def); }
From source file:co.edu.uniandes.csw.RigitalApp.test.RepositorioTest.java
@Test public void testBuscarMaquina() throws Exception { driver.findElement(By.xpath("//button[contains(@id,'button-search')]")).click(); Thread.sleep(2000);// w ww.j a v a2 s .c om driver.findElement(By.id("btn_tableDestruido")).click(); Thread.sleep(2000); driver.findElement(By.id("destruido")).click(); Thread.sleep(2000); driver.findElement(By.id("btn_fechasTable")).click(); Thread.sleep(2000); driver.findElement(By.id("fechaCreacion")).clear(); driver.findElement(By.id("fechaCreacion")).sendKeys("20/11/2014"); Thread.sleep(2000); driver.findElement(By.id("fechaCreacion2")).clear(); driver.findElement(By.id("fechaCreacion2")).sendKeys("23/11/2014"); Thread.sleep(2000); driver.findElement(By.xpath("//button[contains(@id,'button-exec-search')]")).click(); Thread.sleep(2000); List<WebElement> table = driver .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr")); boolean success = true; for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); success = success && elems.get(1).getText().contains("Imagine"); } assertTrue(success); }
From source file:co.edu.uniandes.csw.RigitalApp.test.RepositorioTest.java
@AfterClass public static void tearDown() throws Exception { driver.get(baseUrl + "/RigitalApp.web/repositorio.html"); // Se selecciona la tabla para eliminar todos sus elementos List<WebElement> table = driver .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr")); /**//from w w w . j av a 2 s . co m * Se itera sobre los elementos de la tabla para eliminarlos */ for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); elems.get(5).findElement(By.linkText("Eliminar")).click(); assertTrue(true); } // Se cierra el navegador. driver.quit(); // Se verifica que se haya cerrado efectivamente el navegador. String verificationErrorString = verificationErrors.toString(); if (!"".equals(verificationErrorString)) { fail(verificationErrorString); } }
From source file:co.edu.uniandes.csw.RigitalApp.test.SoftwareSalasTest.java
@Test public void testCrearSoftware() throws Exception { driver.findElement(By.xpath("//button[contains(@id,'button-create')]")).click(); Thread.sleep(2000);/*w ww .j av a 2s .com*/ driver.findElement(By.id("name")).clear(); driver.findElement(By.id("name")).sendKeys("NetBeans IDE"); Thread.sleep(2000); driver.findElement(By.id("descripcion")).clear(); driver.findElement(By.id("descripcion")).sendKeys("Software de programacin"); Thread.sleep(2000); driver.findElement(By.id("caracteristicas")).clear(); driver.findElement(By.id("caracteristicas")).sendKeys("Este campo ya no se usa"); Thread.sleep(2000); driver.findElement(By.id("proposito")).clear(); driver.findElement(By.id("proposito")).sendKeys("Este tampoco, pero por si acaso"); Thread.sleep(2000); driver.findElement(By.id("fechaCreacion")).clear(); driver.findElement(By.id("fechaCreacion")).sendKeys("22/11/2014"); Thread.sleep(2000); driver.findElement(By.className("onoffswitch-label")).click(); Thread.sleep(2000); driver.findElement(By.id("solicitante")).clear(); driver.findElement(By.id("solicitante")).sendKeys("Websis"); Thread.sleep(2000); driver.findElement(By.id("software")).clear(); driver.findElement(By.id("software")).sendKeys("Waira1, Waira2, Turing"); Thread.sleep(2000); driver.findElement(By.id("version")).clear(); driver.findElement(By.id("version")).sendKeys("8.1.0"); Thread.sleep(2000); driver.findElement(By.xpath("//button[contains(@id,'button-save')]")).click(); Thread.sleep(2000); WebElement dialog = driver.findElement(By.xpath("//div[contains(@style,'display: block;')]")); List<WebElement> table = driver .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr")); boolean sucess = false; System.out.println(table); for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); if (elems.get(1).getText().equals("NetBeans IDE") && elems.get(2).getText().equals("22/11/2014") && elems.get(3).getText().equals("true")) { sucess = true; } } System.out.println(sucess); assertTrue(dialog != null && sucess); }
From source file:co.edu.uniandes.csw.RigitalApp.test.SoftwareSalasTest.java
@Test public void testDesactivarMaquina() throws Exception { Thread.sleep(2000);/*from w ww . java2 s . c o m*/ List<WebElement> table = driver .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr")); for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); if (elems.get(3).getText().equals("true")) { elems.get(0).findElement(By.tagName("input")).click(); } } Thread.sleep(2000); driver.findElement(By.xpath("//button[contains(@id,'button-desactivar')]")).click(); driver.get(baseUrl + "/RigitalApp.web/softwareSalas.html"); Thread.sleep(2000); List<WebElement> table2 = driver .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr")); boolean def = true; for (WebElement webElement : table2) { List<WebElement> elems = webElement.findElements(By.xpath("td")); String val = elems.get(3).getText(); boolean temp = !val.equals("true"); System.out.println(temp); def = def && temp; } Thread.sleep(4000); assertTrue(def); }
From source file:co.edu.uniandes.csw.RigitalApp.test.SoftwareSalasTest.java
@Test public void testBuscarMaquina() throws Exception { driver.findElement(By.xpath("//button[contains(@id,'button-search')]")).click(); Thread.sleep(2000);/*from w ww. j a va2s. c om*/ driver.findElement(By.id("btn_name")).click(); Thread.sleep(2000); driver.findElement(By.id("name")).clear(); driver.findElement(By.id("name")).sendKeys("IDE"); Thread.sleep(2000); driver.findElement(By.xpath("//button[contains(@id,'button-exec-search')]")).click(); Thread.sleep(2000); List<WebElement> table = driver .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr")); boolean success = true; for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); success = success && elems.get(1).getText().contains("IDE"); } assertTrue(success); }
From source file:co.edu.uniandes.csw.RigitalApp.test.SoftwareSalasTest.java
@AfterClass public static void tearDown() throws Exception { driver.get(baseUrl + "/RigitalApp.web/softwareSalas.html"); // Se selecciona la tabla para eliminar todos sus elementos List<WebElement> table = driver .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr")); /**/*from w ww . ja v a 2 s .co m*/ * Se itera sobre los elementos de la tabla para eliminarlos */ for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); elems.get(5).findElement(By.linkText("Eliminar")).click(); assertTrue(true); } // Se cierra el navegador. driver.quit(); // Se verifica que se haya cerrado efectivamente el navegador. String verificationErrorString = verificationErrors.toString(); if (!"".equals(verificationErrorString)) { fail(verificationErrorString); } }
From source file:co.edu.uniandes.csw.RigitalApp.test.SQLDevTest.java
@Test public void testCrearMaquina() throws Exception { driver.findElement(By.xpath("//button[contains(@id,'button-create')]")).click(); Thread.sleep(2000);//from w w w. j a va 2 s .c o m driver.findElement(By.id("name")).clear(); driver.findElement(By.id("name")).sendKeys("Imagine"); Thread.sleep(2000); driver.findElement(By.id("descripcion")).clear(); driver.findElement(By.id("descripcion")).sendKeys("Base de datos para el sitio Imagine"); Thread.sleep(2000); driver.findElement(By.id("fechaCreacion")).clear(); driver.findElement(By.id("fechaCreacion")).sendKeys("22/11/2014"); Thread.sleep(2000); driver.findElement(By.className("onoffswitch-label")).click(); Thread.sleep(2000); driver.findElement(By.id("fechaVencimiento")).clear(); driver.findElement(By.id("fechaVencimiento")).sendKeys("20/02/2015"); Thread.sleep(2000); driver.findElement(By.id("servidor")).clear(); driver.findElement(By.id("servidor")).sendKeys("sistemas.uniandes.edu.co"); Thread.sleep(2000); driver.findElement(By.id("pgwebId")).clear(); driver.findElement(By.id("pgwebId")).sendKeys("imagine.uniandes.edu.co"); Thread.sleep(2000); driver.findElement(By.xpath("//button[contains(@id,'button-save')]")).click(); Thread.sleep(2000); WebElement dialog = driver.findElement(By.xpath("//div[contains(@style,'display: block;')]")); List<WebElement> table = driver .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr")); boolean sucess = false; System.out.println(table); for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); if (elems.get(1).getText().equals("Imagine") && elems.get(2).getText().equals("22/11/2014") && elems.get(3).getText().equals("true")) { sucess = true; } } System.out.println(sucess); assertTrue(dialog != null && sucess); }
From source file:co.edu.uniandes.csw.RigitalApp.test.SQLDevTest.java
@Test public void testDesactivarMaquina() throws Exception { Thread.sleep(2000);/*from w w w. j a v a 2s . c om*/ List<WebElement> table = driver .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr")); for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); if (elems.get(3).getText().equals("true")) { elems.get(0).findElement(By.tagName("input")).click(); } } Thread.sleep(2000); driver.findElement(By.xpath("//button[contains(@id,'button-desactivar')]")).click(); driver.get(baseUrl + "/RigitalApp.web/sQLDev.html"); Thread.sleep(2000); List<WebElement> table2 = driver .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr")); boolean def = true; for (WebElement webElement : table2) { List<WebElement> elems = webElement.findElements(By.xpath("td")); String val = elems.get(3).getText(); boolean temp = !val.equals("true"); System.out.println(temp); def = def && temp; } Thread.sleep(4000); assertTrue(def); }
From source file:co.edu.uniandes.csw.RigitalApp.test.SQLDevTest.java
@Test public void testBuscarMaquina() throws Exception { driver.findElement(By.xpath("//button[contains(@id,'button-search')]")).click(); Thread.sleep(2000);//w w w . ja v a 2 s . c om driver.findElement(By.id("btn_name")).click(); Thread.sleep(2000); driver.findElement(By.id("name")).clear(); driver.findElement(By.id("name")).sendKeys("Imagine"); Thread.sleep(2000); driver.findElement(By.xpath("//button[contains(@id,'button-exec-search')]")).click(); Thread.sleep(2000); List<WebElement> table = driver .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr")); boolean success = true; for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); success = success && elems.get(1).getText().contains("Imagine"); } assertTrue(success); }