List of usage examples for org.openqa.selenium WebElement clear
void clear();
From source file:com.htmlhifive.test.selenium.testcase.coverage.IndicatorTest.java
License:Apache License
public IndicatorTest(WebDriver driver) throws InterruptedException { super(driver); try {/*from w w w .java 2s . c o m*/ if (querySelector("#location").get(0).getText().equals(BLOCK_SAMPLE_PAGE)) { return; } } catch (Exception e) { return; } // ???BeforeClass??????????????????? WebElement locationBox = querySelector("#location").get(0); locationBox.clear(); locationBox.sendKeys(BLOCK_SAMPLE_PAGE); WebElement openInWindow = querySelector("[title='open URL in the iframe below [Enter]']").get(0); openInWindow.click(); Thread.sleep(1000); }
From source file:com.htmlhifive.test.selenium.testcase.coverage.marge.Runner.java
License:Apache License
@Test public void openQUnit() throws InterruptedException { WebElement locationBox = querySelector("#location").get(0); locationBox.clear(); locationBox.sendKeys(QUNIT_PAGE);/* w ww . j a v a2s.com*/ WebElement openInWindow = querySelector("[title='open URL in the iframe below [Enter]']").get(0); openInWindow.click(); Thread.sleep(1000); }
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 w w . ja v 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.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()); }//from www . 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); }/* www .j a va2 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); //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 a va 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(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//from w w w .j a v a 2 s . com * @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 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(); htmlSource.sendKeys(value);/*w w w . ja v a2 s. c om*/ 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 type(String locator, String value) { WebElement webElement = getWebElement(locator); if (!webElement.isEnabled()) { return;/* w w w. j av a 2 s . co m*/ } webElement.clear(); typeKeys(locator, value); }
From source file:com.liferay.cucumber.selenium.WebDriverHelper.java
License:Open Source License
public static void type(WebDriver webDriver, String locator, String value) { WebElement webElement = getWebElement(webDriver, locator); if (!webElement.isEnabled()) { return;/*from w w w .ja v a 2 s . c o m*/ } webElement.clear(); webElement.sendKeys(value); }