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

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

Introduction

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

Prototype

public void perform() 

Source Link

Document

A convenience method for performing the actions without calling build() first.

Usage

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
 *///w w w.j  av a2  s . c  om
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 www .  jav a  2s  .  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 ww.  j  a va  2 s . com*/
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}// w ww  . jav  a  2  s .c  o  m
 */
@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}/*from   w  w  w  . ja va2s.c o m*/
 */
@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();
}

From source file:org.kuali.rice.testtools.selenium.WebDriverAftBase.java

License:Educational Community License

/**
 * {@link org.openqa.selenium.interactions.Actions#moveToElement(org.openqa.selenium.WebElement)}
 * @param by//from   w w  w.  j a va  2s .  co m
 */
public void fireMouseOverEvent(By by) {
    Actions builder = new Actions(driver);
    Actions hover = builder.moveToElement(findElement(by));
    hover.perform();
}

From source file:org.mousephenotype.cda.selenium.support.SearchAnatomyTable.java

License:Apache License

/**
 * Pulls <code>numRows</code> rows of search page gene facet data and column access variables from the search page's
 * 'maGrid' HTML table./*from   w w  w. j a v a  2s .  co  m*/
 *
 * @param numRows the number of <code>GridMap</code> table rows to return, including the heading row. To specify all
 *                rows, set <code>numRows</code> to null.
 *
 * @return <code>numRows</code> rows of search page gene facet data and column access variables from the search
 * page's 'diseaseGrid' HTML table.
 */
private GridMap load(Integer numRows) {
    if (numRows == null)
        numRows = computeTableRowCount();

    String[][] pageArray;

    // Wait for page.
    wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("table#maGrid")));
    int numCols = COL_INDEX_LAST + 1;

    pageArray = new String[numRows][numCols]; // Allocate space for the data.
    for (int i = 0; i < numCols; i++) {
        pageArray[0][i] = "Column_" + i; // Set the headings.
    }

    // Save the body values.
    List<WebElement> bodyRowElementsList = table.findElements(By.cssSelector("tbody tr"));
    if (!bodyRowElementsList.isEmpty()) {
        int sourceRowIndex = 1;

        pageArray[sourceRowIndex][COL_INDEX_ANATOMY_TERM] = ""; // Insure there is always a non-null value.
        pageArray[sourceRowIndex][COL_INDEX_ANATOMY_ID] = ""; // Insure there is always a non-null value.
        pageArray[sourceRowIndex][COL_INDEX_ANATOMY_ID_LINK] = ""; // Insure there is always a non-null value.
        pageArray[sourceRowIndex][COL_INDEX_ANATOMY_SYNONYMS] = ""; // Insure there is always a non-null value.

        for (WebElement bodyRowElements : bodyRowElementsList) {
            AnatomyRow anatomyRow = new AnatomyRow();
            List<WebElement> bodyRowElementList = bodyRowElements.findElements(By.cssSelector("td"));
            WebElement anatomyColElement = bodyRowElementList.get(0);
            WebElement anatomyColAnchorElement = bodyRowElementList.get(0).findElement(By.cssSelector("a"));

            // In order to see the contents of the span, we need to first bring the anatomy term into view, then
            // hover over it.
            Actions builder = new Actions(driver);
            try {
                testUtils.scrollToTop(driver, anatomyColElement, -50); // Scroll anatomy term into view.
                Actions hoverOverTerm = builder.moveToElement(anatomyColElement);
                hoverOverTerm.perform();

                anatomyRow.anatomyIdLink = anatomyColAnchorElement.getAttribute("href"); // anatomyIdLink
                int pos = anatomyRow.anatomyIdLink.lastIndexOf("/");
                anatomyRow.anatomyTerm = anatomyColAnchorElement.getText(); // anatomyTerm
                anatomyRow.anatomyId = anatomyRow.anatomyIdLink.substring(pos + 1); // anatomyId

                List<WebElement> subinfoElement = bodyRowElementList.get(0)
                        .findElements(By.cssSelector("div.subinfo"));
                if (!subinfoElement.isEmpty()) {
                    String[] parts = subinfoElement.get(0).getText().split(":");
                    switch (parts[0].trim().toLowerCase()) {
                    case "synonym":
                        // This handles a single synonym only. Multiple synonyms pass through this path but parts[1] has a newline in that case.
                        if ((parts.length > 1) && (!parts[1].contains("\n"))) {
                            anatomyRow.synonyms.add(parts[1].trim()); // single synonym
                        }

                    default:
                        break;
                    }
                }

                List<WebElement> synonymElements = bodyRowElementList.get(0)
                        .findElements(By.cssSelector("ul.synonym li")); // Look for multiple synonyms.
                for (WebElement synonymElement : synonymElements) {
                    anatomyRow.synonyms.add(synonymElement.getText().trim());
                }

            } catch (Exception e) {
                logger.error("EXCEPTION: SearchAnatomyTable.load() while waiting to hover. Error message: "
                        + e.getLocalizedMessage());
                e.printStackTrace();
            }

            pageArray[sourceRowIndex][COL_INDEX_ANATOMY_TERM] = anatomyRow.anatomyTerm;
            pageArray[sourceRowIndex][COL_INDEX_ANATOMY_ID] = anatomyRow.anatomyId;
            pageArray[sourceRowIndex][COL_INDEX_ANATOMY_ID_LINK] = anatomyRow.anatomyIdLink;
            pageArray[sourceRowIndex][COL_INDEX_ANATOMY_SYNONYMS] = StringUtils.join(anatomyRow.synonyms, "|");

            sourceRowIndex++;
            bodyRows.add(anatomyRow);
        }
    }

    return new GridMap(pageArray, target);
}

