List of usage examples for org.openqa.selenium WebElement submit
void submit();
From source file:runkoserver.integration.AreaTest.java
@Test public void areaCannotBeWoundByOtherUsersContentManager() { elementService.deleteAllElements();//from w w w. j a va2 s. c o m areaService.deleteAllAreas(); String name = "Ei kannata yritt"; String visibility = "testing2"; createNewArea(name, visibility); driver.get(LINK_LOCALHOST + LINK_LOGIN); WebElement username = driver.findElement(By.name(ATTRIBUTE_USERNAME)); WebElement password = driver.findElement(By.name(ATTRIBUTE_PASSWORD)); username.sendKeys(LOGIN_TEST2); password.sendKeys(PASSWORD_TEST2); password.submit(); driver.get(LINK_LOCALHOST + LINK_PERSONS + LINK_CONTENT_MANAGER); assertFalse(driver.getPageSource().contains(name)); }
From source file:se.vgregion.urlservice.inttest.AdminFeature.java
License:Open Source License
@When("^I search for \"([^\"]*)\"$") public void search(String query) { WebElement searchField = d.findElement(By.name("q")); searchField.sendKeys(query);//from w w w. j a va 2s. c o m // WebDriver will find the containing form for us from the searchField element searchField.submit(); }
From source file:SearchTest.SearchTest.java
@Test public void searchWithSpecificName() { WebElement searchBar = driver.findElement(By.xpath("//*[@id=\"main-nav\"]/form/fieldset/input[1]")); searchBar.sendKeys("Sennheiser RS 120"); searchBar.submit(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);// wait for web response List<WebElement> results = driver.findElements(By.className("product_grid_item")); assertEquals(results.size(), 1);// the search result only has one item assertEquals(results.get(0).findElement(By.className("prodtitle")).getText(), "Sennheiser RS 120");//The name of item which be find out should be identical with the searching word }
From source file:SearchTest.SearchTest.java
@Test public void searchWithAmbiguousName() { WebElement searchBar = driver.findElement(By.xpath("//*[@id=\"main-nav\"]/form/fieldset/input[1]")); searchBar.sendKeys("Apple"); searchBar.submit(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);// wait for web response List<WebElement> results = driver.findElements(By.className("product_grid_item")); assertEquals(results.size(), 9);// The search reasult should be 9 results.stream().map((e) -> e.findElement(By.className("prodtitle")).getText()) .map((name) -> name.substring(0, 5)).map((Key) -> { return Key; }).forEach((Key) -> { assertEquals(Key, "Apple");// The name of items which be find out should has searching key word. });//from www . j a va 2 s . c o m }
From source file:seleniumdemo.HelperSelenium.java
public void InvokeSelenium(String pstrSearchkeyword) { try {/*from ww w . j a va 2 s . c o m*/ WebDriver driver = new HtmlUnitDriver(); driver.get("http://www.google.com"); WebElement lobjelement = driver.findElement(By.name("q")); lobjelement.sendKeys(pstrSearchkeyword); lobjelement.submit(); WriteTheContentToTextFile(); } catch (Exception lobjException) { Logger.getLogger(HelperSelenium.class.getName()).log(Level.SEVERE, null, lobjException); } }
From source file:seleniumfinal.SeleniumFinal.java
/** * @param args the command line arguments *//* w w w.j av a 2 s . c o m*/ public static void main(String[] args) throws InterruptedException { WebDriver driver = new FirefoxDriver(); driver.get("http://www.facebook.com.br/"); WebElement campoDeTexto = driver.findElement(By.id("email")); campoDeTexto.sendKeys("joaoarmandopinto01@gmail.com"); WebElement campoDeTexto2 = driver.findElement(By.id("pass")); campoDeTexto2.sendKeys("armandopinto"); driver.findElement(By.id("u_0_l")).click(); Thread.sleep(10000); //Publica no face aps 10000 milesegundos WebElement campoTexto4 = driver.findElement(By.id("u_0_w")); campoTexto4.sendKeys("Teste de publicao facebook;"); campoTexto4.submit(); }
From source file:seleniumfinal.SeleniumHotmail.java
/** * @param args the command line arguments *///from w w w. j a va2 s . co m public static void main(String[] args) throws InterruptedException { WebDriver driver = new FirefoxDriver(); driver.get("http://www.hotmail.com"); WebElement campoDeTexto = driver.findElement(By.id("i0116")); campoDeTexto.sendKeys("topicosavancados@hotmail.com"); WebElement campoDeTexto2 = driver.findElement(By.name("passwd")); campoDeTexto2.sendKeys("luizcascais123"); campoDeTexto2.submit(); Thread.sleep(4000); driver.findElement(By.xpath("//a[@id='NewMessage']")).click(); Thread.sleep(15000); driver.findElement(By.id("watermarkedInputControl90f")).sendKeys("Assunto!"); Thread.sleep(10000); driver.findElement(By.cssSelector("textarea[class='cp_primaryInput cp_anyInput t_urtc']")) .sendKeys("topicosavancados@hotmail.com"); Thread.sleep(10000); driver.findElement(By.id("SendMessage")).click(); }
From source file:seleniumfinal.SeleniumTwitter.java
/** * @param args the command line arguments *///from w w w . j ava 2 s. c o m public static void main(String[] args) throws InterruptedException { WebDriver driver = new FirefoxDriver(); driver.get("http://www.twitter.com/"); //Thread.sleep(10000); WebElement campoDeTexto = driver.findElement(By.id("signin-email")); campoDeTexto.sendKeys("stelio@kedsystem.com.br"); WebElement campoDeTexto2 = driver.findElement(By.id("signin-password")); campoDeTexto2.sendKeys("karo1egab1"); campoDeTexto2.submit(); Thread.sleep(5000); WebElement campoDeTexto3 = driver.findElement(By.id("tweet-box-mini-home-profile")); campoDeTexto3.sendKeys("Ol Galera! Este um teste do Selenium!"); Thread.sleep(10000); driver.findElement(By.cssSelector("div[class='tweet-button']")).click(); //driver.findElement(By.cssSelector("div[class='btn primary-btn tweet-action tweet-btn js-tweet-btn']")).click(); //class="btn primary-btn tweet-action tweet-btn js-tweet-btn" }
From source file:seleniumsample.SeleniumSample.java
public static void InvokeSelenium(String pstrSearchkeyword) { try {//from w w w.j a va2 s.co m WebDriver driver = new HtmlUnitDriver(); driver.get("http://www.google.com"); WebElement lobjelement = driver.findElement(By.name("q")); lobjelement.sendKeys(pstrSearchkeyword); lobjelement.submit(); char[] lobjBuffer = driver.getPageSource().toCharArray(); //lobjfilewriter.write(lobjBuffer); //String lstrpath=file.getAbsolutePath(); //System.out.println(mstrSearchkeyword+" File successfully created at!! "+lstrpath); WriteTheContentToTextFile(lobjBuffer, pstrSearchkeyword); driver.quit(); } catch (Exception lobjException) { Logger.getLogger(SeleniumSample.class.getName()).log(Level.SEVERE, null, lobjException); } }
From source file:selenium_webdriver_test_01.Selenium_Webdriver_Test_01.java
public static void main(String[] args) { // Creates a new instance of the Firefox driver WebDriver driver = new FirefoxDriver(); // WebDriver.get - Opens a URL in Firefox driver.get("http://www.google.com"); // Alternatively the same thing can be done like this: // driver.navigate().to("http://www.google.com"); // WebDriver.findElement(By.name("name")) - Accesses the text input element by its name. WebElement element = driver.findElement(By.name("q")); // .sendKeys("text") - Sends text to text input element. element.sendKeys("Thurse"); // .submit() - Submits the form. Form is found automatically from element. element.submit(); // System.out.println("text" + some.object()) - Prints something on the NetBeans output window // WebDriver.getTitle() - Gets the title of a web page. System.out.println("Page title is: " + driver.getTitle()); // Google's search is rendered dynamically with JavaScript. // Wait for the page to load, timeout after 10 seconds (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return d.getTitle().toLowerCase().startsWith("thurse"); }//from www . j a va2 s . c o m }); // Should see: "cheese! - Google Search" System.out.println("Page title is: " + driver.getTitle()); //Close the browser driver.quit(); }