當前位置: 首頁>>代碼示例>>Java>>正文


Java WebElement.sendKeys方法代碼示例

本文整理匯總了Java中org.openqa.selenium.WebElement.sendKeys方法的典型用法代碼示例。如果您正苦於以下問題:Java WebElement.sendKeys方法的具體用法?Java WebElement.sendKeys怎麽用?Java WebElement.sendKeys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openqa.selenium.WebElement的用法示例。


在下文中一共展示了WebElement.sendKeys方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: searchFor

import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
/**
 * Types into the search bar in the top right and searches.
 * 
 * @param content
 *            - The value to type into the search bar.
 */
public void searchFor(String content) {
	this.focusForm(false);
	WebElement mGTypeArea = _wait.until(ExpectedConditions.presenceOfElementLocated(By.name("sysparm_search")));
	if (!mGTypeArea.getClass().toString().contains("focus")) {
		WebElement magnifyingGlass = _wait
				.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("[action='textsearch.do']")));
		magnifyingGlass.click();
	}
	if(!mGTypeArea.getAttribute("value").equalsIgnoreCase("")) {
		mGTypeArea.clear();
	}
	mGTypeArea.sendKeys(content);
	mGTypeArea.sendKeys(Keys.ENTER);
}
 
開發者ID:SeanABoyer,項目名稱:ServiceNow_Selenium,代碼行數:21,代碼來源:ServiceNow.java

示例2: sendKeys

