Search in sources :

Example 6 with ReplayOnError

use of com.seleniumtests.uipage.ReplayOnError in project seleniumRobot by bhecquet.

the class PictureElement method doubleClickAt.

@ReplayOnError(replayDelayMs = 1000, waitAfterAction = true)
public void doubleClickAt(int xOffset, int yOffset) {
    findElement();
    Point intoElementPos = intoElement.getCoordinates().onPage();
    int relativeX = detectedObjectRectangle.x + detectedObjectRectangle.width / 2 - intoElementPos.x;
    int relativeY = detectedObjectRectangle.y + detectedObjectRectangle.height / 2 - intoElementPos.y;
    moveAndDoubleClick(intoElement, relativeX + (int) (xOffset * pictureSizeRatio), relativeY + (int) (yOffset * pictureSizeRatio));
}
Also used : Point(org.openqa.selenium.Point) Point(org.openqa.selenium.Point) ReplayOnError(com.seleniumtests.uipage.ReplayOnError)

Example 7 with ReplayOnError

use of com.seleniumtests.uipage.ReplayOnError in project seleniumRobot by bhecquet.

the class SelectList method getSelectedTexts.

@ReplayOnError
public String[] getSelectedTexts() {
    List<WebElement> allSelectedOptions = getAllTheSelectedOptions();
    List<String> textList = new ArrayList<>();
    for (WebElement option : allSelectedOptions) {
        textList.add(selectImplementation.getOptionText(option));
    }
    String[] texts = new String[textList.size()];
    return textList.toArray(texts);
}
Also used : ArrayList(java.util.ArrayList) WebElement(org.openqa.selenium.WebElement) ReplayOnError(com.seleniumtests.uipage.ReplayOnError)

Example 8 with ReplayOnError

use of com.seleniumtests.uipage.ReplayOnError in project seleniumRobot by bhecquet.

the class SelectList method deselectByCorrespondingText.

@ReplayOnError(waitAfterAction = true)
public void deselectByCorrespondingText(final String text) {
    try {
        findElement();
        if (!isMultipleSelect()) {
            throw new UnsupportedOperationException(ERROR_MULTI_SELECT);
        }
        double score = 0;
        WebElement optionToSelect = null;
        for (WebElement option : options) {
            String source = option.getText().trim();
            if (service.score(source, text) > score) {
                score = service.score(source, text);
                optionToSelect = option;
            }
        }
        if (optionToSelect != null) {
            selectImplementation.setDeselected(optionToSelect);
        } else {
            throw new NoSuchElementException("Cannot locate option with corresponding text " + text);
        }
    } finally {
        selectImplementation.finalizeAction();
    }
}
Also used : WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException) ReplayOnError(com.seleniumtests.uipage.ReplayOnError)

Example 9 with ReplayOnError

use of com.seleniumtests.uipage.ReplayOnError in project seleniumRobot by bhecquet.

the class Table method getRowFromContent.

/**
 * issue #306
 * Returns the row from table, searching for its content by pattern. Then you can search for a specific cell using 'getRowCells(row);'
 *
 * Tip: returned element is a HtmlElement, but you must cast it to use its specific methods
 *
 * @param content	pattern to search for
 * @param column	column where pattern should be searched
 * @return
 */
@ReplayOnError
public WebElement getRowFromContent(final Pattern content, final int column) {
    findTableElement();
    if (rows != null && !rows.isEmpty()) {
        for (WebElement row : rows) {
            List<WebElement> cols = getRowCells(row);
            if (cols.isEmpty()) {
                throw new ScenarioException("There are no columns in this row");
            }
            WebElement cell = cols.get(column);
            Matcher matcher = content.matcher(cell.getText());
            if (matcher.matches()) {
                return row;
            }
        }
        throw new ScenarioException(String.format("Pattern %s has not been found in table", content.pattern()));
    } else {
        throw new ScenarioException(ERROR_NO_ROWS);
    }
}
Also used : Matcher(java.util.regex.Matcher) WebElement(org.openqa.selenium.WebElement) ScenarioException(com.seleniumtests.customexception.ScenarioException) ReplayOnError(com.seleniumtests.uipage.ReplayOnError)

Example 10 with ReplayOnError

use of com.seleniumtests.uipage.ReplayOnError in project seleniumRobot by bhecquet.

the class UiElement method clickAt.

@ReplayOnError(waitAfterAction = true)
public void clickAt(int xOffset, int yOffset) {
    Point relativePoint = findElementPosition(xOffset, yOffset);
    CustomEventFiringWebDriver.leftClicOnDesktopAt(true, relativePoint.x, relativePoint.y, SeleniumTestsContextManager.getThreadContext().getRunMode(), SeleniumTestsContextManager.getThreadContext().getSeleniumGridConnector());
}
Also used : Point(org.openqa.selenium.Point) ReplayOnError(com.seleniumtests.uipage.ReplayOnError)

Aggregations

ReplayOnError (com.seleniumtests.uipage.ReplayOnError)24 Point (org.openqa.selenium.Point)11 WebElement (org.openqa.selenium.WebElement)7 PerformsTouchActions (io.appium.java_client.PerformsTouchActions)5 MobileElement (io.appium.java_client.MobileElement)4 ScenarioException (com.seleniumtests.customexception.ScenarioException)3 CustomEventFiringWebDriver (com.seleniumtests.driver.CustomEventFiringWebDriver)3 DriverConfig (com.seleniumtests.driver.DriverConfig)3 MultiTouchAction (io.appium.java_client.MultiTouchAction)3 ArrayList (java.util.ArrayList)3 Matcher (java.util.regex.Matcher)3 NoSuchElementException (org.openqa.selenium.NoSuchElementException)3 Actions (org.openqa.selenium.interactions.Actions)2 RemoteWebElement (org.openqa.selenium.remote.RemoteWebElement)2 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)1 Clock (java.time.Clock)1 Instant (java.time.Instant)1 InvalidElementStateException (org.openqa.selenium.InvalidElementStateException)1 Rectangle (org.openqa.selenium.Rectangle)1 TimeoutException (org.openqa.selenium.TimeoutException)1