List of usage examples for org.openqa.selenium WebElement submit
void submit();
From source file:com.mycompany.newseleniumtest.TestScript2.java
public boolean workbenchLogin(String user) { boolean output = true; try {// ww w . j a v a 2 s. c om this.startDriver("firefox"); this.driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); WebDriverWait wait = new WebDriverWait(driver, 10); //Open the page this.driver.get("http://" + this.testLocation + ".uangteman.com/admin"); // this.driver.get("localhost:80/uang-teman/admin"); WebElement main; switch (user) { case ("finance"): this.driver.findElement(By.name("bu_name")).sendKeys("ddebora_fi"); break; case ("admin"): this.driver.findElement(By.name("bu_name")).sendKeys("pras_admin"); break; case ("staff"): this.driver.findElement(By.name("bu_name")).sendKeys("pras_staff"); break; case ("fraudcheck"): this.driver.findElement(By.name("bu_name")).sendKeys("pras_fc"); break; case ("customerservice"): this.driver.findElement(By.name("bu_name")).sendKeys("pras_supercs"); break; case ("pras_supermanager"): this.driver.findElement(By.name("bu_name")).sendKeys("pras_supermanager"); break; case ("supermanager_redho"): this.driver.findElement(By.name("bu_name")).sendKeys("redho"); break; case ("fauzan"): this.driver.findElement(By.name("bu_name")).sendKeys("fauzan"); break; case ("pras_manager"): this.driver.findElement(By.name("bu_name")).sendKeys("pras_manager"); break; case ("ddebora_mgr"): this.driver.findElement(By.name("bu_name")).sendKeys("ddebora_mgr"); break; case ("fahmy_manager"): this.driver.findElement(By.name("bu_name")).sendKeys("fahmy_manager"); break; case ("eka"): this.driver.findElement(By.name("bu_name")).sendKeys("eka"); break; case ("collection"): this.driver.findElement(By.name("bu_name")).sendKeys("kevincol"); break; default: throw new Exception("No user"); } this.driver.findElement(By.name("bu_passwd")).sendKeys("testing"); main = this.driver.findElement( By.cssSelector("button[class='btn btn-orange btn-squared pull-right ladda-button']")); main.submit(); //SMS verifications if (!this.testLocation.equals("dev")) { Thread.sleep(5000); String sms_code = (String) SupportController.getfromDatabase( "SELECT bua_auth_code FROM bo_auth_log ORDER BY bua_id DESC LIMIT 1;", this.testLocation); this.driver.findElement(By.name("authcode")).sendKeys(sms_code); this.driver .findElement(By .cssSelector("button[class='btn btn-bricky btn-squared pull-right ladda-button']")) .click(); } } catch (Exception e) { System.out.println("TestScript Login-Error: " + e.getMessage()); output = false; } finally { return output; } }
From source file:com.mycompany.selenium.SeleniumExample.java
public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "/Applications/chromedriver"); // Create a new instance of the Firefox driver // Notice that the remainder of the code relies on the interface, // not the implementation. WebDriver driver = new ChromeDriver(); // System.setProperty("webdriver.chrome.driver", "/Users/CosticaTeodor/Downloads/drivers/chromedriver"); // And now use this to visit Google driver.get("http://www.google.com"); // Alternatively the same thing can be done like this // driver.navigate().to("http://www.google.com"); // Find the text input element by its name WebElement element = driver.findElement(By.name("q")); // Enter something to search for element.sendKeys("Cheese!"); // Now submit the form. WebDriver will find the form for us from the element element.submit(); // Check the title of the 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("cheese!"); }//from w ww.j av a2 s .c om }); // Should see: "cheese! - Google Search" System.out.println("Page title is: " + driver.getTitle()); //Close the browser driver.quit(); }
From source file:com.mycompany.seliniumtest.Selenium2Example.java
public static void main(String[] args) { System.setProperty("webdriver.gecko.driver", "/usr/local/Cellar/geckodriver/geckodriver"); // Create a new instance of the Firefox driver // Notice that the remainder of the code relies on the interface, // not the implementation. //WebDriver driver = new FirefoxDriver(); //WebDriver driver = new ChromeDriver(); WebDriver driver = new FirefoxDriver(); //WebDriver driver = new HtmlUnitDriver(); // And now use this to visit Google driver.get("http://www.google.com"); // Alternatively the same thing can be done like this // driver.navigate().to("http://www.google.com"); // Find the text input element by its name WebElement element = driver.findElement(By.name("q")); // Enter something to search for element.sendKeys("Cheese!"); // Now submit the form. WebDriver will find the form for us from the element element.submit(); // Check the title of the 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("cheese!"); }/*from w ww . j a va2s . c o m*/ }); // Should see: "cheese! - Google Search" System.out.println("Page title is: " + driver.getTitle()); //Close the browser driver.quit(); }
From source file:com.nabla.project.fronter.selenium.tests.GoogleSearchSTest.java
License:Open Source License
@Test public void testGoogleSearch() { // try/*from ww w . j a va 2s . c om*/ // { // Find the text input element by its name final WebElement element = this.driver.findElement(By.name("q")); // Enter something to search for element.sendKeys("Selenium testing tools cookbook"); // Now submit the form. WebDriver will find the form for us from the element element.submit(); // Google's search is rendered dynamically with JavaScript. // Wait for the page to load, timeout after 10 seconds (new WebDriverWait(this.driver, 10)).until(new ExpectedCondition<Boolean>() { @Override public Boolean apply(final WebDriver d) { return d.getTitle().toLowerCase().startsWith("selenium testing tools cookbook"); } }); // Should see: selenium testing tools cookbook - Google Search // Assert.assertEquals("Selenium testing tools cookbook - Google Search", this.driver.getTitle()); Assert.assertEquals("Selenium testing tools cookbook - Recherche Google", this.driver.getTitle()); /* * } catch (final Error e) * { * // Capture and append Exceptions/Errors * this.verificationErrors.append(e.toString()); * } */ }
From source file:com.nike.tests.MobileWebTest.java
License:Apache License
@Test public void shouldSearchWithEbay() { // And now use this to visit ebay driver.get("http://m.ebay.de"); System.out.println("starting flick"); //WebElement pages = driver.findElement(By.id("vp_pages")); TouchActions flick = new TouchActions(driver).flick(100, 860); flick.perform();/*from w ww. ja v a2 s.c om*/ TouchActions swipe = new TouchActions(driver).scroll(-200, 860); swipe.perform(); TouchAction ta = (new TouchActionBuilder()).pointerDown(200, 860).pointerMove(100, 10).pointerUp().build(); ta.perform(driver); System.out.println("done"); // Find the text input element by its id WebElement element = driver.findElement(By.id("kw")); // Enter something to search for element.sendKeys("Nexus 5"); // Now submit the form. WebDriver will find the form for us from the element element.submit(); // Check the title of the page System.out.println("Page title is: " + driver.getTitle()); driver.quit(); }
From source file:com.nosoftskills.travianbot.page.Login.java
License:Apache License
public void login(String userName, String password) { WebElement userNameElement = webDriver.findElement(By.name("name")); userNameElement.sendKeys(userName);//from ww w. j a v a2 s .co m WebElement passwordElement = webDriver.findElement(By.name("password")); passwordElement.sendKeys(password); passwordElement.submit(); }
From source file:com.openones.auto.selen.Sample01.java
License:Apache License
public static void main(String[] args) { // Create a new instance of the Firefox driver // Notice that the remainder of the code relies on the interface, // not the implementation. WebDriver driver = new FirefoxDriver(); //WebDriver driver = new InternetExplorerDriver(); // And now use this to visit Google driver.get("http://www.google.com"); // Alternatively the same thing can be done like this // driver.navigate().to("http://www.google.com"); // Find the text input element by its name WebElement element = driver.findElement(By.name("q")); // Enter something to search for element.sendKeys("Cheese!"); // Now submit the form. WebDriver will find the form for us from the element element.submit(); // Check the title of the 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("cheese!"); }//from w w w .j av a 2s. c o m }); // Should see: "cheese! - Google Search" System.out.println("Page title is: " + driver.getTitle()); //Close the browser driver.quit(); }
From source file:com.pentaho.ctools.utils.ElementHelper.java
License:Apache License
/** * This method find the element and sendkeys. * /*from w ww .jav a 2 s . c om*/ * @param driver * @param locator * @param text */ public void SendKeysAndSubmit(final WebDriver driver, final By locator, final CharSequence... keysToSend) { this.log.debug("SendKeysAndSubmit::Enter"); try { WebElement element = WaitForElementPresenceAndVisible(driver, locator); if (element != null) { element.clear(); element.sendKeys(keysToSend); element.submit(); } else { this.log.error("Element is null!"); } } catch (StaleElementReferenceException e) { this.log.warn("Stale Element Reference Exception"); SendKeysAndSubmit(driver, locator, keysToSend); } this.log.debug("SendKeysAndSubmit::Exit"); }
From source file:com.pivotal.gemfire.tools.pulse.tests.PulseTests.java
License:Open Source License
@BeforeClass public static void setUpBeforeClass() throws Exception { try {/*w w w.ja v a 2s .c o m*/ server = Server.createServer(9999, jmxPropertiesFile); String host = "localhost";// InetAddress.getLocalHost().getHostAddress(); int port = 8080; String context = "/pulse"; tomcat = TomcatHelper.startTomcat(host, port, context, path); pulseURL = "http://" + host + ":" + port + context; Thread.sleep(5000); // wait till tomcat settles down } catch (FileNotFoundException e) { e.printStackTrace(); Assert.fail("Error " + e.getMessage()); } catch (IOException e) { e.printStackTrace(); Assert.fail("Error " + e.getMessage()); } catch (Exception e) { e.printStackTrace(); Assert.fail("Error " + e.getMessage()); } driver = new FirefoxDriver(); driver.manage().window().maximize(); driver.get(pulseURL); WebElement userNameElement = driver.findElement(By.id("user_name")); WebElement passwordElement = driver.findElement(By.id("user_password")); userNameElement.sendKeys(userName); passwordElement.sendKeys(pasword); passwordElement.submit(); Thread.sleep(10000); WebElement userNameOnPulsePage = (new WebDriverWait(driver, 10)).until(new ExpectedCondition<WebElement>() { @Override public WebElement apply(WebDriver d) { return d.findElement(By.id("userName")); } }); Assert.assertNotNull(userNameOnPulsePage); Thread.sleep(7000); }
From source file:com.safeway.app.appcert.smoketester.SmokeTester.java
@Test public void executeSmokeTest() throws Exception { // Create a new instance of the Firefox driver // Notice that the remainder of the code relies on the interface, // not the implementation. System.setProperty("webdriver.chrome.driver", "C:\\Nino\\ChromeWebDriver\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); TestCaseReader tcreader = new TestCaseReader(); List<TestScriptTemplate> tcl = tcreader.readExcel(); List<TestScriptTemplate> validatedTestScript = new ArrayList(); String log_execution = ""; Iterator<TestScriptTemplate> i = tcl.iterator(); while (i.hasNext()) { TestScriptTemplate testscript = i.next(); //collect the results TestScriptTemplate testexecution = new TestScriptTemplate(); testexecution.setAppCode(testscript.getAppCode()); log_execution = log_execution + " Start smoke testing for application code: " + testexecution.getAppCode(); //access the URL driver.get(testscript.getAppURL()); //login if not yet if (driver.getCurrentUrl().contains("identity.safeway.com")) { //key in userid and password WebElement weusername = driver.findElement(By.id("username")); //System.out.println("tag:" + weusername.getTagName()); weusername.sendKeys(testscript.getAppUserID()); WebElement wepassword = driver.findElement(By.id("password")); //System.out.println("tag:" + wepassword.getTagName()); wepassword.sendKeys(testscript.getAppPassword()); WebElement weloginform = driver.findElement(By.name("loginData")); //System.out.println("tag:" + weloginform.getTagName()); weloginform.submit(); }//from ww w .j a v a 2s . c o m //recoding URL; required so no need to check for nullity testexecution.setAppURL(driver.getCurrentUrl()); log_execution = log_execution + " Current URL: " + driver.getCurrentUrl(); //recoding title; required so no need to check for nullity testexecution.setHomePageTitle(driver.getTitle()); log_execution = log_execution + " Login Successful"; log_execution = log_execution + " Page Title: " + driver.getTitle(); if (isElementExist(testscript.getHomePageElementType(), testscript.getHomePageElement(), driver)) { System.out.println("Element match!" + testscript.getHomePageElement()); log_execution = log_execution + " Home Page Element validation..."; testexecution.setHomePageElement(testscript.getHomePageElement()); } else { testexecution.setHomePageElement("not found"); } //next page validation if (!testscript.getLevel1URL().isEmpty() || !testscript.getLevel1URL().equals("")) { //go to next level page driver.get(testscript.getLevel1URL()); log_execution = log_execution + " Next Page validation URL: " + testscript.getLevel1URL(); testexecution.setLevel1URL(driver.getCurrentUrl()); System.out.println("execution log: current level 1 URL on set" + testexecution.getLevel1URL()); if (!testscript.getLevel1PageTitle().isEmpty() || !testscript.getLevel1PageTitle().equals("")) { testexecution.setLevel1PageTitle(driver.getTitle()); log_execution = log_execution + " Next Page title validation: " + driver.getTitle(); } if (isElementExist(testscript.getLevel1ElementType(), testscript.getLevel1Element(), driver)) { testexecution.setLevel1Element(testscript.getLevel1Element()); log_execution = log_execution + " Next Page element validation: " + testscript.getLevel1Element(); } else { testexecution.setLevel1Element("not found"); } } testexecution.setLogs(log_execution); System.out.println("Execution Log: " + log_execution); log_execution = ""; SmokeTestValidator testvalidator = new SmokeTestValidator(testscript); TestScriptTemplate testingresult = testvalidator.getTestResult(testexecution); validatedTestScript.add(testingresult); } tcreader.writetoExcel(validatedTestScript); //Close the browser driver.quit(); //return log_execution; }