Example usage for org.openqa.selenium.interactions Actions moveToElement

List of usage examples for org.openqa.selenium.interactions Actions moveToElement

Introduction

In this page you can find the example usage for org.openqa.selenium.interactions Actions moveToElement.

Prototype

public Actions moveToElement(WebElement target) 

Source Link

Document

Moves the mouse to the middle of the element.

Usage

From source file:org.finra.jtaf.ewd.widget.element.InteractiveElement.java

License:Apache License

@Override
public void mouseMove() throws WidgetException {
    try {/*from  w  ww.j  a  v  a  2  s. c  o m*/
        Actions builder = new Actions(getGUIDriver().getWrappedDriver());
        synchronized (InteractiveElement.class) {
            getGUIDriver().focus();
            builder.moveToElement(getWebElement()).build().perform();
        }
    } catch (Exception e) {
        throw new WidgetException("Error while performing mouse move to", getLocator(), e);
    }
}

From source file:org.gradle.needle.selenium.BrowserFactory.java

License:Apache License

public void mouseOver(String xpath) {
    pause(stepInterval);/* w  w w  .  ja v  a 2  s .  com*/
    expectElementExistOrNot(true, xpath, timeout);
    Robot rb = null;
    try {
        rb = new Robot();
    } catch (AWTException e) {
        e.printStackTrace();
    }
    rb.mouseMove(0, 0);

    WebElement we = browserCore.findElement(By.xpath(xpath));
    if (GlobalSettings.browserCoreType == 2) {
        try {
            Actions builder = new Actions(browserCore);
            builder.moveToElement(we).build().perform();
        } catch (Exception e) {
            e.printStackTrace();
            handleFailure(" " + xpath);
        }

        logger.info(" " + xpath);
        return;
    }

    if (GlobalSettings.browserCoreType == 1 || GlobalSettings.browserCoreType == 3) {
        for (int i = 0; i < 5; i++) {
            Actions builder = new Actions(browserCore);
            builder.moveToElement(we).build().perform();
        }
        logger.info("  " + xpath);
        return;
    }

    if (GlobalSettings.browserCoreType == 4) {
        Assert.fail("Safari");
    }
    Assert.fail("");
}

From source file:org.jitsi.meet.test.DisplayNameTest.java

License:Apache License

/**
 * Check whether name has changed locally.
 * @param newName the name we changed/*  w  ww  .j a v a2s.co m*/
 */
public void doLocalDisplayNameCheck(String newName) {
    System.err.println("Start doLocalDisplayNameCheck for " + newName + ".");

    WebDriver secondParticipant = ConferenceFixture.getSecondParticipant();

    // make sure we hover over other element first, cause when hovering
    // local element we may not out of it when editing
    WebElement remoteVideoElem = secondParticipant.findElement(By
            .xpath("//span[@id='participant_" + MeetUtils.getResourceJid(ConferenceFixture.getOwner()) + "']"));
    Actions action0 = new Actions(secondParticipant);
    action0.moveToElement(remoteVideoElem);
    action0.perform();

    // now lets check whether display name is set locally
    WebElement displayNameElem = secondParticipant
            .findElement(By.xpath("//span[@id='localVideoContainer']" + "//span[@id='localDisplayName']"));

    // hover over local display name
    WebElement localVideoContainerElem = secondParticipant
            .findElement(By.xpath("//span[@id='localVideoContainer']"));
    Actions action = new Actions(secondParticipant);
    action.moveToElement(localVideoContainerElem);
    action.build().perform();

    boolean isFF = ConferenceFixture.getBrowserType(secondParticipant) == ConferenceFixture.BrowserType.firefox;
    if (!isFF) {
        assertTrue("Display name not visible", displayNameElem.isDisplayed());
    }

    String displayNameText = displayNameElem.getText();
    // there is a bug in FF with hovering over elements
    // so we workaround this
    if (isFF) {
        displayNameText = displayNameElem.getAttribute("innerHTML");
    }

    if (newName != null && newName.length() > 0)
        assertTrue("Display name not changed! Content of elem is: " + displayNameText,
                displayNameText.contains(newName));
    else
        assertTrue("Display name is not removed! (" + displayNameText + ")",
                displayNameText.equals(DEFAULT_DISPLAY_NAME));
}

From source file:org.jitsi.meet.test.DisplayNameTest.java

License:Apache License

/**
 * Check whether name has changed remotely.
 * @param newName the name we changed// w  ww .j  a  v  a  2 s .c o  m
 */
public void doRemoteDisplayNameCheck(String newName) {
    System.err.println("Start doRemoteDisplayNameCheck for " + newName + ".");

    WebDriver owner = ConferenceFixture.getOwner();
    WebDriver secondParticipant = ConferenceFixture.getSecondParticipant();

    // first when checking make sure we click on video so we avoid
    // the situation of dominant speaker detection and changing display
    MeetUIUtils.clickOnRemoteVideo(owner, MeetUtils.getResourceJid(secondParticipant));

    final String secondParticipantResourceJid = MeetUtils.getResourceJid(secondParticipant);

    WebElement localVideoWrapperElem = owner
            .findElement(By.xpath("//span[@id='participant_" + secondParticipantResourceJid + "']"));
    Actions action = new Actions(owner);
    action.moveToElement(localVideoWrapperElem);
    action.perform();

    checkRemoteVideoForName(owner, secondParticipant, newName);

    MeetUIUtils.clickOnRemoteVideo(owner, MeetUtils.getResourceJid(secondParticipant));
}

