Java Code Examples for org.openqa.selenium.SearchContext#getClass()

The following examples show how to use org.openqa.selenium.SearchContext#getClass() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MobileBy.java    From java-client with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws WebDriverException when current session doesn't support the given selector or when
 *      value of the selector is not consistent.
 * @throws IllegalArgumentException when it is impossible to find something on the given
 * {@link SearchContext} instance
 */
@SuppressWarnings("unchecked")
@Override public List<WebElement> findElements(SearchContext context) {
    Class<?> contextClass = context.getClass();

    if (FindsByIosNSPredicate.class.isAssignableFrom(contextClass)) {
        return FindsByIosNSPredicate.class.cast(context)
                .findElementsByIosNsPredicate(getLocatorString());
    }

    if (FindsByFluentSelector.class.isAssignableFrom(contextClass)) {
        return super.findElements(context);
    }

    throw formIllegalArgumentException(contextClass, FindsByIosNSPredicate.class,
            FindsByFluentSelector.class);
}
 
Example 2
Source File: MobileBy.java    From java-client with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws WebDriverException when current session doesn't support the given selector or when
 *      value of the selector is not consistent.
 * @throws IllegalArgumentException when it is impossible to find something on the given
 * {@link SearchContext} instance
 */
@Override public WebElement findElement(SearchContext context) throws WebDriverException,
        IllegalArgumentException {
    Class<?> contextClass = context.getClass();

    if (FindsByAndroidViewTag.class.isAssignableFrom(contextClass)) {
        return FindsByAndroidViewTag.class.cast(context)
                .findElementByAndroidViewTag(getLocatorString());
    }

    if (FindsByFluentSelector.class.isAssignableFrom(contextClass)) {
        return super.findElement(context);
    }

    throw formIllegalArgumentException(contextClass, FindsByAndroidViewTag.class,
            FindsByFluentSelector.class);
}
 
Example 3
Source File: MobileBy.java    From java-client with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws WebDriverException when current session doesn't support the given selector or when
 *      value of the selector is not consistent.
 * @throws IllegalArgumentException when it is impossible to find something on the given
 * {@link SearchContext} instance
 */
@SuppressWarnings("unchecked")
@Override
public List<WebElement> findElements(SearchContext context) throws WebDriverException,
        IllegalArgumentException {
    Class<?> contextClass = context.getClass();

    if (FindsByAndroidViewTag.class.isAssignableFrom(contextClass)) {
        return FindsByAndroidViewTag.class.cast(context)
                .findElementsByAndroidViewTag(getLocatorString());
    }

    if (FindsByFluentSelector.class.isAssignableFrom(contextClass)) {
        return super.findElements(context);
    }

    throw formIllegalArgumentException(contextClass, FindsByAndroidViewTag.class,
            FindsByFluentSelector.class);
}
 
Example 4
Source File: MobileBy.java    From java-client with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws WebDriverException when current session doesn't support the given selector or when
 *      value of the selector is not consistent.
 * @throws IllegalArgumentException when it is impossible to find something on the given
 * {@link SearchContext} instance
 */
@Override public WebElement findElement(SearchContext context) {
    Class<?> contextClass = context.getClass();

    if (FindsByWindowsAutomation.class.isAssignableFrom(contextClass)) {
        return FindsByWindowsAutomation.class.cast(context)
            .findElementByWindowsUIAutomation(getLocatorString());
    }

    if (FindsByFluentSelector.class.isAssignableFrom(contextClass)) {
        return super.findElement(context);
    }

    throw formIllegalArgumentException(contextClass, FindsByIosNSPredicate.class,
        FindsByWindowsAutomation.class);
}
 
Example 5
Source File: MobileBy.java    From java-client with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws WebDriverException when current session doesn't support the given selector or when
 *      value of the selector is not consistent.
 * @throws IllegalArgumentException when it is impossible to find something on the given
 * {@link SearchContext} instance
 */
@SuppressWarnings("unchecked")
@Override public List<WebElement> findElements(SearchContext context) {
    Class<?> contextClass = context.getClass();

    if (FindsByWindowsAutomation.class.isAssignableFrom(contextClass)) {
        return FindsByWindowsAutomation.class.cast(context)
            .findElementsByWindowsUIAutomation(getLocatorString());
    }

    if (FindsByFluentSelector.class.isAssignableFrom(contextClass)) {
        return super.findElements(context);
    }

    throw formIllegalArgumentException(contextClass, FindsByWindowsAutomation.class,
        FindsByFluentSelector.class);
}
 
