List of usage examples for org.openqa.selenium.interactions Actions release
public Actions release()
From source file:org.evilco.bot.powersweeper.game.ScreenGameInterface.java
License:Apache License
/** * {@inheritDoc}// ww w. j av a2 s. co m */ @Override public void moveToChunk(@NonNull ChunkLocation location) { getLogger().entry(); // check whether sane movement is possible if (this.chunkLocation != null) { // calculate distance ChunkLocation distance = this.chunkLocation.getDistance(location); ChunkLocation distanceSanitized = new ChunkLocation(distance); distanceSanitized.sanitize(); // verify whether sane movement is possible if (distanceSanitized.getX() <= SANE_MOVEMENT_THRESHOLD && distanceSanitized.getY() <= SANE_MOVEMENT_THRESHOLD) { // calculate distance long x = ((this.chunk.getWidth() * CELL_SIZE) * distance.getX()); long y = ((this.chunk.getHeight() * CELL_SIZE) * distance.getY()); // verify if (x > Integer.MAX_VALUE || y > Integer.MAX_VALUE) getLogger().warn("Sane movement threshold of " + SANE_MOVEMENT_THRESHOLD + " seems to be too big. Aborting."); else { // find HTML WebElement html = this.getPowersweeper().getDriverManager().getDriver() .findElement(By.tagName("html")); // build action Actions action = new Actions(this.getPowersweeper().getDriverManager().getDriver()); action.moveToElement(html, (CELL_SIZE / 2), (CELL_SIZE / 2)); action.clickAndHold(); action.moveByOffset(((int) x), ((int) y)); action.release(); // execute action.build().perform(); // wait for a few seconds try { Thread.sleep(2000); } catch (Exception ex) { getLogger().warn("Aliens wake us up to early."); } // update location this.chunkLocation = location; // force update this.update(); // trace getLogger().exit(); // skip return; } } } // open new URL this.getPowersweeper().getDriverManager().getDriver() .get(String.format(GAME_URL, location.getX(), location.getY())); // wait for a few seconds try { Thread.sleep(5000); } catch (Exception ex) { getLogger().warn("Aliens wake us up to early."); } // update location this.chunkLocation = location; // force update this.update(); // trace getLogger().exit(); }
From source file:org.jitsi.meet.test.MuteTest.java
License:Apache License
/** * Finds the menu that can be used by the owner to control the participant. * Hovers over it. Finds the mute link and mute it. * Then checks in the second participant page whether it is muted *//*from w w w. j a v a 2s. c o m*/ public void ownerMutesParticipantAndCheck() { System.err.println("Start ownerMutesParticipantAndCheck."); WebDriver owner = ConferenceFixture.getOwner(); WebDriver secondParticipant = ConferenceFixture.getSecondParticipant(); String secondParticipantResource = MeetUtils.getResourceJid(secondParticipant); WebElement cntElem = owner.findElement(By.id("participant_" + secondParticipantResource)); WebElement elem = owner.findElement(By.xpath( TestUtils.getXPathStringForClassName("//span", "remotevideomenu") + "/i[@class='icon-menu']")); Actions action = new Actions(owner); action.moveToElement(cntElem); action.moveToElement(elem); action.perform(); TestUtils.waitForDisplayedElementByXPath(owner, "//ul[@class='popupmenu']/li/a[contains(@class, 'mutelink')]", 5); owner.findElement(By.xpath("//ul[@class='popupmenu']/li/a[contains(@class, 'mutelink')]")).click(); // and now check whether second participant is muted TestUtils.waitForElementByXPath(ConferenceFixture.getSecondParticipant(), TestUtils.getXPathStringForClassName("//span", "audioMuted") + "/i[@class='icon-mic-disabled']", 5); action.release(); }
From source file:org.openecomp.sdc.ci.tests.execute.resourceui.VFCanvasTest.java
License:Open Source License
@Test public void VFCanvasTest1() throws Exception { // GeneralUIUtils.waitForContainsdataTestIdVisibility("left-sectioin-element-QA"); GeneralUIUtils.moveToStep(StepsEnum.COMPOSITION); Thread.sleep(2000);/*from w w w. j av a 2s . c o m*/ List<Integer> position = null; WebElement canvas = GeneralUIUtils.getWebElementWaitForVisible("canvas"); int xPos = 0; int yPos = 0; position = getposition(canvas, xPos, yPos); WebElement otherElement = GeneralUIUtils .getWebElementWaitForVisible("left-sectioin-element-QA left-section-NeutronPort"); for (int i = 0; i < 8; i++) { Actions builder = new Actions(GeneralUIUtils.getDriver()); Action dragAndDrop = builder.clickAndHold(otherElement) .moveToElement(canvas, position.get(0), position.get(1)).release().build(); dragAndDrop.perform(); Thread.sleep(2000); } Thread.sleep(2000); Actions builder = new Actions(GeneralUIUtils.getDriver()); builder.moveToElement(canvas, position.get(0), position.get(1)); builder.clickAndHold(); position = getposition(canvas, xPos, yPos); builder.moveToElement(canvas, position.get(0), position.get(1)); builder.release(); builder.build(); builder.perform(); builder.moveToElement(canvas, 200, 300); builder.release(); builder.perform(); }
From source file:org.openecomp.sdc.ci.tests.utilities.ServiceUIUtils.java
License:Open Source License
public void moveResourceInstanceToCanvasUI() throws Exception { List<WebElement> moveResource = driver.findElements(By.className("sprite-resource-icons")); WebElement moveResourceToCanvasResourceOne = moveResource.get(0); // WebElement moveResource = // driver.findElement(By.className("sprite-resource-icons")); Actions action = new Actions(driver); action.moveToElement(moveResourceToCanvasResourceOne); action.clickAndHold(moveResourceToCanvasResourceOne); action.moveByOffset(635, 375);//from ww w . jav a2 s.com action.release(); action.perform(); WebElement moveResourceToCanvasResourceTwo = moveResource.get(1); action.moveToElement(moveResourceToCanvasResourceTwo); action.clickAndHold(moveResourceToCanvasResourceTwo); action.moveByOffset(535, 375); action.release(); action.perform(); WebElement moveResourceToCanvasResourceTree = moveResource.get(2); action.moveToElement(moveResourceToCanvasResourceTree); action.clickAndHold(moveResourceToCanvasResourceTree); action.moveByOffset(435, 375); action.release(); action.perform(); Thread.sleep(2000); }
From source file:org.richfaces.tests.metamer.ftest.richDragIndicator.TestDragIndicator.java
License:Open Source License
@Test public void testRendered() throws InterruptedException { dragIndicatorAttributes.set(draggingClass, DRAGGING_CLASS); dragIndicatorAttributes.set(rendered, true); // before any mouse move, no indicator appears on page elementNotPresent.element(page.indicator).apply(driver); Actions actionQueue = new Actions(driver); // firstly just drag and don't move. Indicator no displayed Action dragging = actionQueue.clickAndHold(page.drag1).build(); dragging.perform();// ww w.ja va2 s. com elementNotPresent.element(page.indicator); // just small move to display indicator dragging = actionQueue.moveByOffset(1, 1).build(); dragging.perform(); assertTrue(page.indicator.isDisplayed()); assertTrue(page.indicator.getAttribute("class").contains(DRAGGING_CLASS)); // simulate drop dragging = actionQueue.release().build(); elementPresent.element(page.indicator); dragging.perform(); elementNotPresent.element(page.indicator).apply(driver); // and now the same with indicator not rendered dragIndicatorAttributes.set(rendered, false); elementNotPresent.element(page.indicator).apply(driver); // just small move to attempt display indicator dragging = actionQueue.clickAndHold(page.drag1).moveByOffset(1, 1).build(); dragging.perform(); elementNotPresent.element(page.indicator); }
From source file:org.richfaces.tests.metamer.ftest.richDragIndicator.TestDragIndicator.java
License:Open Source License
@Test public void testDragging() { dragIndicatorAttributes.set(draggingClass, DRAGGING_CLASS); dragIndicatorAttributes.set(acceptClass, ACCEPT_CLASS); Actions actionQueue = new Actions(driver); // before any mouse move, no indicator appears on page elementNotPresent.element(page.indicator).apply(driver); // firstly just drag and don't move. Indicator no displayed Action dragging = actionQueue.clickAndHold(page.drag1).build(); dragging.perform();/*from w w w.ja va2 s.c o m*/ elementNotPresent.element(page.indicator); // just small move to display indicator dragging = actionQueue.moveByOffset(1, 1).build(); dragging.perform(); assertTrue(page.indicator.isDisplayed()); assertTrue(page.indicator.getAttribute("class").contains(DRAGGING_CLASS)); // then move out of drag area (but not over drop area) dragging = actionQueue.moveByOffset(550, 10).build(); dragging.perform(); assertTrue(page.indicator.isDisplayed()); assertTrue(page.indicator.getAttribute("class").contains(DRAGGING_CLASS)); // this one as well dragging = actionQueue.release().build(); dragging.perform(); elementNotPresent.element(page.indicator); }
From source file:org.richfaces.tests.metamer.ftest.richDragIndicator.TestDragIndicator.java
License:Open Source License
@Test public void testAccepting() { dragIndicatorAttributes.set(draggingClass, DRAGGING_CLASS); dragIndicatorAttributes.set(acceptClass, ACCEPT_CLASS); Actions actionQueue = new Actions(driver); Action dragging = actionQueue.clickAndHold(page.drag1).build(); dragging.perform();/* ww w . jav a 2 s. co m*/ elementNotPresent.element(page.indicator); // just small move to display indicator dragging = actionQueue.moveByOffset(1, 1).build(); dragging.perform(); assertTrue(page.indicator.isDisplayed()); assertTrue(page.indicator.getAttribute("class").contains(DRAGGING_CLASS)); dragging = actionQueue.moveToElement(page.drop1).build(); dragging.perform(); assertTrue(page.indicator.isDisplayed()); assertTrue(page.indicator.getAttribute("class").contains(ACCEPT_CLASS)); // then release dragging = actionQueue.release().build(); dragging.perform(); elementNotPresent.element(page.indicator); }
From source file:org.richfaces.tests.metamer.ftest.richDragIndicator.TestDragIndicator.java
License:Open Source License
@Test public void testRejecting() { dragIndicatorAttributes.set(draggingClass, DRAGGING_CLASS); dragIndicatorAttributes.set(rejectClass, REJECT_CLASS); Actions actionQueue = new Actions(driver); Action dragging = actionQueue.clickAndHold(page.drag1).build(); dragging.perform();/*from w w w .java 2 s. c o m*/ elementNotPresent.element(page.indicator); // just small move to display indicator dragging = actionQueue.moveByOffset(1, 1).build(); dragging.perform(); assertTrue(page.indicator.isDisplayed()); assertTrue(page.indicator.getAttribute("class").contains(DRAGGING_CLASS)); dragging = actionQueue.moveToElement(page.drop2).build(); dragging.perform(); assertTrue(page.indicator.isDisplayed()); assertTrue(page.indicator.getAttribute("class").contains(REJECT_CLASS)); // then release dragging = actionQueue.release().build(); dragging.perform(); elementNotPresent.element(page.indicator); }
From source file:org.richfaces.tests.metamer.ftest.richDragIndicator.TestDragIndicator.java
License:Open Source License
@Test public void testMovingOverDifferentStates() { dragIndicatorAttributes.set(draggingClass, DRAGGING_CLASS); dragIndicatorAttributes.set(rejectClass, REJECT_CLASS); dragIndicatorAttributes.set(acceptClass, ACCEPT_CLASS); for (int i = 0; i <= 20; ++i) { Actions actionQueue = new Actions(driver); Action dragging = actionQueue.clickAndHold(page.drag1).build(); dragging.perform();//from ww w . j a v a 2s . co m elementNotPresent.element(page.indicator); // just small move to display indicator dragging = actionQueue.moveByOffset(1, 1).build(); dragging.perform(); assertTrue(page.indicator.isDisplayed()); assertTrue(page.indicator.getAttribute("class").contains(DRAGGING_CLASS)); // then move out of drag area (but not over drop area) dragging = actionQueue.moveByOffset(550, 10).build(); dragging.perform(); assertTrue(page.indicator.isDisplayed()); assertTrue(page.indicator.getAttribute("class").contains(DRAGGING_CLASS)); dragging = actionQueue.moveToElement(page.drop1).build(); dragging.perform(); assertTrue(page.indicator.isDisplayed()); assertTrue(page.indicator.getAttribute("class").contains(ACCEPT_CLASS)); dragging = actionQueue.moveToElement(page.drop2).build(); dragging.perform(); assertTrue(page.indicator.isDisplayed()); assertTrue(page.indicator.getAttribute("class").contains(REJECT_CLASS)); // then release dragging = actionQueue.release().build(); dragging.perform(); elementNotPresent.element(page.indicator); } }
From source file:org.richfaces.tests.metamer.ftest.richDragSource.AbstractDragSourceTest.java
License:Open Source License
public void testRendered() { dragSourceAttributes.set(dragIndicator, "indicator2"); dragSourceAttributes.set(rendered, true); // before any mouse move, no indicator appears on page elementNotPresent.element(page.indicator2).apply(driver); // indicator = new IndicatorWD(indicatorLoc); indicator = new Indicator(page.indicator2); Actions actionQueue = new Actions(driver); // firstly just drag and don't move. Indicator no displayed Action dragging = actionQueue.clickAndHold(page.drag1).build(); dragging.perform();/*from w ww .j a v a2 s. co m*/ elementNotPresent.element(page.indicator2).apply(driver); // just small move to display indicator dragging = actionQueue.moveByOffset(1, 1).build(); dragging.perform(); elementPresent.element(page.indicator2).apply(driver); dragging = actionQueue.release().build(); elementPresent.element(page.indicator2).apply(driver); dragging.perform(); elementNotPresent.element(page.indicator2).apply(driver); }