热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.openqa.selenium.interactions.Actions.clickAndHold()方法的使用及代码示例

本文整理了Java中org.openqa.selenium.interactions.Actions.clickAndHold()方法的一些代码示例,展示了

本文整理了Java中org.openqa.selenium.interactions.Actions.clickAndHold()方法的一些代码示例,展示了Actions.clickAndHold()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Actions.clickAndHold()方法的具体详情如下:
包路径:org.openqa.selenium.interactions.Actions
类名称:Actions
方法名:clickAndHold

Actions.clickAndHold介绍

[英]Clicks (without releasing) at the current mouse location.
[中]在当前鼠标位置单击(不释放)。

代码示例

代码示例来源:origin: stackoverflow.com

Actions builder = new Actions(driver);
Action dragAndDrop = builder.clickAndHold(someElement)
.moveToElement(otherElement)
.release(otherElement)
.build();
dragAndDrop.perform();

代码示例来源:origin: org.richfaces/richfaces-page-fragments

@Override
public Actions clickAndHold() {
super.clickAndHold();
return this;
}

代码示例来源:origin: TEAMMATES/teammates

public void dragAndDropQuestionOption(String qnType, int qnNumber, int sourceIndex, int targetIndex) throws Exception {
WebElement draggedOptiOnElement= browser.driver.findElement(By.xpath("//div[@id='" + qnType + "OptionRow-"
+ sourceIndex + "-" + qnNumber + "']//span[@class='glyphicon glyphicon-resize-vertical']"));
WebElement targetElement = browser.driver.findElement(By.xpath("//div[@id='" + qnType + "OptionRow-"
+ targetIndex + "-" + qnNumber + "']//span[@class='glyphicon glyphicon-resize-vertical']"));
Actions builder = new Actions(browser.driver);
// drag option to target, move 10 units above target and release
// multiple movements are used to slow down drag movement and provide
// enough time for the grid to create empty slots
builder.clickAndHold(draggedOptionElement)
.moveToElement(targetElement)
.moveToElement(targetElement, 0, -10)
.release()
.build()
.perform();
}

代码示例来源:origin: stackoverflow.com

Actions builder = new Actions(dr);
Action dragAndDrop = builder.clickAndHold(someElement)
.moveToElement(otherElement)
.release(otherElement)
.build();
dragAndDrop.perform();

代码示例来源:origin: stackoverflow.com

WebElement elm = driver.findElement(By.id("btn1"));
Actions builder = new Actions(driver);
Action act = builder.clickAndHold(elm).build();
act.perform();
try {
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("c:\\Img\\screenshot.png"));
} catch (IOException e) {
e.printStackTrace();
}
act = builder.release(elm).build();
act.perform();

代码示例来源:origin: stackoverflow.com

WebElement sourceElement = mySourceElement;
Actions builder = new Actions(driver);
Action dragAndDrop = builder.clickAndHold(sourceElement).build();
dragAndDrop.perform();
driver.switchTo().frame(iFrame);
WebElement targetElement = myTargetElement;
Thread.sleep(1000);
dragAndDrop = builder.moveToElement(targetElement).release().build();
dragAndDrop.perform();

代码示例来源:origin: sayems/java.webdriver

public Actions dragDropClickMoveRelease(Supplier from, Supplier to) {
Actions build = new Actions(driver);
build.clickAndHold(driver.findElement(from.get())).build().perform();
build.moveToElement(driver.findElement(to.get())).build().perform();
build.release(driver.findElement(to.get())).perform();
return build;
}

代码示例来源:origin: org.mazarineblue/MazarineBlue-WebDriver

@Override
protected Void action(WebKey key, Object... param)
throws ExecutionException {
WebElement e = key == null ? null : fetcher.fetchElement(key);

Actions actiOns= new Actions(driver);
actions.clickAndHold(e);
actions.perform();
return null;
}
};

代码示例来源:origin: org.jspringbot/jspringbot-selenium

public void mouseUp(String locator) {
LOG.keywordAppender().appendLocator(locator);
WebElement el = finder.find(locator);
if (el == null) {
throw new IllegalStateException(String.format("ERROR: Element %s not found", locator));
}
new Actions(driver).clickAndHold(el).release().perform();
}

