本文整理了Java中org.openqa.selenium.interactions.Keyboard.sendKeys()
方法的一些代码示例,展示了Keyboard.sendKeys()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Keyboard.sendKeys()
方法的具体详情如下:
包路径:org.openqa.selenium.interactions.Keyboard
类名称:Keyboard
方法名:sendKeys
[英]Sends keys to the keyboard representation in the browser. Special keys that are not text, represented as org.openqa.selenium.Keys are recognized both as part of sequences of characters, or individually. Modifier keys are preserved throughout the lifetime of the send keys operation, and are released upon this method returning.
[中]将键发送到浏览器中的键盘表示形式。非文本的特殊键,表示为org。openqa。硒。键既可以作为字符序列的一部分识别,也可以单独识别。修改键在send keys操作的整个生命周期内都会保留,并在该方法返回时释放。
代码示例来源:origin: viltgroup/minium
@Override
public void sendKeys(CharSequence... keysToSend) {
ensureWebDriver();
delegateKeyboard().sendKeys(keysToSend);
}
代码示例来源:origin: org.seleniumhq.selenium/selenium-api
public void perform() {
focusOnElement();
keyboard.sendKeys(keysToSend);
}
代码示例来源:origin: viltgroup/minium
@Override
protected void doPerform() {
if (isSourceDocumentRoot()) {
keyboard().sendKeys(keys);
} else {
getFirstElement().sendKeys(keys);
}
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui
/**
* Deletes this suggestion from the list of selected suggestions.
*/
public void delete()
{
select();
// We don't send the keys directly to the text input because it can be hidden.(e.g. when multiple selection
// is on and we click on a selected suggestion).
getDriver().getKeyboard().sendKeys(Keys.BACK_SPACE);
}
代码示例来源:origin: com.infotel.seleniumRobot/core
@ReplayOnError
public void simulateSendKeys(CharSequence... keysToSend) {
findElement(true);
// click on element before sending keys through keyboard
element.click();
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].focus();", element);
WebDriver realDriver = ((CustomEventFiringWebDriver)driver).getWebDriver();
// handle org.openqa.selenium.UnsupportedCommandException: sendKeysToActiveElement which are not available for firefox and IE
if ((realDriver instanceof FirefoxDriver && FirefoxDriverFactory.isMarionetteMode())
|| realDriver instanceof InternetExplorerDriver) {
logger.warn("using specific Marionette method");
js.executeScript(String.format("arguments[0].value='%s';", keysToSend[0].toString()), element);
} else {
// use keyboard to type
((CustomEventFiringWebDriver)driver).getKeyboard().sendKeys(keysToSend);
}
}
代码示例来源:origin: com.applitools/eyes-selenium-java3
public void sendKeys(CharSequence... charSequences) {
Region control = Region.EMPTY;
// We first find the active element to get the region
WebElement activeElement = eyesDriver.switchTo().activeElement();
if (activeElement instanceof RemoteWebElement) {
activeElement = new EyesRemoteWebElement(logger, eyesDriver, activeElement);
control = ((EyesRemoteWebElement)activeElement).getBounds();
}
for(CharSequence keys : charSequences) {
String text = String.valueOf(keys);
eyesDriver.getEyes().addTextTrigger(control, text);
}
keyboard.sendKeys(charSequences);
}
代码示例来源:origin: com.atlassian.confluence/confluence-webdriver-pageobjects
public LabelsDialog addLabelUsingEnterKey(String label) {
typeInLabelsInput(label);
driver.getKeyboard().sendKeys(RETURN);
waitUntilTrue("New label should be visible", getLabelSection().hasLabelCondition(label));
return this;
}
代码示例来源:origin: com.opera/operadriver
public void sendKeys(CharSequence... keysToSend) {
verifyCanInteractWithElement();
// Handle special input types
String typeAttribute = getAttribute("type");
if (typeAttribute != null) {
typeAttribute = typeAttribute.toLowerCase();
if (getTagName().equals("INPUT") && SPECIAL_INPUTS.contains(typeAttribute)) {
if (typeAttribute.equals("file")) {
File localFile = fileDetector.getLocalFile(keysToSend);
if (localFile != null) {
debugger.setFormElementValue(objectId, localFile.getAbsolutePath());
}
} else {
debugger.setFormElementValue(objectId, Joiner.on("").join(keysToSend));
}
return;
}
}
parent.getScopeServices().captureOperaIdle();
switchFocusToThisIfNeeded();
parent.getKeyboard().sendKeys(keysToSend);
try {
parent.waitForLoadToComplete();
} catch (ResponseNotReceivedException e) {
// return control to user
}
}
代码示例来源:origin: arquillian/arquillian-graphene
@Test
public void testGrapheneElementActionWriteIntoElement() {
// when
grapheneElement.writeIntoElement("hi");
// then
verify(mouse).mouseMove(((Locatable) grapheneElement).getCoordinates());
verify(mouse).click(((Locatable) grapheneElement).getCoordinates());
verify(keyboard).sendKeys("hi");
verifyNoMoreInteractions(mouse, keyboard);
}
}
代码示例来源:origin: arquillian/arquillian-graphene
@Test
public void testGrapheneActionWriteIntoElement() {
// when
Graphene.writeIntoElement(webElement, "hi");
// then
verify(mouse).mouseMove(((Locatable) webElement).getCoordinates());
verify(mouse).click(((Locatable) webElement).getCoordinates());
verify(keyboard).sendKeys("hi");
verifyNoMoreInteractions(mouse, keyboard);
}
}
内容来源于网络,如有侵权,请联系作者删除!