List of usage examples for org.openqa.selenium By name
public static By name(String name)
From source file:com.example.selenium.grid.SeleniumGridIE.java
@Test(dataProvider = "xlsTest") public void testLogin(String useName, String password) throws InterruptedException { driver.get("http://localhost:8080/WebApplication/pages/login.html"); Thread.sleep(2000);// ww w. j a va 2s . c o m WebElement userNameText = driver.findElement(By.name("email")); userNameText.sendKeys(useName); WebElement passwordText = driver.findElement(By.id("password")); passwordText.sendKeys(password); WebElement loginButton = driver.findElement(By.linkText("Login")); loginButton.click(); if (driver.getTitle().equals("SB Admin 2 - Bootstrap Admin Theme")) { assertTrue(true); } else { assertTrue(false); } }
From source file:com.example.selenium.grid.SeleniumGridTest.java
@Test public void testLogin() throws InterruptedException { WebElement userNameText = driver.findElement(By.name("email")); userNameText.sendKeys("jayasimha.bj@gmail.com"); WebElement passwordText = driver.findElement(By.id("password")); passwordText.sendKeys("welcome123"); WebElement loginButton = driver.findElement(By.linkText("Login")); loginButton.click();/* w w w . j a v a 2s. c om*/ if (driver.getTitle().equals("SB Admin 2 - Bootstrap Admin Theme")) { assertTrue(true); } else { assertTrue(false); } }
From source file:com.example.tests.CadastroChromeTest.java
@Test public void testCadastroLol() throws Exception { GerarCod gc = new GerarCod(); driver.get("http://localhost:8080/" + "/ModuloDois/"); driver.findElement(By.linkText("Cadastrar")).click(); driver.findElement(By.name("campoCadastroID")).clear(); driver.findElement(By.name("campoCadastroID")).sendKeys(gc.gerarCod()); driver.findElement(By.name("campoCadastroNome")).clear(); driver.findElement(By.name("campoCadastroNome")).sendKeys("exemplo"); driver.findElement(By.name("campoCadastroQuantidade")).clear(); driver.findElement(By.name("campoCadastroQuantidade")).sendKeys("78"); driver.findElement(By.name("campoCadastroUnidade")).clear(); driver.findElement(By.name("campoCadastroUnidade")).sendKeys("78"); driver.findElement(By.name("campoCadastroValor")).clear(); driver.findElement(By.name("campoCadastroValor")).sendKeys("20.32"); driver.findElement(By.cssSelector("button.btn.btn-success")).click(); }
From source file:com.example.tests.SignUp.java
@Test public void testSignUp() throws Exception { // ERROR: Caught exception [ERROR: Unsupported command [selectWindow | null | ]] driver.findElement(By.xpath("(//a[contains(text(),'PROCEED')])[2]")).click(); driver.findElement(By.id("firstName")).clear(); driver.findElement(By.id("firstName")).sendKeys("Neha"); driver.findElement(By.id("lastName")).clear(); driver.findElement(By.id("lastName")).sendKeys("Agarwal"); driver.findElement(By.id("organization_email")).clear(); driver.findElement(By.id("organization_email")).sendKeys("15/09-12@weboapps.com"); driver.findElement(By.id("organization_password")).clear(); driver.findElement(By.id("organization_password")).sendKeys("12345678"); driver.findElement(By.cssSelector("#new_organizations_organization > input[name=\"commit\"]")).click(); driver.findElement(By.id("organization_name")).clear(); driver.findElement(By.id("organization_name")).sendKeys("15/09"); driver.findElement(By.id("organizations_organization_category_id_1")).click(); driver.findElement(By.cssSelector("div.licenseSelect")).click(); driver.findElement(By.name("commit")).click(); driver.findElement(By.id("organizations_organization_plan_id_2")).click(); driver.findElement(By.cssSelector("div.licenseSelect")).click(); driver.findElement(By.name("commit")).click(); driver.findElement(By.id("address")).clear(); driver.findElement(By.id("address")).sendKeys("fgh"); driver.findElement(By.id("mobile_number")).click(); driver.findElement(By.id("mobile_number")).sendKeys("1234567890"); driver.findElement(By.id("postal_code")).clear(); driver.findElement(By.id("postal_code")).sendKeys("99546"); driver.findElement(By.id("user_email")).clear(); driver.findElement(By.id("user_email")).sendKeys("neha2@weboapps.com"); driver.findElement(By.name("commit")).click(); }
From source file:com.formkiq.web.FolderIntegrationTest.java
License:Apache License
/** * testAddFolder01().//from ww w . j a va 2 s. co m * add folder - missing name * * @throws Exception Exception */ @Test public void testAddFolder01() throws Exception { // given // when findElementBy(By.id("folder_add_button")).click(); getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("form-modal"))); click(By.name("_eventId_next")); // then waitUntilPageSourceText("Field required"); }
From source file:com.formkiq.web.FolderIntegrationTest.java
License:Apache License
/** * testAddFolder02().//from ww w.j ava 2s . c o m * add folder * * @throws Exception Exception */ @Test public void testAddFolder02() throws Exception { // given String folder = "testfolder"; // when findElementBy(By.id("folder_add_button")).click(); getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("form-modal"))); findElementBy("input", "data-valuekey", "name").sendKeys(folder); WebElement el = findElementBy(By.name("_eventId_next")); assertEquals("Add Folder", el.getText()); el.click(); // then getWait().until(ExpectedConditions.invisibilityOfElementLocated(By.id("form-modal"))); int i = 0; final int elementCount = 2; List<WebElement> e = findElements(By.xpath("//table[@id='results']/tbody/tr/td")); assertEquals(elementCount, e.size()); assertEquals("testfolder", e.get(i++).getText()); assertEquals("", e.get(i++).getText()); // when findElementBy(By.id("tablesearch")).sendKeys("testf1"); findElementBy(By.id("buttonsearch")).click(); // then e = findElements(By.xpath("//table[@id='results']/tbody/tr")); assertEquals(1, e.size()); assertEquals("No Folder(s) found", e.get(0).getText()); // when findElementBy(By.id("tablesearch")).clear(); findElementBy(By.id("tablesearch")).sendKeys("testf"); findElementBy(By.id("buttonsearch")).click(); // then e = findElements(By.xpath("//table[@id='results']/tbody/tr")); assertEquals(1, e.size()); assertEquals("testfolder", e.get(0).getText()); }
From source file:com.formkiq.web.LicenseSeleniumTest.java
License:Apache License
/** * invalid license./* ww w. j av a2 s . c o m*/ */ @Test public void testLicense01() { // given String license = "adsaadad"; // when findElementBy("textarea", "data-valuekey", "license").sendKeys(license); click(By.name("_eventId_next")); // then assertEquals("Unregistered Server", findElementBy(By.className("form-section-label")).getText()); assertTrue(getPageSource().contains("Invalid License Key")); }
From source file:com.formkiq.web.LicenseSeleniumTest.java
License:Apache License
/** * valid license./*from w w w .j av a 2 s . c o m*/ * @throws Exception Exception */ @Test public void testLicense02() throws Exception { // given String license = Resources.getResourceAsString("/TestCompany.lic"); // when findElementBy("textarea", "data-valuekey", "license").sendKeys(license); click(By.name("_eventId_next")); // then assertEquals("Registered Server", findElementBy(By.className("form-section-label")).getText()); assertEquals(license, findElementBy(getBy("textarea", "data-valuekey", "license")).getText()); String info = findElementBy(getBy("div", "data-valuekey", "info")).getText(); assertTrue(info.contains("Company: Test Company")); assertTrue(info.contains("Issue Date: Sun Jun 25 21:27:33 CDT 2017")); assertTrue(info.contains("Expiry Date: Sun Jun 25 21:27:33 CDT 2017")); assertTrue(info.contains("Issued By: FormKiQ Inc.")); String token = login("testapp", "testapp", getDefaultEmail(), getDefaultPass()); String url = getDefaultHostAndPort() + API_CLIENT_LIST + "?access_token=" + token; final int clientCount = 3; ResponseEntity<String> entity = exchangeRest(HttpMethod.GET, url); assertEquals(SC_OK, entity.getStatusCode().value()); ClientListDTO dto = this.jsonService.readValue(entity.getBody(), ClientListDTO.class); List<ClientDTO> clients = dto.getClients(); Collections.sort(clients, new Comparator<ClientDTO>() { @Override public int compare(final ClientDTO o1, final ClientDTO o2) { return o1.getClientname().compareTo(o2.getClientname()); } }); assertEquals(clientCount, dto.getClients().size()); assertEquals("testapp", dto.getClients().get(0).getClient()); assertEquals("Test App", dto.getClients().get(0).getClientname()); assertEquals("password", dto.getClients().get(0).getGranttypesasstring()); assertEquals("TestCompany", dto.getClients().get(1).getClient()); assertEquals("Test Company", dto.getClients().get(1).getClientname()); assertEquals("password", dto.getClients().get(1).getGranttypesasstring()); assertEquals(getClientId(), dto.getClients().get(2).getClient()); assertEquals(getClientId(), dto.getClients().get(2).getClientname()); assertEquals("authorization_code,password,refresh_token", dto.getClients().get(2).getGranttypesasstring()); }
From source file:com.formkiq.web.OAuthFederationIntegrationTest.java
License:Apache License
/** * testOauth01().//from w w w .j a v a 2 s.co m * save blank oauth federation * * @throws Exception Exception */ @Test public void testOauth01() throws Exception { // given // when findElementBy(By.id("oauth_add_button")).click(); getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("form-modal"))); click(By.name("_eventId_next")); // then waitUntilPageSourceText("Field required"); }
From source file:com.formkiq.web.OAuthFederationIntegrationTest.java
License:Apache License
/** * testOauth02().//from www.ja va 2 s .co m * add oauth federation * * @throws Exception Exception */ @Test public void testOauth02() throws Exception { // given // when findElementBy(By.id("oauth_add_button")).click(); getWait().until(ExpectedConditions.visibilityOfElementLocated(By.id("form-modal"))); findElementBy("input", "data-valuekey", "domain").sendKeys("222"); findElementBy("input", "data-valuekey", "username").sendKeys("333"); findElementBy("input", "data-valuekey", "host").sendKeys("444"); click(By.name("_eventId_next")); // then getWait().until(ExpectedConditions.invisibilityOfElementLocated(By.id("form-modal"))); assertEquals(1, getTableRowCount("results")); List<WebElement> tablecells = findElements(By.tagName("td")); assertRowEquals(tablecells, Arrays.asList("333", "444", "")); // when findElementBy(By.id("delete_0")).click(); // then assertNoOAuthSetup(); }