List of usage examples for org.openqa.selenium WebElement sendKeys
void sendKeys(CharSequence... keysToSend);
From source file:com.ibm.watson.movieapp.dialog.fvt.webui.MovieUI.java
License:Open Source License
/** * askQuestion//www . ja v a 2s. c o m * @param question */ public void ask(BaseQuestion question) { BaseResponse resp = new BaseResponse.Builder().build(); //wait for chatbox to be enabled fluentWaitNotPresent(chatBoxDisabled); //collect conversation List<WebElement> preQuestCount = findElements(conversationsWeb); logger.info("INFO: Number of total questions asked in this conversations " + preQuestCount.size()); //ensure the chatbox exists fluentWaitVisible(chatBox); WebElement chatbox = findElement(chatBox); chatbox.click(); logger.info("INFO: Sending \"" + question.getText() + "\" to " + chatBox); chatbox.sendKeys(question.getText()); chatbox.submit(); //wait for thinking animation has completed fluentWaitNotPresent(watsonThinkAnimation); //collect questions and wait for new question to be added List<WebElement> postQuestCount = findElements(conversationsWeb); while (preQuestCount.size() >= postQuestCount.size()) { postQuestCount = findElements(conversationsWeb); } //General check to ensure that we are not waiting on any animations fluentWaitNotPresent(animationActive); logger.info("INFO: Number of total questions asked in this conversations " + postQuestCount.size()); //collect last question answer WebElement thisQuestion = postQuestCount.get(postQuestCount.size() - 1); List<WebElement> questPart = thisQuestion.findElements(By.cssSelector(questionParts)); //set response to the answer resp.setResponseText(questPart.get(1).getText()); //add response to question logger.info("INFO: Adding Response text to Question object"); question.setResponse(resp); //add any movies that are part of the response to question List<WebElement> movies = findElements(movieResponse); if (movies.size() > 0) { question.setMovies(movies); } }
From source file:com.ipinyou.webpage.abnormalwebpage.AbnormalAdvertiserPage.java
public static void create(WebDriver driver, AbnormalAdvertiserInfo adinfo, int a) throws NoSuchElementException { driver.findElement(By.className("resource-create-btn")).click(); driver.findElement(By.id("advertiser.name")).sendKeys(adinfo.adname); driver.findElement(By.id("advertiser.registerName")).sendKeys(adinfo.registername); if (a == 1) { driver.findElement(By.id("advertiser.serviceFeeRate")).sendKeys(adinfo.servicefeerate); }// w ww . j av a 2s.co m // driver.findElement(By.id("advertiser.selfService1")).click(); // driver.findElement(By.id("advertiser.selfService0")).click(); Select industry = new Select(driver.findElement(By.name("advertiser.verticalTagId"))); industry.selectByVisibleText(adinfo.industrytext); WebElement websuite = driver.findElement(By.id("advertiser.website")); websuite.clear(); websuite.sendKeys(adinfo.advertiserwebsite); driver.findElement(By.id("advertiser.cellphone")).sendKeys(adinfo.cellphone); driver.findElement(By.id("advertiser.contactName")).sendKeys(adinfo.contactname); driver.findElement(By.id("advertiser.email")).sendKeys(adinfo.email); driver.findElement(By.id("advertiser.showLogo1")).click(); driver.findElement(By.id("advertiser.showLogo0")).click(); WebElement addaptitude = driver.findElement(By.id("addQualificationFiles")); addaptitude.click(); if (a == 2) { addaptitude.click(); } else { ; } //ICP Select aptitudeicp = new Select(driver.findElement(By.name("types"))); aptitudeicp.selectByValue("ICP"); driver.findElement(By.name("qualifications")).sendKeys(adinfo.path); addaptitude.click(); // Select aptitudelicense = new Select(driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[12]/td[2]/select"))); aptitudelicense.selectByValue("License"); WebElement chooselicense = driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[12]/td[2]/input")); chooselicense.sendKeys(adinfo.path); addaptitude.click(); // Select aptitudelegalid = new Select(driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[13]/td[2]/select"))); aptitudelegalid.selectByValue("LegalId"); WebElement chooselegalid = driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[13]/td[2]/input")); chooselegalid.sendKeys(adinfo.path); addaptitude.click(); // Select aptitudeproduct = new Select(driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[14]/td[2]/select"))); aptitudeproduct.selectByValue("Product"); WebElement chooseproduct = driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[14]/td[2]/input")); chooseproduct.sendKeys(adinfo.path); addaptitude.click(); // Select aptitudeother = new Select(driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[15]/td[2]/select"))); aptitudeother.selectByValue("Other"); WebElement chooseother = driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[15]/td[2]/input")); chooseother.sendKeys(adinfo.path); WebElement submit = driver.findElement(By.name("submitForm")); submit.click(); }
From source file:com.ipinyou.webpage.abnormalwebpage.AbnormalAdvertiserPageName.java
public static void create(WebDriver driver, AbnormalAdvertiserNameInfo aainfo, int a) throws NoSuchElementException { driver.findElement(By.className("resource-create-btn")).click(); driver.findElement(By.id("advertiser.name")).sendKeys(aainfo.getAdname()); driver.findElement(By.id("advertiser.registerName")).sendKeys(aainfo.getRegistername()); if (a == 1) { driver.findElement(By.id("advertiser.serviceFeeRate")).sendKeys(aainfo.getServicefeerate()); }/* w w w . ja v a 2s . c o m*/ // driver.findElement(By.id("advertiser.selfService1")).click(); // driver.findElement(By.id("advertiser.selfService0")).click(); Select industry = new Select(driver.findElement(By.name("advertiser.verticalTagId"))); industry.selectByVisibleText(aainfo.getIndustrytext()); WebElement websuite = driver.findElement(By.id("advertiser.website")); websuite.clear(); websuite.sendKeys(aainfo.getAdvertiserwebsite()); driver.findElement(By.id("advertiser.cellphone")).sendKeys(aainfo.getCellphone()); driver.findElement(By.id("advertiser.contactName")).sendKeys(aainfo.getContactname()); driver.findElement(By.id("advertiser.email")).sendKeys(aainfo.getEmail()); driver.findElement(By.id("advertiser.showLogo1")).click(); driver.findElement(By.id("advertiser.showLogo0")).click(); WebElement addaptitude = driver.findElement(By.id("addQualificationFiles")); addaptitude.click(); if (a == 2) { addaptitude.click(); } else { ; } //ICP Select aptitudeicp = new Select(driver.findElement(By.name("types"))); aptitudeicp.selectByValue("ICP"); driver.findElement(By.name("qualifications")).sendKeys(aainfo.getPath()); addaptitude.click(); /*// Select aptitudelicense = new Select(driver.findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[12]/td[2]/select"))); aptitudelicense.selectByValue("License"); WebElement chooselicense = driver.findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[12]/td[2]/input")); // chooselicense.sendKeys(aainfo.getPath()); addaptitude.click(); // Select aptitudelegalid = new Select(driver.findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[13]/td[2]/select"))); aptitudelegalid.selectByValue("LegalId"); WebElement chooselegalid = driver.findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[13]/td[2]/input")); chooselegalid.sendKeys(aainfo.getPath()); addaptitude.click(); // Select aptitudeproduct = new Select(driver.findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[14]/td[2]/select"))); aptitudeproduct.selectByValue("Product"); WebElement chooseproduct = driver.findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[14]/td[2]/input")); chooseproduct.sendKeys(aainfo.getPath()); addaptitude.click(); // Select aptitudeother = new Select(driver.findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[15]/td[2]/select"))); aptitudeother.selectByValue("Other"); WebElement chooseother = driver.findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[15]/td[2]/input")); chooseother.sendKeys(aainfo.getPath());*/ WebElement submit = driver.findElement(By.name("submitForm")); submit.click(); }
From source file:com.ipinyou.webpage.AdvertiserPage.java
public static void create(WebDriver driver, AdvertiserInfo adinfo, int a) throws NoSuchElementException { driver.findElement(By.className("resource-create-btn")).click(); driver.findElement(By.id("advertiser.name")).sendKeys(adinfo.adname); driver.findElement(By.id("advertiser.registerName")).sendKeys(adinfo.registername); if (a == 1) { driver.findElement(By.id("advertiser.serviceFeeRate")).sendKeys(adinfo.servicefeerate); }/*from ww w .ja v a 2 s . c o m*/ // driver.findElement(By.id("advertiser.selfService1")).click(); // driver.findElement(By.id("advertiser.selfService0")).click(); Select industry = new Select(driver.findElement(By.name("advertiser.verticalTagId"))); industry.selectByVisibleText(adinfo.industrytext); WebElement websuite = driver.findElement(By.id("advertiser.website")); websuite.clear(); websuite.sendKeys(adinfo.advertiserwebsite); //4.0 // driver.findElement(By.id("advertiser.orgCodeNo")).sendKeys(adinfo.orgcodeno); driver.findElement(By.id("advertiser.cellphone")).sendKeys(adinfo.cellphone); driver.findElement(By.id("advertiser.contactName")).sendKeys(adinfo.contactname); driver.findElement(By.id("advertiser.type0")).click(); driver.findElement(By.id("advertiser.email")).sendKeys(adinfo.email); driver.findElement(By.id("advertiser.showLogo1")).click(); driver.findElement(By.id("advertiser.showLogo0")).click(); WebElement addaptitude = driver.findElement(By.id("addQualificationFiles")); addaptitude.click(); if (a == 2) { addaptitude.click(); addaptitude.click(); } else { ; } //ICP Select aptitudeicp = new Select(driver.findElement(By.name("types"))); aptitudeicp.selectByValue("ICP"); driver.findElement(By.name("qualifications")).sendKeys(adinfo.path); addaptitude.click(); // 3.9 Select aptitudelicense = new Select(driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[15]/td[2]/select"))); aptitudelicense.selectByValue("License"); WebElement chooselicense = driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[15]/td[2]/input")); chooselicense.sendKeys(adinfo.path); addaptitude.click(); // Select aptitudelegalid = new Select(driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[16]/td[2]/select"))); aptitudelegalid.selectByValue("LegalId"); WebElement chooselegalid = driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[16]/td[2]/input")); chooselegalid.sendKeys(adinfo.path); addaptitude.click(); // Select aptitudeproduct = new Select(driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[17]/td[2]/select"))); aptitudeproduct.selectByValue("Product"); WebElement chooseproduct = driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[17]/td[2]/input")); chooseproduct.sendKeys(adinfo.path); // addaptitude.click(); Select aptitudeother = new Select(driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[18]/td[2]/select"))); aptitudeother.selectByValue("Other"); WebElement chooseother = driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[18]/td[2]/input")); chooseother.sendKeys(adinfo.path); // 4.0 // /*Select aptitudelicense = new Select(driver.findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[16]/td[2]/select"))); aptitudelicense.selectByValue("License"); WebElement chooselicense = driver.findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[16]/td[2]/input")); chooselicense.sendKeys(adinfo.path); addaptitude.click(); // Select aptitudelegalid = new Select(driver.findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[17]/td[2]/select"))); aptitudelegalid.selectByValue("LegalId"); WebElement chooselegalid = driver.findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[17]/td[2]/input")); chooselegalid.sendKeys(adinfo.path); addaptitude.click(); // Select aptitudeproduct = new Select(driver.findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[18]/td[2]/select"))); aptitudeproduct.selectByValue("Product"); WebElement chooseproduct = driver.findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[18]/td[2]/input")); chooseproduct.sendKeys(adinfo.path); addaptitude.click(); // PubHandle.select(driver, By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[19]/td[2]/select"), ""); WebElement orgen = driver.findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[19]/td[2]/input")); orgen.sendKeys(adinfo.path); // addaptitude.click(); Select aptitudeother = new Select(driver.findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[20]/td[2]/select"))); aptitudeother.selectByValue("Other"); WebElement chooseother = driver.findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[20]/td[2]/input")); chooseother.sendKeys(adinfo.path);*/ if (a == 2) { driver.findElement(By.id("removeQ_1")).click(); driver.findElement(By.id("removeQ_2")).click(); } else { ; } WebElement submit = driver.findElement(By.name("submitForm")); submit.click(); }
From source file:com.ipinyou.webpage.del.DelAdvertiserPage.java
public static void create(WebDriver driver, AdvertiserInfo adinfo, int a) throws NoSuchElementException { driver.findElement(By.className("resource-create-btn")).click(); driver.findElement(By.id("advertiser.name")).sendKeys(adinfo.adname); driver.findElement(By.id("advertiser.registerName")).sendKeys(adinfo.registername); if (a == 1) { driver.findElement(By.id("advertiser.serviceFeeRate")).sendKeys(adinfo.servicefeerate); }/*from www . j av a 2 s . co m*/ // driver.findElement(By.id("advertiser.selfService1")).click(); // driver.findElement(By.id("advertiser.selfService0")).click(); Select industry = new Select(driver.findElement(By.name("advertiser.verticalTagId"))); industry.selectByVisibleText(adinfo.industrytext); WebElement websuite = driver.findElement(By.id("advertiser.website")); websuite.clear(); websuite.sendKeys(adinfo.advertiserwebsite); driver.findElement(By.id("advertiser.cellphone")).sendKeys(adinfo.cellphone); driver.findElement(By.id("advertiser.contactName")).sendKeys(adinfo.contactname); driver.findElement(By.id("advertiser.type0")).click(); driver.findElement(By.id("advertiser.email")).sendKeys(adinfo.email); driver.findElement(By.id("advertiser.showLogo1")).click(); driver.findElement(By.id("advertiser.showLogo0")).click(); WebElement addaptitude = driver.findElement(By.id("addQualificationFiles")); addaptitude.click(); if (a == 2) { addaptitude.click(); } else { ; } //ICP Select aptitudeicp = new Select(driver.findElement(By.name("types"))); aptitudeicp.selectByValue("ICP"); driver.findElement(By.name("qualifications")).sendKeys(adinfo.path); addaptitude.click(); // Select aptitudelicense = new Select(driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[14]/td[2]/select"))); aptitudelicense.selectByValue("License"); WebElement chooselicense = driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[14]/td[2]/input")); chooselicense.sendKeys(adinfo.path); addaptitude.click(); // Select aptitudelegalid = new Select(driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[15]/td[2]/select"))); aptitudelegalid.selectByValue("LegalId"); WebElement chooselegalid = driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[15]/td[2]/input")); chooselegalid.sendKeys(adinfo.path); addaptitude.click(); // Select aptitudeproduct = new Select(driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[16]/td[2]/select"))); aptitudeproduct.selectByValue("Product"); WebElement chooseproduct = driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[16]/td[2]/input")); chooseproduct.sendKeys(adinfo.path); addaptitude.click(); // Select aptitudeother = new Select(driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[17]/td[2]/select"))); aptitudeother.selectByValue("Other"); WebElement chooseother = driver .findElement(By.xpath("//*[@id='advertiser_form']/div[1]/div[2]/table/tbody/tr[17]/td[2]/input")); chooseother.sendKeys(adinfo.path); WebElement submit = driver.findElement(By.name("submitForm")); submit.click(); }
From source file:com.jase.knife.BrowserEmulator.java
License:Apache License
/** * Type text at the page element<br> * Before typing, try to clear existed text * @param xpath, the element's xpath// w w w. ja v a2 s.co m * @param text, the input text */ public void type(String xpath, String text) { waitElement(xpath, timeout); WebElement we = browser.findElement(By.xpath(xpath)); try { we.clear(); } catch (Exception e) { e.printStackTrace(); } try { we.sendKeys(text); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.lazerycode.ebselen.customhandlers.TinyMCEHandler.java
License:Apache License
public void type(String value) throws Exception { WebElement tinyMCEFrame = doesElementExist(); this.driver.switchTo().frame(tinyMCEFrame); WebElement tinyMCEEditor = driver.findElement(By.id("tinymce")); tinyMCEEditor.sendKeys(value); this.driver.switchTo().defaultContent(); }
From source file:com.lazerycode.ebselen.customhandlers.TinyMCEHandler.java
License:Apache License
public void replaceHTMLSource(String value) throws Exception { driver.findElement(By.id(this.textAreaID + "_code")).click(); String sourceBlockID = driver.findElement(By.xpath("//div[@id='mceModalBlocker']/preceding-sibling::div")) .getAttribute("id"); WebElement htmlSourceFrame = doesElementExist(sourceBlockID); this.driver.switchTo().frame(htmlSourceFrame); WebElement htmlSource = driver.findElement(By.id("htmlSource")); htmlSource.clear();// w w w . ja v a 2 s . c o m htmlSource.sendKeys(value); driver.findElement(By.id("insert")).click(); this.driver.switchTo().defaultContent(); }
From source file:com.liferay.cucumber.selenium.BaseWebDriverImpl.java
License:Open Source License
@Override public void keyPress(String locator, String keySequence) { WebElement webElement = getWebElement(locator); if (keySequence.startsWith("\\")) { String keycode = keySequence.substring(1); if (isValidKeycode(keycode)) { Keys keys = Keys.valueOf(keycode); WrapsDriver wrapsDriver = (WrapsDriver) webElement; WebDriver webDriver = wrapsDriver.getWrappedDriver(); Actions actions = new Actions(webDriver); if (keycode.equals("ALT") || keycode.equals("COMMAND") || keycode.equals("CONTROL") || keycode.equals("SHIFT")) { actions.keyDown(webElement, keys); actions.keyUp(webElement, keys); Action action = actions.build(); action.perform();/* w w w .j a v a 2s. c om*/ } else { webElement.sendKeys(keys); } } } else { webElement.sendKeys(keySequence); } }
From source file:com.liferay.cucumber.selenium.BaseWebDriverImpl.java
License:Open Source License
@Override public void typeKeys(String locator, String value) { WebElement webElement = getWebElement(locator); if (!webElement.isEnabled()) { return;//from w ww . j a v a 2 s . c o m } if (value.contains("line-number=")) { value = value.replaceAll("line-number=\"\\d+\"", ""); } int i = 0; Set<Integer> specialCharIndexes = getSpecialCharIndexes(value); for (int specialCharIndex : specialCharIndexes) { webElement.sendKeys(value.substring(i, specialCharIndex)); String specialChar = String.valueOf(value.charAt(specialCharIndex)); if (specialChar.equals("-")) { webElement.sendKeys(Keys.SUBTRACT); } else if (specialChar.equals("\t")) { webElement.sendKeys(Keys.TAB); } else { webElement.sendKeys(Keys.SHIFT, _keysSpecialChars.get(specialChar)); } i = specialCharIndex + 1; } webElement.sendKeys(value.substring(i, value.length())); }