Example 6
Source File: MobileBy.java    From java-client with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws WebDriverException when current session doesn't support the given selector or when
 *      value of the selector is not consistent.
 * @throws IllegalArgumentException when it is impossible to find something on the given
 * {@link SearchContext} instance
 */
@Override public WebElement findElement(SearchContext context) {
    Class<?> contextClass = context.getClass();

    if (FindsByIosNSPredicate.class.isAssignableFrom(contextClass)) {
        return FindsByIosNSPredicate.class.cast(context)
                .findElementByIosNsPredicate(getLocatorString());
    }

    if (FindsByFluentSelector.class.isAssignableFrom(contextClass)) {
        return super.findElement(context);
    }

    throw formIllegalArgumentException(contextClass, FindsByIosNSPredicate.class,
            FindsByFluentSelector.class);
}
 
Example 7
Source File: MobileBy.java    From java-client with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws WebDriverException when current session doesn't support the given selector or when
 *      value of the selector is not consistent.
 * @throws IllegalArgumentException when it is impossible to find something on the given
 * {@link SearchContext} instance
 */
@SuppressWarnings("unchecked")
@Override
public List<WebElement> findElements(SearchContext context) throws WebDriverException,
    IllegalArgumentException {
    Class<?> contextClass = context.getClass();

    if (FindsByAndroidUIAutomator.class.isAssignableFrom(contextClass)) {
        return FindsByAndroidUIAutomator.class.cast(context)
            .findElementsByAndroidUIAutomator(getLocatorString());
    }

    if (FindsByFluentSelector.class.isAssignableFrom(contextClass)) {
        return super.findElements(context);
    }

    throw formIllegalArgumentException(contextClass, FindsByAndroidUIAutomator.class,
        FindsByFluentSelector.class);
}
 
Example 8
Source File: MobileBy.java    From java-client with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws WebDriverException when current session doesn't support the given selector or when
 *      value of the selector is not consistent.
 * @throws IllegalArgumentException when it is impossible to find something on the given
 * {@link SearchContext} instance
 */
@Override public WebElement findElement(SearchContext context) {
    Class<?> contextClass = context.getClass();

    if (FindsByAndroidViewMatcher.class.isAssignableFrom(contextClass)) {
        return FindsByAndroidViewMatcher.class.cast(context)
            .findElementByAndroidViewMatcher(getLocatorString());
    }

    if (FindsByFluentSelector.class.isAssignableFrom(contextClass)) {
        return super.findElement(context);
    }

    throw formIllegalArgumentException(contextClass, FindsByAndroidViewMatcher.class,
        FindsByFluentSelector.class);
}
 
Example 9
Source File: MobileBy.java    From java-client with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws WebDriverException when current session doesn't support the given selector or when
 *      value of the selector is not consistent.
 * @throws IllegalArgumentException when it is impossible to find something on the given
 * {@link SearchContext} instance
 */
@SuppressWarnings("unchecked")
@Override public List<WebElement> findElements(SearchContext context) {
    Class<?> contextClass = context.getClass();

    if (FindsByAndroidViewMatcher.class.isAssignableFrom(contextClass)) {
        return FindsByAndroidViewMatcher.class.cast(context)
            .findElementsByAndroidViewMatcher(getLocatorString());
    }

    if (FindsByFluentSelector.class.isAssignableFrom(contextClass)) {
        return super.findElements(context);
    }

    throw formIllegalArgumentException(contextClass, FindsByAndroidViewMatcher.class,
        FindsByFluentSelector.class);
}
 
Example 10
Source File: MobileBy.java    From java-client with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws WebDriverException when current session doesn't support the given selector or when
 *      value of the selector is not consistent.
 * @throws IllegalArgumentException when it is impossible to find something on the given
 * {@link SearchContext} instance
 */
@Override public WebElement findElement(SearchContext context) {
    Class<?> contextClass = context.getClass();

    if (FindsByAndroidDataMatcher.class.isAssignableFrom(contextClass)) {
        return FindsByAndroidDataMatcher.class.cast(context)
                .findElementByAndroidDataMatcher(getLocatorString());
    }

    if (FindsByFluentSelector.class.isAssignableFrom(contextClass)) {
        return super.findElement(context);
    }

    throw formIllegalArgumentException(contextClass, FindsByAndroidDataMatcher.class,
            FindsByFluentSelector.class);
}
 