代码示例来源:origin: org.jspringbot/jspringbot-selenium

public void mouseDownOnImage(String locator){
LOG.keywordAppender().appendLocator(locator);
WebElement el = finder.find(locator, "image");
new Actions(driver).clickAndHold(el).perform();
}
public void mouseDownOnLink(String locator) {

代码示例来源:origin: net.code-story/simplelenium

@Override
public LazyDomElement dragAndDropTo(String destinationSelector) {
return executeActions("dragAndDropTo(" + destinationSelector + ")", (element, actions) -> actions
.clickAndHold(element)
.pause(100)
.release(driver().findElementByCssSelector(destinationSelector)));
}

代码示例来源:origin: org.jspringbot/jspringbot-selenium

public void mouseDownOnLink(String locator) {
LOG.keywordAppender().appendLocator(locator);
WebElement el = finder.find(locator, "link");
new Actions(driver).clickAndHold(el).perform();
}

代码示例来源:origin: com.saucelabs/sebuilder-interpreter

@Override
public boolean run(TestRun ctx) {
new Actions(ctx.driver()).clickAndHold(ctx.locator("locator").find(ctx)).build().perform();
return true;
}
}

代码示例来源:origin: epam/JDI

protected void hoverAction(String... name) {
chooseItemAction(name, el -> {
Actions action = new Actions(getDriver());
action.moveToElement(el).clickAndHold().build().perform();
});
}

代码示例来源:origin: com.epam.jdi/jdi-uitest-web

protected void hoverAction(String... name) {
chooseItemAction(name, el -> {
Actions action = new Actions(getDriver());
action.moveToElement(el).clickAndHold().build().perform();
});
}

代码示例来源:origin: epam/JDI

public void selectArea(int x1, int y1, int x2, int y2) {
invoker.doJAction(format("Select area: from %d,%d;to %d,%d", x1, y1, x2, y2), () -> {
WebElement element = getWebElement();
new Actions(getDriver()).moveToElement(element, x1, y1).clickAndHold()
.moveToElement(element, x2, y2).release().build().perform();
});
}

代码示例来源:origin: com.epam.jdi/jdi-uitest-web

public void selectArea(int x1, int y1, int x2, int y2) {
invoker.doJAction(format("Select area: from %d,%d;to %d,%d", x1, y1, x2, y2), () -> {
WebElement element = getWebElement();
new Actions(getDriver()).moveToElement(element, x1, y1).clickAndHold()
.moveToElement(element, x2, y2).release().build().perform();
});
}

代码示例来源:origin: arquillian/arquillian-graphene

@Test
public void testStalenessAndActionsOnWebElement1() {
WebElement inStale = browser.findElement(By.className("stale")).findElement(By.className("in-stale"));
Action action = new Actions(browser).clickAndHold(inStale).release(inStale).build();
makeStale.click();
action.perform();
}

代码示例来源:origin: Wikia/selenium-tests

public void reorderCategory(String categoryName, int offset) {
final WebElement element = findEditableCategoryWith(categoryName);
if (null != element) {
WebElement dragElement = element.findElement(By.className(MOVE_COMMAND));
builder.moveToElement(element).clickAndHold(dragElement).perform();
// The first move doesn't work properly so do a no-op
builder.moveByOffset(0, 0).moveByOffset(0, offset * CATEGORY_INPUT_HEIGHT_PX).perform();
wait.forX(Duration.ofMillis(100));
builder.release().perform();
}
}
}

代码示例来源:origin: com.daveayan/gherkinsalad.core

public void select_upto(Element other_element) {
Actions actiOns= new Actions(browser.driver());

actions.moveToElement(_nativeWebElement()).build().perform();
wait_between_steps_plus(1);

actions.clickAndHold(_nativeWebElement()).build().perform();
wait_between_steps_plus(1);

actions.moveToElement(other_element._nativeWebElement()).build().perform();
wait_between_steps_plus(1);

actions.release().build().perform();
}

推荐阅读
author-avatar
劳允旭易文忠名
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有