import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
public void sendKeys() throws Throwable {
    driver = new JavaDriver();
    List<WebElement> buttons = driver.findElements(By.cssSelector("button"));
    AssertJUnit.assertEquals(3, buttons.size());
    WebElement b1 = buttons.get(0);
    AssertJUnit.assertEquals("<html><center><b><u>D</u>isable</b><br><font color=#ffffdd>middle button</font>", b1.getText());
    WebElement b2 = buttons.get(1);
    AssertJUnit.assertEquals("middle button", b2.getText());
    WebElement b3 = buttons.get(2);
    AssertJUnit.assertEquals("<html><center><b><u>E</u>nable</b><br><font color=#ffffdd>middle button</font>", b3.getText());
    AssertJUnit.assertEquals("true", b1.getAttribute("enabled"));
    AssertJUnit.assertEquals("true", b2.getAttribute("enabled"));
    AssertJUnit.assertEquals("false", b3.getAttribute("enabled"));
    b1.sendKeys(Keys.SPACE);
    AssertJUnit.assertEquals("false", b1.getAttribute("enabled"));
    AssertJUnit.assertEquals("false", b2.getAttribute("enabled"));
    AssertJUnit.assertEquals("true", b3.getAttribute("enabled"));
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:19,代碼來源:JButtonHtmlTest.java

示例3: sendKeys

import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
public void sendKeys() throws Throwable {
    driver = new JavaDriver();
    List<WebElement> buttons = driver.findElements(By.cssSelector("button"));
    AssertJUnit.assertEquals(3, buttons.size());
    WebElement b1 = buttons.get(0);
    AssertJUnit.assertEquals("Disable middle button", b1.getText());
    WebElement b2 = buttons.get(1);
    AssertJUnit.assertEquals("Middle button", b2.getText());
    WebElement b3 = buttons.get(2);
    AssertJUnit.assertEquals("Enable middle button", b3.getText());
    AssertJUnit.assertEquals("true", b1.getAttribute("enabled"));
    AssertJUnit.assertEquals("true", b2.getAttribute("enabled"));
    AssertJUnit.assertEquals("false", b3.getAttribute("enabled"));
    b1.sendKeys(Keys.SPACE);
    AssertJUnit.assertEquals("false", b1.getAttribute("enabled"));
    AssertJUnit.assertEquals("false", b2.getAttribute("enabled"));
    AssertJUnit.assertEquals("true", b3.getAttribute("enabled"));
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:19,代碼來源:JButtonTest.java

示例4: testEventListenerWithError

import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
@Test
public void testEventListenerWithError() {
    WebDriver webDriver = rule.getWebDriver();
    webDriver.get("https://github.com");
    WebElement searchInput = webDriver.findElement(By.cssSelector(".header-search-input"));
    searchInput.sendKeys("will", "test");
    searchInput.sendKeys(Keys.ENTER);
    String searchKeyword = webDriver.findElement(By.cssSelector(".header-search-input")).getAttribute("value");
    assertThat(searchKeyword, is("foooooo"));
}
 
開發者ID:willhaben,項目名稱:willtest,代碼行數:11,代碼來源:EventListenerExample.java

示例5: testGetAttribute

import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
@Test
public void testGetAttribute() {
	WebElement textField = driver.findElement(By.xpath("//TextField"));
	textField.sendKeys("hello");

	// TODO: Currently (Selenium 3.6) getAttribute delegates to
	// executeJavaScript with a complex script which we can't support.
	
	String enabled = textField.getAttribute("Enabled");
	// assertEquals("true", enabled);
	// assertEquals("Consolas", textField.getAttribute("Font"));
	// assertEquals("false", textField.getAttribute("IsPassword"));
	// assertEquals("MultiLine", textField.getAttribute("true"));
}
 
開發者ID:MicroFocus,項目名稱:SilkAppDriver,代碼行數:15,代碼來源:NotepadDemoTest.java

示例6: sendKeysDelay

import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
/**
 * Send keys with delay
 * @param element Element to send
 * @param message Message to put
 * @param delay Delay in ms
 */
public void sendKeysDelay(WebElement element, String message, long delay) {
    
    for (char c : message.toCharArray()) {
        element.sendKeys(String.valueOf(c));
        try {
            TimeUnit.MILLISECONDS.sleep(delay);
        } catch (InterruptedException e) {
            //its ok
        }
    }
    
}
 
開發者ID:brunocvcunha,項目名稱:seleneasy,代碼行數:19,代碼來源:Seleneasy.java

示例7: pressTabKey

import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
/**
 * Simulate Tab key
 */
@Override
@PublicAtsApi
public void pressTabKey() {

    new RealHtmlElementState(this).waitToBecomeExisting();

    WebElement element = RealHtmlElementLocator.findElement(this);
    element.sendKeys(Keys.TAB);
}
 
開發者ID:Axway,項目名稱:ats-framework,代碼行數:13,代碼來源:RealHtmlElement.java

示例8: tableCellEditUneditable

import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
public void tableCellEditUneditable() throws Throwable {
    driver = new JavaDriver();
    try {
        WebElement cell = driver.findElement(By.cssSelector("table::mnth-cell(3,1)::editor"));
        cell.sendKeys("Hello World", Keys.ENTER);
        throw new MissingException(NoSuchElementException.class);
    } catch (NoSuchElementException e) {
    }
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:10,代碼來源:JTableTest.java

示例9: sendKeysNTimes

import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
public static void sendKeysNTimes(WebElement element, int numberOfTimes, Keys keyName) {
	try {
		for (int count = 1; count <= numberOfTimes; count++) {
			element.sendKeys(keyName);
		}
	} catch (Exception e) {
		System.out.println("Error occured while sending keys...\n" + e.getMessage());
	}
}
 
開發者ID:anilpandeykiet,項目名稱:POM_HYBRID_FRAMEOWRK,代碼行數:10,代碼來源:WebTextbox.java

示例10: username_and_password_are_given

import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
@When("^username \"([^\"]*)\" and password \"([^\"]*)\" are given$")
public void username_and_password_are_given(String username, String password) throws Throwable {
    WebElement element = driver.findElement(By.name("username"));
    element.sendKeys(username);
    element = driver.findElement(By.name("password"));
    element.sendKeys(password);
    element = driver.findElement(By.name("login"));
    element.submit();  
}
 
開發者ID:mluukkai,項目名稱:ohjelmistotuotanto2017,代碼行數:10,代碼來源:Stepdefs.java

示例11: changeData

import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
public void changeData(String value){

        WebElement text = getDriver().findElement(By.id("form:text"));
        WebElement button = getDriver().findElement(By.id("form:modify"));

        text.clear();
        text.sendKeys(value);
        button.click();
        waitForPageToLoad();
    }
 
開發者ID:arcuri82,項目名稱:testing_security_development_enterprise_systems,代碼行數:11,代碼來源:HomePageObject.java

示例12: clickOnCol

import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
private void clickOnCol(WebElement table, int colNum) {
    // Index on the element is 1 based and index on the JTable is 0 based.
    // Hence adding 1 to the colNum
    WebElement col = table.findElement(By.cssSelector(".::mnth-cell(1," + (colNum + 1) + ")"));
    col.click();
    table.sendKeys(Keys.NULL);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:8,代碼來源:JTableColumnSelectionTest.java

示例13: UpdateCV

import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
public void UpdateCV (String filePath) {
	
	WebElement viewProfile = driver.findElement (By.linkText ("View Profile"));
	
	Actions act = new Actions(driver);
	act.click (viewProfile).perform ();
	
	WebElement uploadLink = driver.findElement (By.id ("uploadLink"));
	act.click (uploadLink).perform ();
	
	WebElement attachCV = driver.findElement (By.id("attachCV"));
	attachCV.sendKeys (filePath);
	
	sleep();
	
	WebElement saveCV = driver.findElement (By.cssSelector("button.w85bt.fl"));
	act.click(saveCV).perform ();
	
	sleep();
}
 
開發者ID:mfaisalkhatri,項目名稱:NaukriSite,代碼行數:21,代碼來源:ProfilePage.java

示例14: setText

import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
public void setText(String id, String text){
    WebElement element = driver.findElement(By.id(id));
    element.clear();
    element.sendKeys(text);
}
 
開發者ID:arcuri82,項目名稱:testing_security_development_enterprise_systems,代碼行數:6,代碼來源:PageObject.java

示例15: setBucketName

import org.openqa.selenium.WebElement; //導入方法依賴的package包/類
public void setBucketName(String bucketName)
{
	WebElement bucketNameInput = getBucketNameInput();
	bucketNameInput.sendKeys(bucketName);
}
 
開發者ID:tmply,項目名稱:tmply,代碼行數:6,代碼來源:TmplyPage.java


注:本文中的org.openqa.selenium.WebElement.sendKeys方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。