List of usage examples for org.openqa.selenium By name
public static By name(String name)
From source file:at.ac.tuwien.big.testsuite.impl.selenium.BaseSeleniumTest.java
License:Apache License
protected static void writeText(WebDriver driver, String id, String text) { final WebElement elem = driver.findElement(By.name(id)); elem.clear();/*from ww w . j a v a 2 s. c om*/ elem.sendKeys(text); }
From source file:at.tugraz.ist.catroweb.admin.UploadTest.java
License:Open Source License
@Test(groups = { "upload" }, description = "upload and delete a project") public void uploadTest() throws Throwable { try {/*from w w w. ja v a 2s.c o m*/ // check for project uploader and send invalid request openAdminLocation(); driver().findElement(By.id("aProjectUploader")).click(); assertTrue(isTextPresent("Project Uploader")); driver().findElement(By.name("uploadButton")).click(); assertTrue(isTextPresent("501")); // upload a project String projectTitle = "testproject" + CommonData.getRandomLongString(200); String response = projectUploader .upload(CommonData.getUploadPayload(projectTitle, "", "", "", "", "", "", "")); String projectId = CommonFunctions.getValueFromJSONobject(response, "projectId"); // delete project openAdminLocation(); driver().findElement(By.id("aAdministrationTools")).click(); ajaxWait(); driver().findElement(By.id("aAdminToolsEditProjects")).click(); assertTrue(isTextPresent(projectTitle)); clickOkOnNextConfirmationBox(); driver().findElement(By.id("delete" + projectId)).click(); assertFalse(isTextPresent(projectTitle)); // verify deletion assertProjectNotPresent(projectTitle); } catch (AssertionError e) { captureScreen("UploadTest.uploadTest"); throw e; } catch (Exception e) { captureScreen("UploadTest.uploadTest"); throw e; } }
From source file:atd.selenium.RegisterUser.java
License:Open Source License
@Test public void testCsv() throws Exception { String csvFile = "test/atd/selenium/RegisterUser.csv"; BufferedReader br = null;/*from ww w . jav a2 s . c o m*/ String line = ""; String cvsSplitBy = ","; try { br = new BufferedReader(new FileReader(csvFile)); while ((line = br.readLine()) != null) { // use comma as separator String[] entry = line.split(cvsSplitBy); driver.get(baseUrl + "/ATD-WEBSITE/register/register.jsp"); driver.findElement(By.name("username")).clear(); driver.findElement(By.name("username")).sendKeys(entry[0]); driver.findElement(By.name("password")).clear(); driver.findElement(By.name("password")).sendKeys(entry[2]); driver.findElement(By.name("realname")).clear(); driver.findElement(By.name("realname")).sendKeys(entry[0] + " " + entry[1]); driver.findElement(By.name("postcode")).clear(); driver.findElement(By.name("postcode")).sendKeys(entry[3]); driver.findElement(By.name("email")).clear(); driver.findElement(By.name("email")).sendKeys(entry[4]); driver.findElement(By.name("kenteken")).clear(); driver.findElement(By.name("kenteken")).sendKeys(entry[5]); driver.findElement(By.name("merk")).clear(); driver.findElement(By.name("merk")).sendKeys(entry[6]); driver.findElement(By.name("type")).clear(); driver.findElement(By.name("type")).sendKeys(entry[7]); driver.findElement(By.xpath("//input[@value='Registreren']")).click(); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (br != null) { try { br.close(); } catch (IOException e) { e.printStackTrace(); } } } }
From source file:au.org.theark.test.integration.container.ITestLoginPage.java
License:Open Source License
@Test public void testValidLogin() { log.info("Starting test " + new Object() { }.getClass().getEnclosingMethod().getName()); driver.findElement(By.name("userName")).sendKeys("arksuperuser@ark.org.au"); driver.findElement(By.name("password")).sendKeys("Password_1"); driver.findElement(By.name("signInButton")).click(); //If the Logout link appears, then we have successfully logged in. try {// w ww.j ava2 s. c o m element = driver.findElement(WicketBy.wicketPath("ajaxLogoutLink")); } catch (Exception e) { e.printStackTrace(); } TestCase.assertNotNull(element); log.info("Ending test " + new Object() { }.getClass().getEnclosingMethod().getName()); }
From source file:au.org.theark.test.integration.container.ITestLoginPage.java
License:Open Source License
@Test public void testInvalidLogin() { log.info("Starting test " + new Object() { }.getClass().getEnclosingMethod().getName()); driver.findElement(By.name("userName")).sendKeys("arksuperuser@ark.org.au"); driver.findElement(By.name("password")).sendKeys("Incorrect Password"); driver.findElement(By.name("signInButton")).click(); //If the "Invalid username and password" warning comes up, then we didn't log in. element = driver.findElement(By.className("feedbackPanelERROR")); TestCase.assertNotNull(element);/*from ww w . jav a 2 s . c o m*/ TestCase.assertEquals("Invalid username and/or password.", element.getText()); log.info("Ending test " + new Object() { }.getClass().getEnclosingMethod().getName()); }
From source file:august.screens.registration.AgreementScreen.java
@Override public boolean isExpectedScreen() { return (this.isDisplayed(By.id("com.august.luna:id/eula_header_textview")) && this.isDisplayed(By.id("com.august.luna:id/eula_body_textview")) && this.isDisplayed(By.id("com.august.luna:id/eula_privacy_policy")) && this.isDisplayed(By.id("com.august.luna:id/eula_terms_of_service")) && this.isDisplayed(By.id("com.august.luna:id/eula_license_agreement")) && this.isDisplayed(By.name("I Agree"))); }
From source file:automation.Zayo.java
@Test public void test() throws Exception { System.out.println(dstIP);//www. ja v a2 s .c om System.out.println(locVar); driver.get(baseUrl + "lg.cgi"); // ERROR: Caught exception [Error: Dom locators are not implemented yet!] driver.findElement(By.name("protocol")).click(); driver.findElement(By.name("addr")).clear(); driver.findElement(By.name("addr")).sendKeys(dstIP); new Select(driver.findElement(By.name("router"))).selectByVisibleText(locVar); driver.findElement(By.name("submit")).click(); // driver.get(baseUrl + "/"); // driver.findElement(By.id(locVar)).click(); // driver.findElement(By.id("command_traceroute")).click(); // driver.findElement(By.id("raw")).click(); // driver.findElement(By.cssSelector("input[type=\"submit\"]")).click(); }
From source file:be.rubus.web.testing.widget.extension.angularprime.PuiRadiobuttonGroup.java
License:Apache License
@PostConstruct private void identifyButtons() { if (buttons == null) { List<WebElement> elements = driver.findElements(By.name(root.getAttribute("name"))); buttons = new ArrayList<PuiRadiobutton>(); for (WebElement element : elements) { PuiRadiobutton radiobutton = new PuiRadiobutton(); grafacesContext.initializePageFragment(radiobutton, element, this); buttons.add(radiobutton);/*from w ww .j a va 2s.c om*/ } } }
From source file:beseenium.model.action.findElementsBy.FindElementsByName.java
License:Open Source License
/** * this performs the find elements by name action * @param n the index of the element to find information on, i.e. if 3 results are found * the 0 will be the first element 1 the second and so on. will get an array out of bounds. * If you wish the action to return all of the results found then set n = -1. * @return String representation of the returnParam set in the ActionData object * passed into the constructor.//www . j a va 2 s.c o m * @throws ActionDataException */ @Override public String execute(int n) throws ActionDataException { String searchParam = super.context.getInputParam(); WebDriver browser = super.context.getDriver(); List<WebElement> htmlElements = browser.findElements(By.name(searchParam)); super.context.setElement(htmlElements); return FormatOutput.formatFindElementOutput(htmlElements, n); }
From source file:botski.example.AddMeFastExample.java
License:Apache License
public void facebookLogin() throws Exception { driver.get("http://www.facebook.com/"); WebElement formEmail = driver.findElement(By.name("email")); formEmail.sendKeys(facebookEmail);//from w ww .ja v a 2s . c om WebElement formPassword = driver.findElement(By.name("pass")); formPassword.sendKeys(facebookPassword); WebElement formRemember = driver.findElement(By.name("persistent")); formRemember.sendKeys(" "); formPassword.submit(); if (driver.getCurrentUrl().contains("login.php")) { throw new Exception("Failed to login Facebook as '" + facebookEmail + "' using password '" + facebookPassword + "', I ended up here '" + driver.getCurrentUrl() + "'"); } }