当前位置: 首页>>代码示例>>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;未经允许,请勿转载。