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

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

Introduction

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

Prototype

public Action build() 

Source Link

Document

Generates a composite action containing all actions so far, ready to be performed (and resets the internal builder state, so subsequent calls to #build() will contain fresh sequences).

Usage

From source file:org.safs.selenium.webdriver.lib.WDLibrary.java

License:Open Source License

/**
 * Perform a left-drag from start point to end point relative to webelement (LeftUp corner).
 * @param we WebElement, the component relative to which to drag
 * @param start Point, the start point relative to the webelement
 * @param end Point, the end point relative to the webelement
 * @throws SeleniumPlusException//from  w w  w  . j av a2s . com
 */
public static void leftDrag(WebElement we, Point start, Point end) throws SeleniumPlusException {
    String debugmsg = StringUtils.debugmsg(false);

    try {
        IndependantLog.debug(debugmsg + " drag from " + start + " to " + end + " relative to webelement.");
        translatePoints(we, start, end);
        Robot.leftDrag(start, end);

    } catch (Exception e) {
        IndependantLog.warn(debugmsg + "Failed to drag by SAFS Robot: " + StringUtils.debugmsg(e));
        IndependantLog.debug(debugmsg + "Try to drag by Selenium API.");

        try {
            Actions actions = new Actions(lastUsedWD);
            actions = actions.moveToElement(we, start.x, start.y);
            actions = actions.clickAndHold().moveByOffset((end.x - start.x), (end.y - start.y)).release();
            actions.build().perform();
        } catch (Exception e1) {
            IndependantLog.warn(debugmsg + "Failed to drag by Selenium API: " + StringUtils.debugmsg(e1));
            throw new SeleniumPlusException("Failed to drag.");
        }
    }
}

From source file:org.sonarqube.qa.util.pageobjects.measures.MeasuresPage.java

License:Open Source License

public MeasuresPage backShortcut() {
    SelenideElement panel = Selenide.$(".layout-page-header-panel");

    // panel.sendKeys(Keys.LEFT) does not work correctly on Chrome
    // The workaround is to use Actions
    // https://bugs.chromium.org/p/chromedriver/issues/detail?id=35
    Actions actions = new Actions(WebDriverRunner.getWebDriver());
    actions.moveToElement(panel);//w  w  w  .java2s . co  m
    actions.click();
    actions.sendKeys(Keys.LEFT);
    actions.build().perform();
    return this;
}

From source file:renascere.Renascere.java

License:Open Source License

/**
 * @Description Method that send an ACTION to a selected object
 *///w  w  w.j  av  a  2s. co  m
public static void performAction(tAction uiAction, String sValue, WebDriver driver, WebElement wElement) {
    try {
        Actions actions = new Actions(driver);
        actions.moveToElement(wElement);
        actions.click();
        pauseExecution(Global.fTimeQSecond);
        switch (uiAction) {
        case ENTER:
            actions.sendKeys(sValue);
            actions.build().perform();
            break;
        case SELECT:
            actions.sendKeys(sValue);
            actions.build().perform();
            pauseExecution(Global.fTimeQSecond);
            actions.sendKeys(Keys.ENTER);
            actions.build().perform();
            break;
        case CHOOSE:
            actions.sendKeys(sValue);
            actions.sendKeys(Keys.ENTER);
            actions.build().perform();
            pauseExecution(Global.fTimeQSecond);
            break;
        default:
            break;
        }
        return;
    } catch (Exception e) {
        frmError("performing action " + uiAction + " with: " + sValue, e.getMessage(), severity.HIGH);
    }
}

From source file:TBR.Regression_Testcases.CreateNewCandidate.java

@Test(dataProvider = "getCreateNewCandidateData")
public void createNewCandidate(Hashtable<String, String> data) throws InterruptedException {
    openBrowser();//from  w  w w  .jav a 2 s  . c  o m
    driver.get(CONFIG.getProperty("testSiteName"));
    login_Valid();
    //login_Kevin();
    getObject("candLinkX").click();
    getObject("addNewCandidateX").click();
    waitForElementClickableId(10, "candidateNameId");
    //waitForElementClickableId(10, "candidateNameId");

    //moves on to step 1 Basic Information
    //explicitWaitId("candidateNameId");
    getObjectById("candidateNameId").sendKeys(data.get("CandidateName"));
    Thread.sleep(5000);
    String candidateName = getObjectById("candidateNameId").getAttribute("value");
    System.out.println("name of the new candidate is= " + candidateName);
    getObjectById("candidateEmailId").sendKeys(data.get("CandidateEmail"));
    getObjectById("candidatePhoneNumberId").sendKeys(data.get("PhoneNumber"));
    /*getObject("candidateMonthX").sendKeys(data.get("DobMonth"));
    //getObjectById("candidateYearX").click();
    getObject("candidateYearX").sendKeys(data.get("DobYear"));
    getObject("candidateDayDateX").click();*/
    getObjectById("candidateDobId").click();
    Thread.sleep(5000);
    Select yearDob = new Select(getObject("candidateYearX"));
    yearDob.selectByValue("2009");
    Select monthDob = new Select(getObjectByCss("candidateMonthCSS"));
    monthDob.selectByVisibleText("Oct");
    getObject("candidateDayDateX").click();
    getObjectById("candidateAddressId").click();
    getObjectById("candidateAddressId").sendKeys(data.get("CandidateAddress"));
    Actions hover = new Actions(driver);
    WebElement elementToHover = getObject("candidateNextStep1X");
    hover.moveToElement(elementToHover);
    hover.build().perform();
    Thread.sleep(3000);
    getObject("candidateNextStep1X").click();

    //moving on to Step 2 LogIn Details
    getObjectById("candidateUsernameId").sendKeys(data.get("CandidateUsername"));
    getObjectById("candidatePasswordId").sendKeys(data.get("CandidatePassword"));
    Actions hove = new Actions(driver);
    WebElement elementToHov = getObject("candidateNextStep1X");
    hove.moveToElement(elementToHov);
    hove.build().perform();
    //getObjectByCss("candidateNextStepCss").click();

    Actions hover3 = new Actions(driver);
    WebElement elementToHover3 = getObjectByCss("candidateNextStepCss");
    hover3.moveToElement(elementToHover3);
    hover3.build().perform();
    Thread.sleep(4000);
    getObjectByCss("candidateNextStepCss").click();
    System.out.println("clicked on next in step 2");

    //moving on to Step 3 Employment Information
    waitForElementClickableId(10, "candidateNiNumberId");
    getObjectById("candidateNiNumberId").sendKeys(data.get("NiNumber"));
    getObjectById("candidateStatusId").sendKeys(data.get("CandidateStatus"));
    getObject("candidateNextStep3X").click();

    //moving on to Step 4 Social Media (Optional)
    getObjectById("candidateFacebookId").sendKeys(data.get("Facebook"));
    getObjectById("candidateTwitterId").sendKeys(data.get("Twitter"));
    getObjectById("candidateLinkedinId").sendKeys(data.get("LinkedIn"));
    getObjectById("candidateSkypeId").sendKeys(data.get("Skype"));
    getObject("candidateNextStep4X").click();

    //moving on to Step 5 Criteria
    getObject("candidateCategoryX").click();
    getObject("candidateCategoryX").sendKeys(data.get("Category"));
    getObject("candidateCategoryX").sendKeys(Keys.RETURN);
    //Thread.sleep(3000);
    /*the below two lines are for live server*/
    //getObjectById("candidateLicenseId").click();
    //getObjectById("candidateLicenseId").sendKeys(data.get("driverlicense"));
    //getObjectById("candidateLicenseId").sendKeys(Keys.RETURN);
    /*end of live server code*/
    getObject("candidateCustomAttributeShowX").click();
    explicitWaitId("candidatePassportId");
    getObjectById("candidatePassportId").click();
    Select month = new Select(getObject("candidatePassportMonthX"));
    month.selectByVisibleText("Oct");
    Select year = new Select(getObject("candidatePassportYearX"));
    year.selectByValue("2020");
    getObject("candidatePassportDateX").click();
    Thread.sleep(5000);
    getObjectById("candidateManualCertId").click();
    Select month1 = new Select(getObject("candidateManualMonthX"));
    month1.selectByVisibleText("Jul");
    Select year1 = new Select(getObject("candidateManualYearX"));
    year1.selectByValue("2015");
    getObject("candidateManualDateX").click();
    getObjectById("candidateGardaVettingId").sendKeys(data.get("GardaVetting"));
    getObjectById("candidateTrainingId").sendKeys(data.get("TrainingComplete"));
    getObjectById("candidateProofOfRightToWorkId").sendKeys(data.get("ProofRightToWork"));
    getObjectById("candidateCertificationExpiry").click();
    Select month2 = new Select(getObject("candidateCertificationMonthX"));
    month2.selectByVisibleText("Sep");
    Select year2 = new Select(getObject("candidateCertificationYearX"));
    year2.selectByValue("2018");
    getObject("candidateCertificationDateX").click();
    getObject("candidateFinishStep5X").click();
    Thread.sleep(10000);
    explicitWaitXpath("candLinkX");
    //back to dash board
    //getObject("candLinkX").click();
    //explicitWaitXpath("allCandidatesX");
    getObject("allCandidatesX").click();
    //moves on to candidate list wizard
    //explicitWaitXpath("searchCandidateX");
    getObject("searchCandidateX").click();
    //explicitWaitXpath("searchCandidateX");
    getObject("searchCandidateX").sendKeys(candidateName);

    //explicitWaitXpath("candidateMatchX");
    Thread.sleep(5000);
    String candidateNameAppeared = getObject("candidateMatchX").getText();
    System.out.println("candidate appeared on the screen is = " + candidateNameAppeared);
    Assert.assertEquals(candidateNameAppeared, candidateName);
    System.out.println("new candidate saved successfully");
}

From source file:uk.ac.ebi.atlas.acceptance.selenium.pages.HeatmapTablePage.java

License:Apache License

protected void hoverOnElement(WebElement webElement) {
    Action builder;//from ww  w.  ja v a 2 s .c o m
    Actions hover = new Actions(driver);
    hover.moveToElement(webElement);
    builder = hover.build();
    builder.perform();
}