List of usage examples for org.openqa.selenium By id
public static By id(String id)
From source file:automation.PCCWGlobalcom.java
@Test public void test() throws Exception { driver.get(baseUrl + "/"); new Select(driver.findElement(By.id("network"))).selectByVisibleText("Off Net"); new Select(driver.findElement(By.id("src"))).selectByValue(locVar); new Select(driver.findElement(By.id("service"))).selectByVisibleText("traceroute"); driver.findElement(By.id("dst")).clear(); driver.findElement(By.id("dst")).sendKeys(dstIP); driver.findElement(By.id("submit")).click(); }
From source file:automation.PCCWGlobalcom.java
@After public void tearDown() throws Exception { Thread.sleep(60 * 1000);/*ww w.j av a 2 s. com*/ try { WebElement resultElement = driver.findElement(By.id("test_results")); List<WebElement> rows = resultElement.findElements(By.tagName("tr")); for (WebElement row : rows) { result += row.getText().trim() + "\n"; } System.out.println(result); // result = resultElement.getAttribute("innerHTML"); // result = result.replaceAll("[\u0000-\u0008]", ""); // result = result.replaceAll("[\u000B-\u001f]", ""); // result = replaceBrTag(result); // result = removeTags(result); // result = replaceHtmlString(result); } catch (Exception e) { Logger.getLogger(BT.class.getName()).log(Level.SEVERE, null, e); } finally { super.store(); driver.quit(); String verificationErrorString = verificationErrors.toString(); if (!"".equals(verificationErrorString)) { fail(verificationErrorString); } } }
From source file:backend.BackendLoginTest.java
@Test(description = "wfp backend setup", priority = 1) public void frontendSetup() { driver.navigate().to("http://localhost:8082/workflow4people"); WebDriverWait wait = new WebDriverWait(driver, 10); WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("j_username"))); }
From source file:backend.MakeUserTest.java
@Test(description = "create user", priority = 2, dependsOnMethods = { "openUserPage" }) public void makeUser() { WebDriverWait wait = new WebDriverWait(driver, 10); driver.findElement(By.xpath(//from w ww. j a v a2s . co m "//span[@onclick=\"dialog.formDialog(null,'person', { refresh : 'detailTable_person'}, {})\"]")) .click(); WebElement elementUsername = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("username"))); textInput("username", "testUser123"); textInput("userRealName", "test user"); textInput("givenName", "test"); textInput("familyName", "user"); textInput("email", "testuser@gmail.com"); driver.findElement(By.partialLinkText("Password")).click(); WebElement elementPassword = wait .until(ExpectedConditions.visibilityOfElementLocated(By.id("newPassword"))); textInput("newPassword", "test123"); textInput("newPassword2", "test123"); driver.findElement(By.xpath("//span[text()='OK']")).click(); WebElement elementButton = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath( "//span[@onclick=\"dialog.formDialog(null,'person', { refresh : 'detailTable_person'}, {})\"]"))); }
From source file:backend.MakeUserTest.java
@Test(description = "check if new user was succesfully added", priority = 3, dependsOnMethods = { "makeUser" }) public void validateNewUser() throws InterruptedException { WebDriverWait wait = new WebDriverWait(driver, 10); //sort descending(newest on top) WebElement table = driver.findElement(By.id("detailTable_person")); WebElement idCell = table.findElement(By.xpath("//th[text()='Id']")); idCell.click();// w ww .ja va2 s .c o m Thread.sleep(500); //select first table entry List<WebElement> tableRows = table.findElements(By.tagName("tr")); String userId = tableRows.get(2).findElement(By.xpath("//td[1]")).getText(); String nameCell = tableRows.get(2).findElement(By.xpath("//td[2]")).getText(); //validate if first entry is the new user. delete user if true, fails test if false if (nameCell.equals("testUser123")) { WebElement delete = table.findElement(By.xpath("//span[@onclick=\"dialog.deleteDialog('" + userId + "','person',{ refresh : 'null'}, null)\"]")); delete.click(); WebElement elementConfirm = wait .until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='Delete']"))); WebElement confirm = table.findElement(By.xpath("//span[text()='Delete']")); confirm.click(); WebElement elementButton = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath( "//span[@onclick=\"dialog.formDialog(null,'person', { refresh : 'detailTable_person'}, {})\"]"))); } else { org.testng.Assert.fail("Test user was not succesfully created."); } }
From source file:backend.MakeUserTest.java
private void textInput(String elementID, String value) { WebElement inputElement = driver.findElement(By.id(elementID)); inputElement.sendKeys(value); }
From source file:Basic.NewTest.java
@Test public void testEasy() { try {// w w w . ja va2 s. co m driver.get( "https://www37b.swalife.com/servicenowtest/?SAMLRequest=nVPLbtswEPwVgXc9nTgSYRlwFRQ1kKaKpfTQG02tEgIUqXIp2%2F37UrKT%2BNAYhQ8EAe6QOzM7XCDrZNLT1WBf1QZ%2BD4DWO3RSIT1WcjIYRTVDgVSxDpBaTqvV9weaBBHtjbaaa0m8FSIYK7QqtMKhA1OB2QkOz5uHnLxa2yMNQ9Suzd61sG4FeET4Su8DrrtQsV3PXiBoNPG%2BasNhIpWTlkkE4q3vc1I9Ftso4fMmZlmbtTfb2%2FldlqZZso0gnbVtxpgDYskQxQ4%2BriIOsFZombI5SaJ47kepnyR1PKM3CU1ug7tZ%2Bot45UnOF6EaoV4ua98eQUi%2F1XXplz%2BqenpgJxowjw59jeyfYNB56DgGEVkuphHQib05n8plYuxtFGT5XwwW4XmfU9eejhrW96WWgv%2FxVlLqfWGAWafLmgGmEXXMfk4lDuLpRDR%2BO0HpMx6dIV5VjvvTwKRoBZgrrArfeZ5SC80UFxc%2FCwfrFbrrmRE4mgkHxu27neewQjqzNtBeZe5FGKd8fNsdj2Hca9OM4QLueNaGKey1sW%2FG%2F4vR8lT8RN9H%2BfznLv8C&RelayState=https://southwesttest.service-now.com/navpage.do"); driver.manage().window().maximize(); driver.findElement(By.id("ContentPlaceHolder1_MFALoginControl1_UserIDView_txtUserid")) .sendKeys("x226509"); driver.findElement(By.id("ContentPlaceHolder1_MFALoginControl1_UserIDView_tbxPassword")) .sendKeys("Welcome@ibm2"); driver.findElement(By.id("ContentPlaceHolder1_MFALoginControl1_UserIDView_btnSubmit")).click(); driver.findElement(By.id("filter")).sendKeys("software model"); Thread.sleep(1000); driver.findElement(sofModel).click(); ; Thread.sleep(1000); driver.findElement(By.id("sysverb_new")); } catch (Exception e) { e.printStackTrace(); } // AssertJUnit.assertTrue(title.contains("Free Selenium Tutorials")); }
From source file:basicweb.ElementDisplayed.java
@Test public void testLetsKodeIt() throws InterruptedException { driver.get(baseUrl1);// w w w .j av a 2 s .c o m WebElement textBox = driver.findElement(By.id("displayed-text")); System.out.println("Text Box Displayed: " + textBox.isDisplayed()); Thread.sleep(3000); WebElement hideButton = driver.findElement(By.id("hide-textbox")); hideButton.click(); System.out.println("Clicked on hide button"); System.out.println("Text Box Displayed: " + textBox.isDisplayed()); Thread.sleep(3000); // Added code to scroll up because the element was hiding behind the top navigation menu // You will learn about scrolling in future lecture js.executeScript("window.scrollBy(0, -190);"); WebElement showButton = driver.findElement(By.id("show-textbox")); showButton.click(); System.out.println("Clicked on show button"); System.out.println("Text Box Displayed: " + textBox.isDisplayed()); }
From source file:basicweb.ElementDisplayed.java
@Test public void testExpedia() throws InterruptedException { driver.get(baseUrl2);//from w ww .ja va 2 s. co m WebElement childDropdown = driver.findElement(By.id("package-1-age-select-1")); System.out.println("Child Drpdown Displayed: " + childDropdown.isDisplayed()); }
From source file:be.rubus.web.jerry.initializer.RequiredInitializerTest.java
License:Apache License
@Test @RunAsClient/*from ww w. ja v a2s. c om*/ public void testRequired() throws Exception { driver.get(new URL(contextPath, "validations.xhtml").toString()); WebElement submitButton = driver.findElement(By.id("test:submit")); submitButton.click(); Thread.sleep(1000); WebElement messages = driver.findElement(By.id("messages")); List<WebElement> errorElements = messages.findElements(By.tagName("li")); assertThat(errorElements).hasSize(1); assertThat(errorElements.get(0).getText()).contains("Validation Error: Value is required."); }