List of usage examples for org.openqa.selenium By linkText
public static By linkText(String linkText)
From source file:openCloseTables.java
public static void main(String[] args) throws IOException { System.setProperty("webdriver.ie.driver", "C:\\Users\\Colin Cook\\Desktop\\selenium-2.53.1\\IEDriverServer.exe"); WebDriver driver = new InternetExplorerDriver(); driver.get("http://10.0.1.53/opstar_test/"); out.println("Launching Internet Explorer browser.."); driver.manage().window().maximize(); try {// w w w.j a v a 2 s.c o m Thread.sleep(3000); // pauses for 3 seconds } catch (InterruptedException e) { e.printStackTrace(); } out.println("The title of the page being tested is: " + driver.getTitle()); WebElement acknowledge = driver .findElement(By.xpath("html/body/div[5]/div[1]/div[2]/div[2]/div[1]/div/div[2]/center/a")); acknowledge.click(); //first popup when you go on site try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement applications = //driver.findElement(By.xpath("html/body/div[3]/div[2]/div/div[1]/ul[2]/li[5]/a/span")); driver.findElement(By.linkText("Applications")); applications.click(); WebElement toTools = driver .findElement(By.xpath("html/body/div[3]/div[2]/div/div[1]/ul[2]/li[7]/ul/li[2]/a")); toTools.click(); try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement traingFolder = driver .findElement(By.xpath("html/body/div[3]/div[2]/div/div[1]/ul[2]/li[7]/ul/li[2]/ul/li/a")); traingFolder.click(); try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement closeBox = driver.findElement(By.id("cboxClose")); closeBox.click(); //clicks second popup acknolwedge box try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement textBox = driver.findElement(By .xpath("html/body/div[3]/div[4]/div[2]/div/div[1]/div/div[2]/div/form/div/div/span/span[1]/span")); textBox.click(); textBox.sendKeys("ken"); //first three letters of someones name try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } textBox.sendKeys(Keys.ENTER); try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement table1 = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[1]/div/div[1]/div/a[2]")); table1.click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } table1.click(); out.println("The Designations folder has been successfully opened and closed"); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement table2 = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[2]/div/div[1]/div/a[2]")); table2.click(); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } table2.click(); out.println("The Waivers folder has been successfully opened and closed"); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement table3 = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[3]/div/div[1]/div/a[2]")); table3.click(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } table3.click(); out.println("The Professional Licenses/ Certificates / Medical folder has been opened and closed"); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement table4 = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[4]/div/div[1]/div/a[2]")); table4.click(); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } table4.click(); out.println("The First Aid folder has been succesfully opened and closed"); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement table5 = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[5]/div/div[1]/div/a[2]")); table5.click(); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } table5.click(); out.println("The Star folder has been successfully opened and closed"); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement table6 = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[6]/div/div[1]/div/a[2]")); table6.click(); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } table6.click(); out.println("The Training Courses and Tests folder has been successfully opened and closed"); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement table7 = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[7]/div/div[1]/div/a[2]")); table7.click(); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } table7.click(); out.println( "The Professional Development / Individual Development Plan folder has been successfully opened and closed"); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement table8 = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[8]/div/div[1]/div/a[2]")); table8.click(); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } table8.click(); out.println("The FLETC Certificates folder has been successfully opened and closed"); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement table9 = driver.findElement( By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[2]/div[9]/div/div[1]/div/a[2]")); table9.click(); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } table9.click(); out.println("The Miscellaneous folder has been succesfully opened and closed"); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } WebElement qualifications = driver .findElement(By.xpath("html/body/div[3]/div[4]/div[2]/div/div[2]/div[1]/div/div/div[1]/div/a[2]")); qualifications.click(); try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } qualifications.click(); out.println("The Qualifications folder has been successfully opened and closed"); // I should program test scripts like this in the future // try { // WebElement xbox = driver.findElement(By.id("cboxClose")); // xbox.click(); // } catch(Exception e) { // System.err.print("NO NO NO that "); // } }
From source file:ProveedorTest.java
@Test public void testUpdateProveedor() throws Exception { String name = "Un nombre ahi"; String email = "prueba@prueba.com.co"; String telefono = "9999999"; String direccion = "diagonal 5 con calle 6"; String observaciones = "hohohoo"; /**//w w w . j a v a2 s . c o m * Se hace clic en el vinculo "Edit" del primer elemento de la lista de * sports */ driver.findElement(By.linkText("Editar")).click(); Thread.sleep(2000); /** * Se realiza el mismo proceso de diligenciamento de los campos con los * cambios */ driver.findElement(By.id("name")).clear(); driver.findElement(By.id("name")).sendKeys(name); driver.findElement(By.id("email")).clear(); driver.findElement(By.id("email")).sendKeys(email); driver.findElement(By.id("telefono")).clear(); driver.findElement(By.id("telefono")).sendKeys(telefono); driver.findElement(By.id("direccion")).clear(); driver.findElement(By.id("direccion")).sendKeys(direccion); driver.findElement(By.id("observaciones")).clear(); driver.findElement(By.id("observaciones")).sendKeys(observaciones); driver.findElement(By.xpath("//button[contains(@id,'saveButton')]")).click(); Thread.sleep(2000); /** * Se verifica que en la lista de respuesta hallan aparecido los cambios * en el elemento y tambin el mensaje de edicin exitosa. */ 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 fail = false; for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); if (elems.get(0).getText().equals(name) && elems.get(1).getText().equals(email) && elems.get(2).getText().equals(telefono) && elems.get(3).getText().equals(direccion) && elems.get(4).getText().equals(observaciones)) { fail = true; } } assertTrue(dialog != null && fail); }
From source file:ProveedorTest.java
@Test public void testDeleteProveedor() throws Exception { /**/*from w ww . j av a 2 s .c o m*/ * Se hace clic en el vinculo "Delete" del primer elemento de la lista * de sports */ driver.findElement(By.linkText("Eliminar")).click(); Thread.sleep(2000); /** * Se verifica que en la lista el elemento halla desaparecido. Si * existe, hubo un error. */ try { List<WebElement> table = driver .findElements(By.xpath("//table[contains(@class,'table striped')]/tbody/tr")); boolean fail = false; String name = "Un nombre ahi"; String email = "prueba@prueba.com.co"; String telefono = "9999999"; String direccion = "diagonal 5 con calle 6"; String observaciones = "hohohoo"; for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); if (elems.get(0).getText().equals(name) && elems.get(1).getText().equals(email) && elems.get(2).getText().equals(telefono) && elems.get(3).getText().equals(direccion) && elems.get(4).getText().equals(observaciones)) { fail = true; } } WebElement dialog = driver.findElement(By.xpath("//div[contains(@style,'display: block;')]")); assertTrue(dialog != null && !fail); } catch (Exception e) { assertTrue(true); } }
From source file:InventarioTest.java
@Test public void testUpdateProveedor() throws Exception { /**/*ww w. j a v a 2 s . c o m*/ * Se hace clic en el vinculo "Edit" del primer elemento de la lista de * sports */ driver.findElement(By.linkText("Editar")).click(); Thread.sleep(2000); /** * Se realiza el mismo proceso de diligenciamento de los campos con los * cambios */ driver.findElement(By.id("name")).clear(); driver.findElement(By.id("name")).sendKeys(name2); driver.findElement(By.xpath("//button[contains(@id,'saveButton')]")).click(); Thread.sleep(2000); /** * Se verifica que en la lista de respuesta hallan aparecido los cambios * en el elemento y tambin el mensaje de edicin exitosa. */ 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 fail = false; for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); if (elems.get(0).getText().equals(name2)) { fail = true; } } assertTrue(dialog != null && fail); }
From source file:InventarioTest.java
@Test public void testDeleteProveedor() throws Exception { /**/*from w w w. j av a 2 s.co m*/ * Se hace clic en el vinculo "Delete" del primer elemento de la lista * de sports */ driver.findElement(By.linkText("Eliminar")).click(); Thread.sleep(2000); /** * Se verifica que en la lista el elemento halla desaparecido. Si * existe, hubo un error. */ try { List<WebElement> table = driver .findElements(By.xpath("//table[contains(@class,'table striped')]/tbody/tr")); boolean fail = false; for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); if (elems.get(0).getText().equals(name2)) { fail = true; } } WebElement dialog = driver.findElement(By.xpath("//div[contains(@style,'display: block;')]")); assertTrue(dialog != null && !fail); } catch (Exception e) { assertTrue(true); } }
From source file:OrdenFabricacionTest.java
@Test public void testUpdateProveedor() throws Exception { /**/*from www . j a v a2 s . c o m*/ * Se hace clic en el vinculo "Edit" del primer elemento de la lista de * sports */ driver.findElement(By.linkText("Editar")).click(); Thread.sleep(2000); /** * Se realiza el mismo proceso de diligenciamento de los campos con los * cambios */ driver.findElement(By.id("name")).clear(); driver.findElement(By.id("name")).sendKeys(name2); driver.findElement(By.id("fecha")).clear(); driver.findElement(By.id("fecha")).sendKeys(fecha2); driver.findElement(By.id("cantidad")).clear(); driver.findElement(By.id("cantidad")).sendKeys(cantidad2); driver.findElement(By.id("estado")).clear(); driver.findElement(By.id("estado")).sendKeys(estado2); driver.findElement(By.id("nombreProducto")).clear(); driver.findElement(By.id("nombreProducto")).sendKeys(nombreProducto2); driver.findElement(By.xpath("//button[contains(@id,'saveButton')]")).click(); Thread.sleep(2000); /** * Se verifica que en la lista de respuesta hallan aparecido los cambios * en el elemento y tambin el mensaje de edicin exitosa. */ 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 fail = false; for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); if (elems.get(0).getText().equals(name2) && Integer.parseInt( elems.get(1).getText().split("/")[0]) == (Integer.parseInt(fecha2.split("/")[0])) && Integer.parseInt( elems.get(1).getText().split("/")[1]) == (Integer.parseInt(fecha2.split("/")[1])) && Integer.parseInt( elems.get(1).getText().split("/")[2]) == (Integer.parseInt(fecha2.split("/")[2])) && elems.get(2).getText().equals(cantidad2) && elems.get(3).getText().equals(estado2) && elems.get(4).getText().equals(nombreProducto2)) { fail = true; } } assertTrue(dialog != null && fail); }
From source file:OrdenFabricacionTest.java
@Test public void testDeleteProveedor() throws Exception { /**//from w w w. j av a 2s .c o m * Se hace clic en el vinculo "Delete" del primer elemento de la lista * de sports */ driver.findElement(By.linkText("Eliminar")).click(); Thread.sleep(2000); /** * Se verifica que en la lista el elemento halla desaparecido. Si * existe, hubo un error. */ try { List<WebElement> table = driver .findElements(By.xpath("//table[contains(@class,'table striped')]/tbody/tr")); boolean fail = false; for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); if (elems.get(0).getText().equals(name2) && Integer.parseInt( elems.get(1).getText().split("/")[0]) == (Integer.parseInt(fecha2.split("/")[0])) && Integer.parseInt( elems.get(1).getText().split("/")[1]) == (Integer.parseInt(fecha2.split("/")[1])) && Integer.parseInt( elems.get(1).getText().split("/")[2]) == (Integer.parseInt(fecha2.split("/")[2])) && elems.get(2).getText().equals(cantidad2) && elems.get(3).getText().equals(estado2) && elems.get(4).getText().equals(nombreProducto2)) { fail = true; } } WebElement dialog = driver.findElement(By.xpath("//div[contains(@style,'display: block;')]")); assertTrue(dialog != null && !fail); } catch (Exception e) { assertTrue(true); } }
From source file:ItemTest.java
@Test public void testUpdateProveedor() throws Exception { /**//from www. ja v a 2s . co m * Se hace clic en el vinculo "Edit" del primer elemento de la lista de * sports */ driver.findElement(By.linkText("Editar")).click(); Thread.sleep(2000); /** * Se realiza el mismo proceso de diligenciamento de los campos con los * cambios */ driver.findElement(By.id("name")).clear(); driver.findElement(By.id("name")).sendKeys(name2); driver.findElement(By.id("fechaCaducidad")).clear(); driver.findElement(By.id("fechaCaducidad")).sendKeys(fechaCaducidad2); driver.findElement(By.id("motivoIngreso")).clear(); driver.findElement(By.id("motivoIngreso")).sendKeys(motivoIngreso2); driver.findElement(By.id("motivoSalid")).clear(); driver.findElement(By.id("motivoSalid")).sendKeys(motivoSalida2); driver.findElement(By.xpath("//button[contains(@id,'saveButton')]")).click(); Thread.sleep(2000); /** * Se verifica que en la lista de respuesta hallan aparecido los cambios * en el elemento y tambin el mensaje de edicin exitosa. */ 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 fail = false; for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); if (elems.get(0).getText().equals(name2) && Integer.parseInt(elems.get(1).getText().split("/")[0]) == (Integer .parseInt(fechaCaducidad2.split("/")[0])) && Integer.parseInt(elems.get(1).getText().split("/")[1]) == (Integer .parseInt(fechaCaducidad2.split("/")[1])) && Integer.parseInt(elems.get(1).getText().split("/")[2]) == (Integer .parseInt(fechaCaducidad2.split("/")[2])) && elems.get(3).getText().equals(motivoIngreso2) && elems.get(4).getText().equals(motivoSalida2)) { fail = true; } } assertTrue(dialog != null && fail); }
From source file:ItemTest.java
@Test public void testDeleteProveedor() throws Exception { /**/*from w w w . j a va 2 s .c o m*/ * Se hace clic en el vinculo "Delete" del primer elemento de la lista * de sports */ driver.findElement(By.linkText("Eliminar")).click(); Thread.sleep(2000); /** * Se verifica que en la lista el elemento halla desaparecido. Si * existe, hubo un error. */ try { List<WebElement> table = driver .findElements(By.xpath("//table[contains(@class,'table striped')]/tbody/tr")); boolean fail = false; for (WebElement webElement : table) { List<WebElement> elems = webElement.findElements(By.xpath("td")); if (elems.get(0).getText().equals(name2) && Integer.parseInt(elems.get(1).getText().split("/")[0]) == (Integer .parseInt(fechaCaducidad2.split("/")[0])) && Integer.parseInt(elems.get(1).getText().split("/")[1]) == (Integer .parseInt(fechaCaducidad2.split("/")[1])) && Integer.parseInt(elems.get(1).getText().split("/")[2]) == (Integer .parseInt(fechaCaducidad2.split("/")[2])) && elems.get(3).getText().equals(motivoIngreso2) && elems.get(4).getText().equals(motivoSalida2)) { fail = true; } } WebElement dialog = driver.findElement(By.xpath("//div[contains(@style,'display: block;')]")); assertTrue(dialog != null && !fail); } catch (Exception e) { assertTrue(true); } }
From source file:XKCDNavigationTest.java
License:Open Source License
@Test public void testWhatIf() { String url = "http://what-if.xkcd.com/"; driver.findElement(By.linkText("What If?")).click(); String curr = driver.getCurrentUrl(); assertEquals(url, curr);/*from w w w .ja v a2 s. co m*/ }