本文整理汇总了Java中org.openqa.selenium.interactions.Keyboard.sendKeys方法的典型用法代码示例。如果您正苦于以下问题:Java Keyboard.sendKeys方法的具体用法?Java Keyboard.sendKeys怎么用?Java Keyboard.sendKeys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openqa.selenium.interactions.Keyboard
的用法示例。
在下文中一共展示了Keyboard.sendKeys方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clearField
import org.openqa.selenium.interactions.Keyboard; //导入方法依赖的package包/类
@When("очистить \"$fieldName\"")
public void clearField(@Named("$fieldName") String fieldName) {
WebElement webElement = getWebElementByName(fieldName);
webElement.clear();
Keyboard keyboard = driver.getKeyboard();
for (int i = webElement.getText().length(); i > 0; i--) {
keyboard.sendKeys(Keys.BACK_SPACE);
}
}
示例2: sendTextDelay
import org.openqa.selenium.interactions.Keyboard; //导入方法依赖的package包/类
@Step
@When("ввод текста с клавиатуры \"$textOrKeyword\" посимвольно")
public void sendTextDelay(@Named("$textOrKeyword") String textOrKeyword) {
String text = propertyUtils.injectProperties(textOrKeyword);
String eachLetter;
Keyboard keyboard = driver.getKeyboard();
for (int i = text.length(); i > 0; i--) {
eachLetter = String.valueOf(text.charAt(i - 1));
keyboard.sendKeys(eachLetter);
}
}
示例3: clearField
import org.openqa.selenium.interactions.Keyboard; //导入方法依赖的package包/类
@Step
@When("очистить \"$fieldName\"")
public void clearField(@Named("$fieldName") String fieldName) {
IElement element = getCurrentPage().getElementByName(fieldName);
WebElement webElement = finder.findWebElement(element);
Keyboard keyboard = driver.getKeyboard();
for (int i = webElement.getText().length(); i > 0; i--) {
keyboard.sendKeys(Keys.BACK_SPACE);
}
}
示例4: clearField
import org.openqa.selenium.interactions.Keyboard; //导入方法依赖的package包/类
@Step
@When("очистить \"$field\"")
public void clearField(@Named("$field") String field) {
IElement element = getCurrentPage().getElementByName(field);
WebElement webElement = finder.findWebElement(element);
Keyboard keyboard = driver.getKeyboard();
for (int i = 0; i < webElement.getText().length(); i++) {
keyboard.sendKeys(Keys.BACK_SPACE);
}
}
示例5: call
import org.openqa.selenium.interactions.Keyboard; //导入方法依赖的package包/类
@Override
public Void call() throws Exception {
Keyboard keyboard = ((HasInputDevices) getDriver()).getKeyboard();
String[] keysToSend = keys.toArray(new String[0]);
keyboard.sendKeys(keysToSend);
return null;
}