Example 11
Source File: MobileBy.java    From java-client with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws WebDriverException when current session doesn't support the given selector or when
 *      value of the selector is not consistent.
 * @throws IllegalArgumentException when it is impossible to find something on the given
 * {@link SearchContext} instance
 */
@SuppressWarnings("unchecked")
@Override public List<WebElement> findElements(SearchContext context) {
    Class<?> contextClass = context.getClass();

    if (FindsByAndroidDataMatcher.class.isAssignableFrom(contextClass)) {
        return FindsByAndroidDataMatcher.class.cast(context)
                .findElementsByAndroidDataMatcher(getLocatorString());
    }

    if (FindsByFluentSelector.class.isAssignableFrom(contextClass)) {
        return super.findElements(context);
    }

    throw formIllegalArgumentException(contextClass, FindsByAndroidDataMatcher.class,
            FindsByFluentSelector.class);
}
 
Example 12
Source File: MobileBy.java    From java-client with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws WebDriverException when current session doesn't support the given selector or when
 *      value of the selector is not consistent.
 * @throws IllegalArgumentException when it is impossible to find something on the given
 * {@link SearchContext} instance
 */
@Override public WebElement findElement(SearchContext context) {
    Class<?> contextClass = context.getClass();

    if (FindsByIosClassChain.class.isAssignableFrom(contextClass)) {
        return FindsByIosClassChain.class.cast(context)
                .findElementByIosClassChain(getLocatorString());
    }

    if (FindsByFluentSelector.class.isAssignableFrom(contextClass)) {
        return super.findElement(context);
    }

    throw formIllegalArgumentException(contextClass, FindsByIosClassChain.class,
            FindsByFluentSelector.class);
}
 
Example 13
Source File: MobileBy.java    From java-client with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws WebDriverException when current session doesn't support the given selector or when
 *      value of the selector is not consistent.
 * @throws IllegalArgumentException when it is impossible to find something on the given
 * {@link SearchContext} instance
 */
@SuppressWarnings("unchecked")
@Override public List<WebElement> findElements(SearchContext context) {
    Class<?> contextClass = context.getClass();

    if (FindsByIosClassChain.class.isAssignableFrom(contextClass)) {
        return FindsByIosClassChain.class.cast(context)
                .findElementsByIosClassChain(getLocatorString());
    }

    if (FindsByFluentSelector.class.isAssignableFrom(contextClass)) {
        return super.findElements(context);
    }

    throw formIllegalArgumentException(contextClass, FindsByIosClassChain.class,
            FindsByFluentSelector.class);
}
 
Example 14
Source File: MobileBy.java    From java-client with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws WebDriverException when current session doesn't support the given selector or when
 *      value of the selector is not consistent.
 * @throws IllegalArgumentException when it is impossible to find something on the given
 * {@link SearchContext} instance
 */
@Override public WebElement findElement(SearchContext context) throws WebDriverException,
    IllegalArgumentException {
    Class<?> contextClass = context.getClass();

    if (FindsByAccessibilityId.class.isAssignableFrom(contextClass)) {
        return FindsByAccessibilityId.class.cast(context)
            .findElementByAccessibilityId(getLocatorString());
    }

    if (FindsByFluentSelector.class.isAssignableFrom(contextClass)) {
        return super.findElement(context);
    }

    throw formIllegalArgumentException(contextClass, FindsByAccessibilityId.class,
        FindsByFluentSelector.class);
}
 
Example 15
Source File: MobileBy.java    From java-client with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws WebDriverException when current session doesn't support the given selector or when
 *      value of the selector is not consistent.
 * @throws IllegalArgumentException when it is impossible to find something on the given
 * {@link SearchContext} instance
 */
@SuppressWarnings("unchecked")
@Override
public List<WebElement> findElements(SearchContext context) throws WebDriverException,
    IllegalArgumentException {
    Class<?> contextClass = context.getClass();

    if (FindsByAccessibilityId.class.isAssignableFrom(contextClass)) {
        return FindsByAccessibilityId.class.cast(context)
            .findElementsByAccessibilityId(getLocatorString());
    }

    if (FindsByFluentSelector.class.isAssignableFrom(contextClass)) {
        return super.findElements(context);
    }

    throw formIllegalArgumentException(contextClass, FindsByAccessibilityId.class,
        FindsByFluentSelector.class);
}
 
