本文整理汇总了Java中org.openqa.selenium.Keys.chord方法的典型用法代码示例。如果您正苦于以下问题:Java Keys.chord方法的具体用法?Java Keys.chord怎么用?Java Keys.chord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openqa.selenium.Keys
的用法示例。
在下文中一共展示了Keys.chord方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: _executeGesture
import org.openqa.selenium.Keys; //导入方法依赖的package包/类
@Override
protected boolean _executeGesture( WebDriver webDriver )
{
String[] keyCodes = getKeyCode().split("\\+");
String keyPressed = null;
List<CharSequence> charSequence = new ArrayList<CharSequence>();
for (String keyCode : keyCodes) {
if (Keys.valueOf(keyCode) != null) {
charSequence.add(Keys.valueOf(keyCode.toUpperCase()));
} else {
throw new IllegalArgumentException( "Unsupported KeyPressGesture Type " + keyCode );
}
}
if (charSequence.size() > 0) {
Iterable<CharSequence> iterable = charSequence;
keyPressed = Keys.chord(iterable);
new Actions( webDriver ).moveToElement( webElement ).sendKeys(keyPressed).perform();
}
return true;
}
示例2: pressKeyCombination
import org.openqa.selenium.Keys; //导入方法依赖的package包/类
/**
* Эмулирует нажатие сочетания клавиш на клавиатуре.
* Допустим, чтобы эмулировать нажатие на Ctrl+A, в таблице должны быть следующие значения
* | CONTROL |
* | a |
*
* @param keyNames название клавиши
*/
@И("^выполнено нажатие на сочетание клавиш из таблицы$")
public void pressKeyCombination(List<String> keyNames) {
Iterable<CharSequence> listKeys = keyNames.stream()
.map(this::getKeyOrCharacter)
.collect(Collectors.toList());
String combination = Keys.chord(listKeys);
WebDriverRunner.getWebDriver().switchTo().activeElement().sendKeys(combination);
}
示例3: _executeAction
import org.openqa.selenium.Keys; //导入方法依赖的package包/类
@Override
public boolean _executeAction( WebDriver webDriver, List<Object> parameterList )
{
String executionId = getExecutionId( webDriver );
String deviceName = getDeviceName( webDriver );
String applicationName = (String) parameterList.get( 0 );
ApplicationDescriptor appDesc = ApplicationRegistry.instance( ( (DeviceWebDriver) webDriver).getxFID() ).getApplication( applicationName );
if ( appDesc == null )
throw new ScriptConfigurationException( "The Application " + applicationName + " does not exist" );
if ( appDesc.isWeb() )
{
String selectLinkOpeninNewTab = Keys.chord(Keys.CONTROL,"t");
if ( webDriver.getWindowHandles() != null && webDriver.getWindowHandles().size() > 0 )
webDriver.findElement(By.tagName("body")).sendKeys(selectLinkOpeninNewTab);
webDriver.get( appDesc.getUrl() );
( (DeviceWebDriver) webDriver ).setAut( appDesc, ( (DeviceWebDriver) webDriver ).getxFID() );
}
else
{
Handset localDevice = PerfectoMobile.instance( ( (DeviceWebDriver) webDriver ).getxFID() ).devices().getDevice( deviceName );
Execution appExec = null;
if ( localDevice.getOs().toLowerCase().equals( "ios" ) )
appExec = PerfectoMobile.instance( ( (DeviceWebDriver) webDriver ).getxFID() ).application().open( executionId, deviceName, appDesc.getName(), appDesc.getAppleIdentifier() );
else if ( localDevice.getOs().toLowerCase().equals( "android" ) )
appExec = PerfectoMobile.instance( ( (DeviceWebDriver) webDriver ).getxFID() ).application().open( executionId, deviceName, appDesc.getName(), appDesc.getAndroidIdentifier() );
else
throw new IllegalArgumentException( "Could not install application to " + localDevice.getOs() );
if ( appExec != null )
{
if ( appExec.getStatus().toLowerCase().equals( "success" ) )
{
if ( webDriver instanceof ContextAware )
( ( ContextAware ) webDriver ).context( "NATIVE_APP" );
( (DeviceWebDriver) webDriver ).setAut( appDesc, ( (DeviceWebDriver) webDriver ).getxFID() );
return true;
}
else
throw new ScriptException( "Failed to launch application " + appDesc.getName() );
}
else
throw new ScriptException( "Failed to launch application " + appDesc.getName() );
}
return true;
}