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.alfresco.po.share.search.PreViewPopUpPage.java

License:Open Source License

/**
 * Select close button./*from   www . j ava2 s . c  o m*/
 * 
 * @return {@link FacetedSearchPage} page response
 */
public HtmlPage selectClose() {
    closeButton = driver.findElement(PREVIEW_CLOSE_BUTTON);
    Actions a = new Actions(driver);
    a.moveToElement(closeButton);
    a.click();
    a.perform();
    driver.findElements(PREVIEW_CLOSE_BUTTON);
    return factoryPage.instantiatePage(driver, FacetedSearchPage.class);
}

From source file:org.alfresco.po.share.SharePage.java

License:Open Source License

/**
 * Accept inputs from keyborad on page level.
 * /*www  .jav a  2  s .  com*/
 * @param inputs Keys...
 */
public void inputFromKeyborad(Keys... inputs) {
    Actions actions = new Actions(driver);
    actions.sendKeys(inputs);
    actions.perform();
}

From source file:org.apache.archiva.web.test.RepositoryAdminTest.java

License:Apache License

@Test
public void testManagedRepository() {
    // login( getAdminUsername(), getAdminPassword() );
    WebDriverWait wait = new WebDriverWait(getWebDriver(), 20);
    WebElement el;//from w  ww  .j  a  v a2  s . co m
    el = wait.until(ExpectedConditions.elementToBeClickable(By.id("menu-repositories-list-a")));
    tryClick(el, ExpectedConditions.presenceOfElementLocated(By.id("managed-repositories-view-a")),
            "Managed Repositories not activated");
    el = wait.until(
            ExpectedConditions.elementToBeClickable(By.xpath("//a[@href='#remote-repositories-content']")));
    tryClick(el,
            ExpectedConditions.visibilityOfElementLocated(
                    By.xpath("//table[@id='remote-repositories-table']//td[contains(text(),'central')]")),
            "Remote Repositories View not available");
    el = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//a[@href='#remote-repository-edit']")));
    el = tryClick(el, ExpectedConditions.visibilityOfElementLocated(By.id("remote-repository-save-button")),
            "Repository Save Button not available");

    setFieldValue("id", "myrepoid");
    setFieldValue("name", "My repo name");
    setFieldValue("url", "http://www.repo.org");

    el = wait.until(ExpectedConditions.elementToBeClickable(By.id("remote-repository-save-button")));
    Actions actions = new Actions(getWebDriver());
    actions.moveToElement(el);
    actions.perform();
    ((JavascriptExecutor) getWebDriver()).executeScript("arguments[0].scrollIntoView();", el);
    el.click();
    el = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("remote-repositories-view-a")));
    ((JavascriptExecutor) getWebDriver()).executeScript("arguments[0].scrollIntoView();", el);
    tryClick(By.id("menu-proxy-connectors-list-a"),
            ExpectedConditions
                    .visibilityOfElementLocated(By.id("proxy-connectors-view-tabs-a-network-proxies-grid")),
            "Network proxies not available", 3, 10);
    wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("main-content"), "Proxy Connectors"));
    // proxy connect
    wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("proxy-connectors-view"), "central"));
    assertTextNotPresent("myrepoid");
    el = wait.until(ExpectedConditions.elementToBeClickable(By.id("proxy-connectors-view-tabs-a-edit")));
    el.click();
    el = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("proxy-connector-btn-save")));
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("remote-repository-edit-fieldset")));
    // Another hack, don't know why the normal selectValue() does not work here
    ((JavascriptExecutor) getWebDriver()).executeScript("jQuery('#sourceRepoId').css('display','block')");
    Select select = new Select(getWebDriver().findElement(By.xpath(".//select[@id='sourceRepoId']")));
    select.selectByVisibleText("internal");
    // selectValue( "sourceRepoId", "internal", true );
    // Workaround
    // TODO: Check after upgrade of htmlunit, bootstrap or jquery
    // TODO: Check whats wrong here
    ((JavascriptExecutor) getWebDriver()).executeScript("$('#targetRepoId').show();");
    // End of Workaround
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("targetRepoId")));
    selectValue("targetRepoId", "myrepoid");
    el.click();
    wait.until(
            ExpectedConditions.textToBePresentInElementLocated(By.id("user-messages"), "ProxyConnector added"));
    wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("proxy-connectors-view"), "central"));
    wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("proxy-connectors-view"), "myrepoid"));

    tryClick(By.xpath("//i[contains(@class,'icon-resize-vertical')]//ancestor::a"),
            ExpectedConditions.visibilityOfAllElementsLocatedBy(By.id("proxy-connector-edit-order-div")),
            "Edit order view not visible", 3, 10);
    // clickLinkWithXPath( "//i[contains(@class,'icon-resize-vertical')]//ancestor::a");
    // This is needed here for HTMLUnit Tests. Currently do not know why, wait is not working for the
    // list entries down
    // waitPage();
    // el = wait.until(ExpectedConditions.presenceOfElementLocated(By.id("proxy-connector-edit-order-div")));
    assertTextPresent("internal");
    List<WebElement> repos = wait.until(ExpectedConditions
            .numberOfElementsToBe(By.xpath("//div[@id='proxy-connector-edit-order-div']/div"), 2));
    Assert.assertTrue("First repo is myrepo", repos.get(0).getText().contains("myrepoid"));
    Assert.assertTrue("Second repo is central", repos.get(1).getText().contains("central"));

    // works until this point
    /*getSelenium().mouseDown( "xpath=//div[@id='proxy-connector-edit-order-div']/div[1]" );
    getSelenium().mouseMove( "xpath=//div[@id='proxy-connector-edit-order-div']/div[2]" );
    getSelenium().mouseUp( "xpath=//div[@id='proxy-connector-edit-order-div']/div[last()]" );
    Assert.assertTrue( "Second repo is myrepo", getSelenium().getText("xpath=//div[@id='proxy-connector-edit-order-div']/div[2]" ).contains( "myrepoid" ));
    Assert.assertTrue( "First repo is central", getSelenium().getText("xpath=//div[@id='proxy-connector-edit-order-div']/div[1]" ).contains( "central" ));
    */
}