Example 16
Source File: MobileBy.java    From java-client with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws WebDriverException when current session doesn't support the given selector or when
 *      value of the selector is not consistent.
 * @throws IllegalArgumentException when it is impossible to find something on the given
 * {@link SearchContext} instance
 */
@Override public WebElement findElement(SearchContext context) throws WebDriverException,
    IllegalArgumentException {
    Class<?> contextClass = context.getClass();

    if (FindsByAndroidUIAutomator.class.isAssignableFrom(contextClass)) {
        return FindsByAndroidUIAutomator.class.cast(context)
            .findElementByAndroidUIAutomator(getLocatorString());
    }

    if (FindsByFluentSelector.class.isAssignableFrom(contextClass)) {
        return super.findElement(context);
    }

    throw formIllegalArgumentException(contextClass, FindsByAndroidUIAutomator.class,
        FindsByFluentSelector.class);
}
 
Example 17
Source File: MobileBy.java    From java-client with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws WebDriverException when current session doesn't support the given selector or when
 *      value of the selector is not consistent.
 * @throws IllegalArgumentException when it is impossible to find something on the given
 * {@link SearchContext} instance
 */
@SuppressWarnings("unchecked")
@Override public List<WebElement> findElements(SearchContext context) {
    Class<?> contextClass = context.getClass();

    if (FindsByImage.class.isAssignableFrom(contextClass)) {
        return FindsByImage.class.cast(context).findElementsByImage(getLocatorString());
    }

    if (FindsByFluentSelector.class.isAssignableFrom(contextClass)) {
        return super.findElements(context);
    }

    throw formIllegalArgumentException(contextClass, FindsByImage.class, FindsByFluentSelector.class);
}
 
Example 18
Source File: MobileBy.java    From java-client with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws WebDriverException when current session doesn't support the given selector or when
 *      value of the selector is not consistent.
 * @throws IllegalArgumentException when it is impossible to find something on the given
 * {@link SearchContext} instance
 */
@Override public WebElement findElement(SearchContext context) {
    Class<?> contextClass = context.getClass();

    if (FindsByImage.class.isAssignableFrom(contextClass)) {
        return FindsByImage.class.cast(context).findElementByImage(getLocatorString());
    }

    if (FindsByFluentSelector.class.isAssignableFrom(contextClass)) {
        return super.findElement(context);
    }

    throw formIllegalArgumentException(contextClass, FindsByImage.class, FindsByFluentSelector.class);
}
 
Example 19
Source File: MobileBy.java    From java-client with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws WebDriverException when current session doesn't support the given selector or when
 *      value of the selector is not consistent.
 * @throws IllegalArgumentException when it is impossible to find something on the given
 * {@link SearchContext} instance
 */
@SuppressWarnings("unchecked")
@Override public List<WebElement> findElements(SearchContext context) {
    Class<?> contextClass = context.getClass();

    if (FindsByCustom.class.isAssignableFrom(contextClass)) {
        return FindsByCustom.class.cast(context).findElementsByCustom(getLocatorString());
    }

    if (FindsByFluentSelector.class.isAssignableFrom(contextClass)) {
        return super.findElements(context);
    }

    throw formIllegalArgumentException(contextClass, FindsByCustom.class, FindsByFluentSelector.class);
}
 
Example 20
Source File: MobileBy.java    From java-client with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws WebDriverException when current session doesn't support the given selector or when
 *      value of the selector is not consistent.
 * @throws IllegalArgumentException when it is impossible to find something on the given
 * {@link SearchContext} instance
 */
@Override public WebElement findElement(SearchContext context) {
    Class<?> contextClass = context.getClass();

    if (FindsByCustom.class.isAssignableFrom(contextClass)) {
        return FindsByCustom.class.cast(context).findElementByCustom(getLocatorString());
    }

    if (FindsByFluentSelector.class.isAssignableFrom(contextClass)) {
        return super.findElement(context);
    }

    throw formIllegalArgumentException(contextClass, FindsByCustom.class, FindsByFluentSelector.class);
}