From source file:org.jitsi.meet.test.DisplayNameTest.java

License:Apache License

/**
 * Changes the display name./*  w  w w. ja va  2 s  .  c o  m*/
 * @param newName the name to change.
 */
private void changeDisplayName(String newName) {
    System.err.println("Start changeDisplayName for " + newName + ".");

    WebDriver secondParticipant = ConferenceFixture.getSecondParticipant();

    WebElement elem = secondParticipant
            .findElement(By.xpath("//span[@id='localVideoContainer']" + "//span[@id='localDisplayName']"));
    // hover the element before clicking
    Actions action0 = new Actions(secondParticipant);
    action0.moveToElement(elem);
    action0.perform();

    elem.click();

    WebElement inputElem = secondParticipant
            .findElement(By.xpath("//span[@id='localVideoContainer']" + "//input[@id='editDisplayName']"));
    Actions action = new Actions(secondParticipant);
    action.moveToElement(inputElem);
    action.perform();

    if (newName != null && newName.length() > 0)
        inputElem.sendKeys(newName);
    else
        inputElem.sendKeys(Keys.BACK_SPACE);

    inputElem.sendKeys(Keys.RETURN);
    // just click somewhere to lose focus, to make sure editing has ended
    String ownerResource = MeetUtils.getResourceJid(ConferenceFixture.getOwner());
    MeetUIUtils.clickOnRemoteVideo(secondParticipant, ownerResource);
    MeetUIUtils.clickOnRemoteVideo(secondParticipant, ownerResource);
}

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 . jav  a  2 s  .com
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.jitsi.meet.test.OneOnOneTest.java

License:Apache License

/**
 * Tests remote videos in filmstrip stay visible when hovering over when the
 * filmstrip is hovered over.//from  w  w  w .  j  ava2 s .  c  o m
 */
@Test(dependsOnMethods = { "testFilmstripVisibleOnSelfViewFocus" })
public void testFilmstripHoverShowsVideos() {
    Participant participant1 = getParticipant1();
    WebDriver driver1 = participant1.getDriver();

    WebElement toolbar = driver1.findElement(By.id("localVideoContainer"));
    Actions hoverOnToolbar = new Actions(driver1);
    hoverOnToolbar.moveToElement(toolbar);
    hoverOnToolbar.perform();

    verifyRemoteVideosDisplay(participant1, true);
}

From source file:org.jitsi.meet.test.util.MeetUIUtils.java

License:Apache License

/**
 * Opens the contact list panel, if not open.
 *
 * @param participant <tt>WebDriver</tt> instance of the participant for
 * whom we'll try to open the contact list panel.
 * @throws TimeoutException if we fail to open the contact list panel
 *///from w  w w. j ava  2  s.c o  m
public static void displayContactListPanel(WebDriver participant) {
    String contactListXPath = "//div[@id='contacts_container']";
    WebElement contactList = participant.findElement(By.xpath(contactListXPath));

    if (!contactList.isDisplayed()) {
        clickOnToolbarButton(participant, "toolbar_contact_list");

        TestUtils.waitForDisplayedElementByXPath(participant, contactListXPath, 5);
    }

    // move away from the button as user will do, to remove the tooltips
    Actions action = new Actions(participant);
    action.moveToElement(participant.findElement(By.id("largeVideoWrapper")));
    action.perform();
}

From source file:org.jitsi.meet.test.web.WebParticipant.java

License:Apache License

/**
 * {@inheritDoc}//from  w  w  w. j a v  a  2  s  .  c om
 */
@Override
public void setDisplayName(String name) {
    WebDriver driver = getDriver();

    WebElement elem = driver
            .findElement(By.xpath("//span[@id='localVideoContainer']" + "//span[@id='localDisplayName']"));
    // hover the element before clicking
    Actions actions = new Actions(driver);
    actions.moveToElement(elem);
    actions.perform();

    elem.click();

    WebElement inputElem = driver
            .findElement(By.xpath("//span[@id='localVideoContainer']" + "//input[@id='editDisplayName']"));
    actions = new Actions(driver);
    actions.moveToElement(inputElem);
    actions.perform();

    if (name != null && name.length() > 0) {
        inputElem.sendKeys(name);
    } else {
        inputElem.sendKeys(Keys.BACK_SPACE);
    }

    inputElem.sendKeys(Keys.RETURN);
    // just click somewhere to lose focus, to make sure editing has ended
    MeetUIUtils.clickOnLocalVideo(driver);
}

From source file:org.jitsi.meet.test.web.WebParticipant.java

License:Apache License

/**
 * {@inheritDoc}/* w  w  w  .j  a  v  a2 s  .  c om*/
 */
@Override
public void pressShortcut(Character shortcut) {
    // We've observed intermittent failures with the keys being sent to the
    // wrong element (e.g. the chat input field). Selecting "body" instead
    // of another element seems to make this condition appear less often.
    WebDriver driver = getDriver();
    WebElement body = driver.findElement(By.tagName("body"));
    Actions actions = new Actions(driver);
    actions.moveToElement(body);
    actions.sendKeys(body, shortcut.toString());
    actions.perform();
}