List of usage examples for org.openqa.selenium.interactions Actions moveToElement
public Actions moveToElement(WebElement target)
From source file:org.kuali.rice.krad.demo.uif.library.controls.LibraryControlCheckboxDefaultAft.java
License:Educational Community License
protected void actionSendKeysArrowDown(String id) { Actions actions = new Actions(driver); actions.moveToElement(driver.findElement(By.id(id))); actions.click();//from w ww. ja v a 2s . c om actions.sendKeys(Keys.ARROW_DOWN); actions.build().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 . ja va2 s .com */ 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 . c om*/ * * @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.utilities.GeneralUIUtils.java
License:Open Source License
public static WebElement hoverOnArea(String areaId) { Actions actions = new Actions(driver); WebElement area = getWebElementWaitForVisible(areaId); actions.moveToElement(area).perform(); return area;//w w w. jav a 2s. co m }
From source file:org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils.java
License:Open Source License
public static WebElement actionBuild(WebElement element) throws InterruptedException { // make an action on page//hover on element Actions build = new Actions(driver); // here you state ActionBuider build.moveToElement(element).build().perform();// hover the element. Thread.sleep(1000);//from w w w. j av a 2 s .c om return element; }
From source file:org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils.java
License:Open Source License
public static WebElement hoverOnArea(String areaId, WebDriver driver) { Actions actions = new Actions(driver); WebElement area = getWebElement(driver, areaId); actions.moveToElement(area).perform(); return area;/*www. ja va 2s .com*/ }
From source file:org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils.java
License:Open Source License
/** * Move to HTML element by class name. When moving to the HTML element, it * will raise hover event.//from w w w . j av a2 s .c om * * @param className */ public static void moveToHTMLElementByClassName(String className) { Actions actions = new Actions(GeneralUIUtils.getDriver()); final WebElement createButtonsArea = GeneralUIUtils .retryMethodOnException(() -> GeneralUIUtils.getDriver().findElement(By.className(className))); actions.moveToElement(createButtonsArea).perform(); }
From source file:org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils.java
License:Open Source License
/** * Move to HTML element by element id. When moving to the HTML element, it * will raise hover event./*from w w w .j av a 2 s . c om*/ * * @param className */ static void moveToHTMLElementByDataTestId(String dataTestId) { // WebElement hoverArea = // GeneralUIUtils.getDriver().findElement(By.xpath("//*[@data-tests-id='" // + dataTestId + "']")); WebElement hoverArea = GeneralUIUtils.waitForElementVisibility(dataTestId); // WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), // 30); // wait.until(ExpectedConditions.visibilityOf(hoverArea)); Actions actions = new Actions(GeneralUIUtils.getDriver()); actions.moveToElement(hoverArea).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 w ww . j a va2 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); }