From source file:org.mousephenotype.cda.selenium.support.SearchDiseaseTable.java

License:Apache License

/**
 * Pulls <code>numRows</code> rows of search page gene facet data and column access variables from the search page's
 * 'diseaseGrid' HTML table.//from   w w w.j a  v a  2s .  c o  m
 *
 * @param numRows the number of <code>GridMap</code> table rows to return, including the heading row. To specify all
 *                rows, set <code>numRows</code> to null.
 *
 * @return <code>numRows</code> rows of search page gene facet data and column access variables from the search
 * page's 'diseaseGrid' HTML table.
 */
private GridMap load(Integer numRows) {
    if (numRows == null)
        numRows = computeTableRowCount();

    String[][] pageArray;

    // Wait for page.
    wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("table#diseaseGrid")));
    int numCols = COL_INDEX_LAST + 1;

    pageArray = new String[numRows][numCols]; // Allocate space for the data.
    for (int i = 0; i < numCols; i++) {
        pageArray[0][i] = "Column_" + i; // Set the headings.
    }

    // Save the body values.
    List<WebElement> bodyRowElementsList = table.findElements(By.cssSelector("tbody tr"));
    if (!bodyRowElementsList.isEmpty()) {
        int sourceRowIndex = 1;

        // Insure there is always a non-null value.
        pageArray[sourceRowIndex][COL_INDEX_DISEASE_ID] = "";
        pageArray[sourceRowIndex][COL_INDEX_DISEASE_ID_LINK] = "";
        pageArray[sourceRowIndex][COL_INDEX_DISEASE_NAME] = "";
        pageArray[sourceRowIndex][COL_INDEX_SOURCE] = "";
        pageArray[sourceRowIndex][COL_INDEX_CURATED_HUMAN_OMIM] = "";
        pageArray[sourceRowIndex][COL_INDEX_CURATED_MOUSE_MGI] = "";
        pageArray[sourceRowIndex][COL_INDEX_CANDIDATE_IMPC] = "";
        pageArray[sourceRowIndex][COL_INDEX_CANDIDATE_MGI] = "";

        for (WebElement bodyRowElements : bodyRowElementsList) {
            DiseaseRow diseaseRow = new DiseaseRow();
            List<WebElement> bodyRowElementList = bodyRowElements.findElements(By.cssSelector("td"));
            WebElement diseaseColElement = bodyRowElementList.get(0);
            WebElement diseaseColAnchorElement = bodyRowElementList.get(0).findElement(By.cssSelector("a"));

            // In order to see the contents of the span, we need to first bring the anatomy term into view, then
            // hover over it.
            Actions builder = new Actions(driver);
            try {
                testUtils.scrollToTop(driver, diseaseColElement, -50); // Scroll disease term into view.
                Actions hoverOverTerm = builder.moveToElement(diseaseColElement);
                hoverOverTerm.perform();

                diseaseRow.diseaseIdLink = diseaseColAnchorElement.getAttribute("href");
                int pos = diseaseRow.diseaseIdLink.lastIndexOf("/");
                diseaseRow.diseaseId = diseaseRow.diseaseIdLink.substring(pos + 1);
                diseaseRow.diseaseName = diseaseColAnchorElement.getText();
                diseaseRow.source = bodyRowElementList.get(1).getText();

                diseaseRow.curatedHumanOmim = bodyRowElements.findElements(By.cssSelector("span.curatedHuman"))
                        .isEmpty() ? false : true;
                diseaseRow.curatedMouseMgi = bodyRowElements.findElements(By.cssSelector("span.curatedMice"))
                        .isEmpty() ? false : true;
                diseaseRow.candidateImpc = bodyRowElements.findElements(By.cssSelector("span.candidateImpc"))
                        .isEmpty() ? false : true;
                diseaseRow.candidateMgi = bodyRowElements.findElements(By.cssSelector("span.candidateMgi"))
                        .isEmpty() ? false : true;

            } catch (Exception e) {
                logger.error("EXCEPTION: SearchAnatomyTable.load() while waiting to hover. Error message: "
                        + e.getLocalizedMessage());
                e.printStackTrace();
            }

            pageArray[sourceRowIndex][COL_INDEX_DISEASE_ID] = diseaseRow.diseaseId;
            pageArray[sourceRowIndex][COL_INDEX_DISEASE_ID_LINK] = diseaseRow.diseaseIdLink;
            pageArray[sourceRowIndex][COL_INDEX_DISEASE_NAME] = diseaseRow.diseaseName;
            pageArray[sourceRowIndex][COL_INDEX_SOURCE] = diseaseRow.source;
            pageArray[sourceRowIndex][COL_INDEX_CURATED_HUMAN_OMIM] = (diseaseRow.curatedHumanOmim ? "true"
                    : "false");
            pageArray[sourceRowIndex][COL_INDEX_CURATED_MOUSE_MGI] = (diseaseRow.curatedMouseMgi ? "true"
                    : "false");
            pageArray[sourceRowIndex][COL_INDEX_CANDIDATE_IMPC] = (diseaseRow.candidateImpc ? "true" : "false");
            pageArray[sourceRowIndex][COL_INDEX_CANDIDATE_MGI] = (diseaseRow.candidateMgi ? "true" : "false");

            sourceRowIndex++;
            bodyRows.add(diseaseRow);
        }
    }

    return new GridMap(pageArray, target);
}

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);/*w  w  w.  j a  v a  2s.c  om*/
    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.j  a  v a  2  s .  c  o m
    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);
}