List of usage examples for org.openqa.selenium WebElement sendKeys
void sendKeys(CharSequence... keysToSend);
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Sets the value.//from w w w . ja va 2s .c o m * @param driver the driver * @param cssSelector the css selector * @param value the value */ public static void setValueByCSS(WebDriver driver, String cssSelector, String value) { if (isDisplayedByCSS(driver, cssSelector, 10)) { List<WebElement> inputs = driver.findElements(By.cssSelector(cssSelector)); for (WebElement input : inputs) { if (input.isDisplayed() && input.isEnabled()) { input.clear(); input.sendKeys(value); } } } }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Sets the value.//from w ww .j ava2 s . c o m * @param driver the driver * @param cssSelector the css selector * @param value the value * @param index the index */ public static void setValueByCSS(WebDriver driver, String cssSelector, String value, int index) { if (isDisplayedByCSS(driver, cssSelector, 10)) { List<WebElement> inputs = driver.findElements(By.cssSelector(cssSelector)); int count = 0; for (WebElement input : inputs) { if (input.isDisplayed() && input.isEnabled()) { if (count == index) { input.clear(); input.sendKeys(value); logger.info("Count " + count + ", " + input.getAttribute("id")); break; } ++count; } } } }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Sets the value.//from w ww.j a v a2 s.c o m * @param driver the driver * @param id the id * @param value the value */ public static void setValue(WebDriver driver, String id, String value) { if (isDisplayedById(driver, id, 10)) { WebElement input = driver.findElement(By.id(id)); input.clear(); input.sendKeys(value); } }
From source file:com.ecofactor.qa.automation.util.PageUtil.java
License:Open Source License
/** * Clear and input./*from ww w . ja v a2s . c o m*/ * @param driver the driver * @param locator the locator * @param fieldValue the field value */ public static void clearAndInput(final WebDriver driver, final By locator, final String fieldValue) { final WebElement element = driver.findElement(locator); element.clear(); element.sendKeys(fieldValue); }
From source file:com.econcept.selenium.method.Login.java
License:Open Source License
public void activate() throws Exception { // If not even valid, return if (!isValid()) { return;//from w w w . j ava2s. c om } // if try { WebElement lInput = mDriver.findElement(By.id("Email")); lInput.sendKeys(mLoginUsername); lInput = mDriver.findElement(By.id("Passwd")); lInput.sendKeys(mLoginPassword); // Set debug point debugPoint("Check login menu"); lInput = mDriver.findElement(By.id("signIn")); lInput.click(); } // try catch (Exception pException) { pException.printStackTrace(); throw new Exception(pException); } // catch }
From source file:com.etouch.cisco.common.CiscoMainPage_iPad.java
public void SignIn(TestParameters input) throws InterruptedException { final int MAX_WAIT = 20; try {/* ww w . j a va 2s . c o m*/ try { Thread.sleep(8000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } WebElement element = driver.findElement(By.xpath(MainPageElements_ipad.UName_XPATH_ipad)); element.click(); element.sendKeys(input.getParamMap().get("uname")); if (TestBedManager.INSTANCE.getCurrentTestBed().getTestBedName().equalsIgnoreCase("iPhoneNativeSim")) { WebElement pwdelement = driver.findElement(By.xpath(MainPageElements_iphone.PWD_XPATH_ipad)); pwdelement.click(); pwdelement.sendKeys("April2014$"); } else { WebElement pwdelement = driver.findElement(By.xpath(MainPageElements_ipad.PWD_XPATH_ipad)); pwdelement.click(); pwdelement.sendKeys(input.getParamMap().get("pwd")); } //pwdelement.sendKeys("Go"); WebElement butElement = driver.findElement(By.xpath(MainPageElements_iphone.Login_BTN_XPATH_ipad)); butElement.click(); //System.out.println(butElement.getText()); //WebElement butElement=driver.findElement(By.id("Log In")); // WebElement element=driver.findElement(By.xpath(MainPageElements_ipad.UName_XPATH_ipad)); // element.click(); // element.sendKeys(input.getParamMap().get("uname")); // // element = driver.findElement(By.xpath(MainPageElements_ipad.PWD_XPATH_ipad)); // element.click(); // element.sendKeys(input.getParamMap().get("pwd")); // // WebElement butElement=driver.findElement(By.xpath(MainPageElements_ipad.Login_BTN_XPATH_ipad)); // butElement.click(); // Thread.sleep(100); } catch (Exception e) { e.printStackTrace(); System.out.println("Error: " + e.getLocalizedMessage()); } }
From source file:com.etouch.cisco.common.CiscoMainPage_iPhoneBackup.java
public void SignIn(TestParameters input) throws InterruptedException { final int MAX_WAIT = 20; try {// ww w . ja va2 s . c o m Thread.sleep(1000); WebElement element = driver.findElement(By.xpath(MainPageElements_iphone.UName_XPATH_ipad)); element.click(); element.sendKeys(input.getParamMap().get("uname")); if (TestBedManager.INSTANCE.getCurrentTestBed().getTestBedName().equalsIgnoreCase("iPhoneNativeSim")) { WebElement pwdelement = driver.findElement(By.xpath(MainPageElements_iphone.PWD_XPATH_ipad)); pwdelement.click(); pwdelement.sendKeys(" November2013$"); } else { WebElement pwdelement = driver.findElement(By.xpath(MainPageElements_iphone.PWD_XPATH_ipad)); pwdelement.click(); pwdelement.sendKeys(input.getParamMap().get("pwd")); } WebElement butElement = driver.findElement(By.xpath(MainPageElements_iphone.Login_BTN_XPATH_ipad)); System.out.println(butElement.getTagName()); butElement.click(); Thread.sleep(10000); } catch (Exception e) { e.printStackTrace(); System.out.println("Error: " + e.getLocalizedMessage()); } }
From source file:com.etouch.taf.webui.selenium.test.AndroidHybridAppTest.java
@Test public void testWebViewWithAndroidDriver() throws InterruptedException, MalformedURLException { driverObj.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); Thread.sleep(4000);// ww w . j a v a2 s . co m //Click on Activity tracker license link driverObj.findElement(By.name(prop.getProperty("ihs_activity_tracker_Activity_Tracker_License_Link"))) .click(); //Entered in to WebView Thread.sleep(2000); //wd.context("WEBVIEW_1"); //Thread.sleep(2000); //Click on Search Text box WebElement search = driverObj .findElement(By.xpath(prop.getProperty("ihs_activity_tracker_Activity_Tracker_Search_Link"))); search.click(); //Enter Search Text WebElement searchText = driverObj .findElement(By.xpath(prop.getProperty("ihs_activity_tracker_Activity_Tracker_Search_Textbox"))); searchText.sendKeys("wells"); //Click on Search Button WebElement searchButton = driverObj .findElement(By.xpath(prop.getProperty("ihs_activity_tracker_Activity_Tracker_Search_Button"))); searchButton.click(); Thread.sleep(4000); //navigate back to App view driverObj.navigate().back(); Thread.sleep(2000); driverObj.navigate().back(); Thread.sleep(2000); //Entered in to Native view driverObj.context("NATIVE_APP"); Thread.sleep(2000); //Click on login button //WebElement login=driverObj.findElement(By.xpath("//android.widget.LinearLayout[1]/android.widget.FrameLayout[1]/android.widget.ScrollView[1]/android.widget.LinearLayout[1]/android.widget.LinearLayout[2]/android.widget.FrameLayout[1]/android.widget.Button[1]")); WebElement login = driverObj.findElement(By.id(prop.getProperty("ihs_activity_tracker_login_button"))); login.click(); Thread.sleep(3000); }
From source file:com.example.getstarted.basicactions.UserJourneyTestIT.java
License:Apache License
private void login(String email) { WebElement input = driver.findElement(By.cssSelector("input[type=text]")); input.clear();//w w w. j av a 2 s. c o m input.sendKeys(email); input.submit(); }
From source file:com.example.selenium.find.elements.FindElementXPath.java
@Test public void findByRelativePath() { WebElement element = driver.findElement(By.xpath("//input")); element.sendKeys("Jayasimha"); }