本文整理汇总了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);
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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
}
}
}
示例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);
}
示例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) {
}
}
示例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());
}
}
示例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();
}
示例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);
}
示例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();
}
示例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);
}
示例15: setBucketName
import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
public void setBucketName(String bucketName)
{
WebElement bucketNameInput = getBucketNameInput();
bucketNameInput.sendKeys(bucketName);
}