Search in sources :

Example 1 with Element

use of io.appium.espressoserver.lib.model.Element in project appium-espresso-driver by appium.

the class Finder method handle.

@Override
public Element handle(Locator locator) throws AppiumException {
    try {
        if (locator.getUsing() == null) {
            throw new InvalidStrategyException("Locator strategy cannot be empty");
        } else if (locator.getValue() == null) {
            throw new MissingCommandsException("No locator provided");
        }
        // Test the selector
        ViewInteraction matcher = findBy(locator.getUsing(), locator.getValue());
        matcher.check(matches(isDisplayed()));
        // If we have a match, return success
        return new Element(matcher);
    } catch (NoMatchingViewException e) {
        throw new NoSuchElementException("Could not find element with strategy " + locator.getUsing() + " and selector " + locator.getValue());
    }
}
Also used : MissingCommandsException(io.appium.espressoserver.lib.handlers.exceptions.MissingCommandsException) Element(io.appium.espressoserver.lib.model.Element) ViewInteraction(android.support.test.espresso.ViewInteraction) NoMatchingViewException(android.support.test.espresso.NoMatchingViewException) InvalidStrategyException(io.appium.espressoserver.lib.handlers.exceptions.InvalidStrategyException) NoSuchElementException(io.appium.espressoserver.lib.handlers.exceptions.NoSuchElementException)

Aggregations

NoMatchingViewException (android.support.test.espresso.NoMatchingViewException)1 ViewInteraction (android.support.test.espresso.ViewInteraction)1 InvalidStrategyException (io.appium.espressoserver.lib.handlers.exceptions.InvalidStrategyException)1 MissingCommandsException (io.appium.espressoserver.lib.handlers.exceptions.MissingCommandsException)1 NoSuchElementException (io.appium.espressoserver.lib.handlers.exceptions.NoSuchElementException)1 Element (io.appium.espressoserver.lib.model.Element)1