From source file:org.eclipse.che.ide.ext.datasource.itests.NewDatasourceWizard.java

License:Open Source License

public String clickOnHostedDatabaseCategory() {
    WebElement category = newDatasourceWizard.getHostedDatabaseCategoryElement();
    Actions action = new Actions(driver);
    action.doubleClick(category);/*from  w  w w. j  a  v a2 s  .  c o  m*/
    action.perform();
    return "unfolds";
}

From source file:org.eclipse.che.ide.ext.datasource.itests.NewDatasourceWizard.java

License:Open Source License

public String clickOnGoogleCategory() {
    WebElement category = newDatasourceWizard.getGoogleCategoryElement();
    Actions action = new Actions(driver);
    action.doubleClick(category);//  ww w . j  ava2  s  .  c  o m
    action.perform();
    return "unfolds";
}

From source file:org.eclipse.che.ide.ext.datasource.itests.NewDatasourceWizard.java

License:Open Source License

public String clickOnAmazonCategory() {
    WebElement category = newDatasourceWizard.getAmazonCategoryElement();
    Actions action = new Actions(driver);
    action.doubleClick(category);/* w w w .j a  va  2 s . c  om*/
    action.perform();
    return "unfolds";
}

From source file:org.jboss.arquillian.graphene.ftest.enricher.TestInitializingPageFragments.java

License:Open Source License

@Test
public void testSupportForAdvancedActions() {
    Actions builder = new Actions(selenium);

    // following tests usage of Actions with injected plain WebElement
    builder.click(input);//from www .ja va2s. c o  m
    // following with List<WebElement>
    builder.click(divs.get(0));
    // following with WebElements from Page Fragments
    builder.click(abstractPageFragmentStub.getLocatorRefByXPath());
    // following with List of WebElements from Page Fragments
    builder.click(abstractPageFragmentStub.getSpansInPageFragment().get(0));

    builder.perform();
}

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 w w . j a v  a  2  s. c  o  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/* www.  jav a 2s  .  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.//from w  w w .  ja v  a  2  s  . co 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);
}