本文整理汇总了Java中org.openqa.selenium.Keys.CONTROL属性的典型用法代码示例。如果您正苦于以下问题:Java Keys.CONTROL属性的具体用法?Java Keys.CONTROL怎么用?Java Keys.CONTROL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.openqa.selenium.Keys
的用法示例。
在下文中一共展示了Keys.CONTROL属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dndWithCopy
public void dndWithCopy() throws Throwable {
DesiredCapabilities caps = new DesiredCapabilities();
// caps.setCapability("nativeEvents", true);
driver = new JavaDriver(caps, caps);
WebElement list = driver.findElement(By.cssSelector("list"));
assertEquals(
"[[\"List Item 0\",\"List Item 1\",\"List Item 2\",\"List Item 3\",\"List Item 4\",\"List Item 5\",\"List Item 6\",\"List Item 7\",\"List Item 8\",\"List Item 9\"]]",
list.getAttribute("content"));
WebElement listitem1 = driver.findElement(By.cssSelector("list::nth-item(1)"));
WebElement listitem5 = driver.findElement(By.cssSelector("list::nth-item(5)"));
listitem1.click();
driver.clearlogs(LogType.DRIVER);
Keys copyKey = Keys.ALT;
if (Platform.isWindows()) {
copyKey = Keys.CONTROL;
}
new Actions(driver).keyDown(copyKey).dragAndDrop(listitem1, listitem5).keyUp(copyKey).perform();
waitTillDropCompletes(
"[[\"List Item 0\",\"List Item 1\",\"List Item 2\",\"List Item 3\",\"List Item 0(1)\",\"List Item 5\",\"List Item 6\",\"List Item 7\",\"List Item 8\",\"List Item 9\"]]",
list);
assertEquals(
"[[\"List Item 0\",\"List Item 1\",\"List Item 2\",\"List Item 3\",\"List Item 0(1)\",\"List Item 5\",\"List Item 6\",\"List Item 7\",\"List Item 8\",\"List Item 9\"]]",
list.getAttribute("content"));
}
示例2: inspectElement
public void inspectElement(WebElement element) {
keyCTRL = osName.startsWith("Mac") ? Keys.COMMAND : Keys.CONTROL;
if (osName.startsWith("Mac")) {
actions.keyDown(keyCTRL).build().perform();
actions.moveToElement(element).contextClick().build().perform();
actions.keyUp(keyCTRL).build().perform();
} else {
actions.moveToElement(element).build().perform();
actions.keyDown(keyCTRL).contextClick().keyUp(keyCTRL).build().perform();
}
// Assert
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
示例3: getMenuKey
public static Keys getMenuKey() {
int keyMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
if (keyMask == Event.CTRL_MASK) {
return Keys.CONTROL;
}
if (keyMask == Event.META_MASK) {
return Keys.META;
}
if (keyMask == Event.ALT_MASK) {
return Keys.ALT;
}
throw new WebDriverException("Unable to find the keymask... not control or meta?");
}
示例4: listMultipleSelectWithControl
public void listMultipleSelectWithControl() throws Throwable {
driver = new JavaDriver();
WebElement listItem;
listItem = driver.findElement(By.cssSelector("#list-1::nth-item(6)"));
WebElement listItem2 = driver.findElement(By.cssSelector("#list-1::nth-item(3)"));
WebElement listItem3 = driver.findElement(By.cssSelector("#list-1::nth-item(4)"));
Keys command = Platform.getCurrent().is(Platform.MAC) ? Keys.COMMAND : Keys.CONTROL;
new Actions(driver).click(listItem).sendKeys(command).click(listItem2).click(listItem3).sendKeys(command).perform();
ArrayList<Integer> al = new ArrayList<Integer>();
int[] selectedIndices = new int[] { 2, 3, 5 };
for (int i : selectedIndices) {
al.add(i);
}
assertEquals(al.toString(), driver.findElement(By.cssSelector("#list-1")).getAttribute("selectedIndices"));
}
示例5: getKeyCode
Keys getKeyCode(String data) {
switch (data) {
case "tab":
return Keys.TAB;
case "enter":
return Keys.ENTER;
case "shift":
return Keys.SHIFT;
case "ctrl":
return Keys.CONTROL;
case "alt":
return Keys.ALT;
case "esc":
return Keys.ESCAPE;
case "delete":
return Keys.DELETE;
case "backspace":
return Keys.BACK_SPACE;
case "home":
return Keys.HOME;
default:
try {
return Keys.valueOf(data.toUpperCase());
} catch (Exception ex) {
return null;
}
}
}
示例6: selectAdditionalRow
public void selectAdditionalRow(int index) {
scrollToRowIndex(index);
WebElement row = findRow(index);
final Keys key = isPlatform(Platform.MAC) ? Keys.COMMAND : Keys.CONTROL;
new Actions(getDriver()).keyDown(key).click(row).keyUp(key).perform();
waitForPpr();
}