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.MySQLTest.java
@Test public void testBuscarMaquina() throws Exception { driver.findElement(By.xpath("//button[contains(@id,'button-search')]")).click(); Thread.sleep(2000);/* w w w.j a v a 2s .co m*/ driver.findElement(By.id("btn_tableDestruido")).click(); Thread.sleep(2000); driver.findElement(By.id("destruido")).click(); Thread.sleep(2000); driver.findElement(By.id("btn_servidor")).click(); Thread.sleep(2000); driver.findElement(By.id("servidor")).clear(); driver.findElement(By.id("servidor")).sendKeys("edu"); 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.MySQLTest.java
@AfterClass public static void tearDown() throws Exception { driver.get(baseUrl + "/RigitalApp.web/mySQL.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 ww w. j a v a2 s .c o 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.PaginaWebTest.java
@Test public void testCrearPagina() throws Exception { driver.findElement(By.xpath("//button[contains(@id,'button-create')]")).click(); Thread.sleep(2000);// w w w. j ava 2 s.c o m driver.findElement(By.id("name")).clear(); driver.findElement(By.id("name")).sendKeys("Eventos"); Thread.sleep(2000); driver.findElement(By.id("descripcion")).clear(); driver.findElement(By.id("descripcion")) .sendKeys("Pgina web para la informacin de eventos de la universidad"); 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("formato")).clear(); driver.findElement(By.id("formato")).sendKeys("Joomla"); Thread.sleep(2000); driver.findElement(By.id("ultimaFechaModificacion")).clear(); driver.findElement(By.id("ultimaFechaModificacion")).sendKeys("22/11/2014"); Thread.sleep(2000); driver.findElement(By.id("url")).clear(); driver.findElement(By.id("url")).sendKeys("eventos.uniandes.edu.co"); Thread.sleep(2000); driver.findElement(By.id("alias")).clear(); driver.findElement(By.id("alias")).sendKeys("www.eventosuniandes.com"); 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("Eventos") && 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.PaginaWebTest.java
@Test public void testDesactivarPagina() throws Exception { Thread.sleep(2000);//from www . ja v a 2s .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/paginaWeb.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.PaginaWebTest.java
@Test public void testBuscarPagina() throws Exception { driver.findElement(By.xpath("//button[contains(@id,'button-search')]")).click(); Thread.sleep(2000);/*from ww w .j av a 2 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_alias")).click(); Thread.sleep(2000); driver.findElement(By.id("alias")).clear(); driver.findElement(By.id("alias")).sendKeys("tosuni"); 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("Eventos"); } assertTrue(success); }
From source file:co.edu.uniandes.csw.RigitalApp.test.PaginaWebTest.java
@AfterClass public static void tearDown() throws Exception { driver.get(baseUrl + "/RigitalApp.web/paginaWeb.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 www . 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.ProblemaTest.java
@Test public void testCrearProblema() throws Exception { driver.findElement(By.xpath("//button[contains(@id,'button-create')]")).click(); Thread.sleep(2000);//from ww w .j a v a 2 s. c o m driver.findElement(By.id("name")).clear(); driver.findElement(By.id("name")).sendKeys("Problema con recurso"); Thread.sleep(2000); driver.findElement(By.id("descripcion")).clear(); driver.findElement(By.id("descripcion")).sendKeys("El recurso est fallando"); Thread.sleep(2000); driver.findElement(By.id("fechaDeOcurrencia")).clear(); driver.findElement(By.id("fechaDeOcurrencia")).sendKeys("23/11/2014"); Thread.sleep(2000); driver.findElement(By.xpath("//button[contains(@id,'button-save')]")).click(); /** * Comando que duerme el thread para esperar el efecto de slide down que * abre la lista */ Thread.sleep(2000); /** * Comando que obtiene el div azul de creacin exitosa. Si se obtiene, * la prueba va bien, si no, saldr un error y la prueba quedar como * fllida. */ WebElement dialog = driver.findElement(By.xpath("//div[contains(@style,'display: block;')]")); /** * Comando que obtiene la tabla con el elemento que se cre * anteriormente. */ List<WebElement> table = driver .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr")); boolean sucess = false; /** * Se itera sobre los elementos de la tabla para ver si el nuevo * elemento creado est en la lista */ for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); System.out.println("nombre: " + elems.get(1).getText() + " fecha: " + elems.get(2).getText()); if (elems.get(0).getText().equals("Problema con recurso") && elems.get(1).getText().equals("23/11/2014")) { /** * si se encuentra la fila, la variable 'fail' pasa a true, * indicando que el elemento creado esta en la lista. */ sucess = true; } } /** * la prueba es exitosa si se encontr el dialogo de creacin exitosa y * el nuevo elemento est en la lista. */ assertTrue(dialog != null && sucess); }
From source file:co.edu.uniandes.csw.RigitalApp.test.ProblemaTest.java
@Test public void testBuscarWiki() throws Exception { driver.findElement(By.xpath("//button[contains(@id,'button-search')]")).click(); Thread.sleep(2000);// w w w . ja v a 2 s . co m driver.findElement(By.id("btn_name")).click(); Thread.sleep(2000); driver.findElement(By.id("name")).clear(); driver.findElement(By.id("name")).sendKeys("recurso"); 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; /** * Se itera sobre los elementos de la tabla para ver si el nuevo * elemento creado est en la lista */ for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); success = success && elems.get(0).getText().contains("recurso"); } /** * la prueba es exitosa si se encontr el dialogo de creacin exitosa y * el nuevo elemento est en la lista. */ assertTrue(success); }
From source file:co.edu.uniandes.csw.RigitalApp.test.ProblemaTest.java
@AfterClass public static void tearDown() throws Exception { // Se selecciona la tabla para eliminar todos sus elementos List<WebElement> table = driver .findElements(By.xpath("//table[contains(@class,'table-striped')]/tbody/tr")); /**/*w w w. j a v a 2 s .c om*/ * Se itera sobre los elementos de la tabla para eliminarlos */ for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); elems.get(3).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.RepositorioTest.java
@Test public void testCrearMaquina() throws Exception { driver.findElement(By.xpath("//button[contains(@id,'button-create')]")).click(); Thread.sleep(2000);// w w w. j a v a 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("Repositorio para el grupo 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("tipo")).clear(); driver.findElement(By.id("tipo")).sendKeys("SVN"); Thread.sleep(2000); driver.findElement(By.id("servidor")).clear(); driver.findElement(By.id("servidor")).sendKeys("minsky2.virtual.uniandes.edu.co"); Thread.sleep(2000); driver.findElement(By.id("tipoAcceso")).clear(); driver.findElement(By.id("tipoAcceso")).sendKeys("ldap"); Thread.sleep(2000); driver.findElement(By.id("ubicacionDelServidor")).clear(); driver.findElement(By.id("ubicacionDelServidor")).sendKeys("/repositorio/imagine"); Thread.sleep(2000); driver.findElement(By.id("url")).clear(); driver.findElement(By.id("url")).sendKeys("minsky2.virtual.uniandes.edu.co/imagine"); 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); }