Search in sources :

Example 11 with AndroidElement

use of io.appium.java_client.android.AndroidElement in project carina by qaprosoft.

the class MobileFactory method create.

@Override
public WebDriver create(String name, Device device, DesiredCapabilities capabilities, String seleniumHost) {
    if (seleniumHost == null) {
        seleniumHost = Configuration.get(Configuration.Parameter.SELENIUM_HOST);
    }
    String driverType = Configuration.getDriverType();
    String mobilePlatformName = Configuration.getPlatform();
    // TODO: refactor code to be able to remove SpecialKeywords.CUSTOM property completely
    // use comparison for custom_capabilities here to localize as possible usage of CUSTOM attribute
    String customCapabilities = Configuration.get(Parameter.CUSTOM_CAPABILITIES);
    if (!customCapabilities.isEmpty()) {
        mobilePlatformName = SpecialKeywords.CUSTOM;
    }
    LOGGER.debug("selenium: " + seleniumHost);
    RemoteWebDriver driver = null;
    if (isCapabilitiesEmpty(capabilities)) {
        capabilities = getCapabilities(name, device);
    }
    try {
        if (driverType.equalsIgnoreCase(SpecialKeywords.MOBILE)) {
            if (mobilePlatformName.toLowerCase().equalsIgnoreCase(SpecialKeywords.ANDROID)) {
                driver = new AndroidDriver<AndroidElement>(new URL(seleniumHost), capabilities);
            } else if (mobilePlatformName.toLowerCase().equalsIgnoreCase(SpecialKeywords.IOS)) {
                driver = new IOSDriver<IOSElement>(new URL(seleniumHost), capabilities);
            } else if (mobilePlatformName.toLowerCase().equalsIgnoreCase(SpecialKeywords.CUSTOM)) {
                // that's a case for custom mobile capabilities like browserstack or saucelabs
                driver = new RemoteWebDriver(new URL(seleniumHost), capabilities);
            } else {
                throw new RuntimeException("Unsupported mobile capabilities for type: " + driverType + " platform: " + mobilePlatformName);
            }
        }
        if (device.isNull()) {
            // TODO: double check that local run with direct appium works fine
            RemoteDevice remoteDevice = getDeviceInfo(seleniumHost, driver.getSessionId().toString());
            // 3rd party solutions like browserstack or saucelabs return not null remoteDevice object. But inside nothing useful
            if (remoteDevice != null && remoteDevice.getName() != null) {
                device = new Device(remoteDevice);
            } else {
                device = new Device(driver.getCapabilities());
            }
            boolean stfEnabled = R.CONFIG.getBoolean(SpecialKeywords.CAPABILITIES + "." + SpecialKeywords.STF_ENABLED);
            if (stfEnabled) {
                device.connectRemote();
            }
            DevicePool.registerDevice(device);
        }
        // will be performed just in case uninstall_related_apps flag marked as true
        device.uninstallRelatedApps();
    } catch (MalformedURLException e) {
        LOGGER.error("Malformed selenium URL! " + e.getMessage(), e);
    }
    if (driver == null) {
        Assert.fail("Unable to initialize driver: " + name + "!");
    }
    return driver;
}
Also used : IOSDriver(io.appium.java_client.ios.IOSDriver) MalformedURLException(java.net.MalformedURLException) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) RemoteDevice(com.qaprosoft.carina.commons.models.RemoteDevice) Device(com.qaprosoft.carina.core.foundation.webdriver.device.Device) AndroidElement(io.appium.java_client.android.AndroidElement) RemoteDevice(com.qaprosoft.carina.commons.models.RemoteDevice) URL(java.net.URL)

Example 12 with AndroidElement

use of io.appium.java_client.android.AndroidElement in project java-client by appium.

the class AndroidTest method scrollingToSubElement.

@Test
public void scrollingToSubElement() {
    driver.findElementByAccessibilityId("Views").click();
    AndroidElement list = driver.findElement(By.id("android:id/list"));
    MobileElement radioGroup = list.findElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView(" + "new UiSelector().text(\"Radio Group\"));"));
    assertNotNull(radioGroup.getLocation());
}
Also used : MobileElement(io.appium.java_client.MobileElement) AndroidElement(io.appium.java_client.android.AndroidElement) Test(org.junit.Test)

Example 13 with AndroidElement

use of io.appium.java_client.android.AndroidElement in project java-client by appium.

the class AndroidTest method replaceValueTest.

@Test
public void replaceValueTest() {
    String originalValue = "original value";
    Activity activity = new Activity("io.appium.android.apis", ".view.Controls1");
    startsActivity.startActivity(activity);
    AndroidElement editElement = driver.findElement(MobileBy.AndroidUIAutomator("resourceId(\"io.appium.android.apis:id/edit\")"));
    editElement.sendKeys(originalValue);
    assertEquals(originalValue, editElement.getText());
    String replacedValue = "replaced value";
    editElement.replaceValue(replacedValue);
    assertEquals(replacedValue, editElement.getText());
}
Also used : Activity(io.appium.java_client.android.Activity) StartsActivity(io.appium.java_client.android.StartsActivity) AndroidElement(io.appium.java_client.android.AndroidElement) Test(org.junit.Test)

Example 14 with AndroidElement

use of io.appium.java_client.android.AndroidElement in project android by owncloud.

the class Actions method deleteElement.

public static AndroidElement deleteElement(String elementName, FileListView fileListView, AndroidDriver driver) throws Exception {
    AndroidElement fileElement;
    WaitAMomentPopUp waitAMomentPopUp;
    try {
        //To open directly the "file list view" and
        //we don't need to know in which view we are
        driver.startActivity("com.owncloud.android", ".ui.activity.FileDisplayActivity");
        fileElement = (AndroidElement) driver.findElementByName(elementName);
        ElementMenuOptions menuOptions = fileListView.longPressOnElement(elementName);
        RemoveConfirmationView removeConfirmationView = menuOptions.clickOnRemove();
        ;
        waitAMomentPopUp = removeConfirmationView.clickOnRemoteAndLocalButton();
        Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
    } catch (NoSuchElementException e) {
        fileElement = null;
    }
    return fileElement;
}
Also used : RemoveConfirmationView(com.owncloud.android.test.ui.models.RemoveConfirmationView) ElementMenuOptions(com.owncloud.android.test.ui.models.ElementMenuOptions) AndroidElement(io.appium.java_client.android.AndroidElement) WaitAMomentPopUp(com.owncloud.android.test.ui.models.WaitAMomentPopUp) NoSuchElementException(org.openqa.selenium.NoSuchElementException)

Example 15 with AndroidElement

use of io.appium.java_client.android.AndroidElement in project android by owncloud.

the class Actions method shareLinkElementByCopyLink.

public static AndroidElement shareLinkElementByCopyLink(String elementName, FileListView fileListView, AndroidDriver driver, Common common) throws Exception {
    try {
        //To open directly the "file list view" and
        //we don't need to know in which view we are
        driver.startActivity("com.owncloud.android", ".ui.activity.FileDisplayActivity");
        ElementMenuOptions menuOptions = fileListView.longPressOnElement(elementName);
        ShareView shareView = menuOptions.clickOnShareLinkElement();
        Actions.scrollTillFindElement("Copy link", shareView.getListViewLayout(), driver).click();
        WaitAMomentPopUp waitAMomentPopUp = new WaitAMomentPopUp(driver);
        Common.waitTillElementIsNotPresentWithoutTimeout(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
        common.wait.until(ExpectedConditions.visibilityOf(fileListView.getFileElementLayout().findElement(By.id(FileListView.getSharedElementIndicator()))));
    } catch (NoSuchElementException e) {
        return null;
    }
    return (AndroidElement) fileListView.getFileElementLayout().findElement(By.id(FileListView.getSharedElementIndicator()));
}
Also used : ShareView(com.owncloud.android.test.ui.models.ShareView) ElementMenuOptions(com.owncloud.android.test.ui.models.ElementMenuOptions) AndroidElement(io.appium.java_client.android.AndroidElement) WaitAMomentPopUp(com.owncloud.android.test.ui.models.WaitAMomentPopUp) NoSuchElementException(org.openqa.selenium.NoSuchElementException)

Aggregations

AndroidElement (io.appium.java_client.android.AndroidElement)19 NoSuchElementException (org.openqa.selenium.NoSuchElementException)10 Test (org.junit.Test)8 IgnoreTestCategory (com.owncloud.android.test.ui.groups.IgnoreTestCategory)6 InProgressCategory (com.owncloud.android.test.ui.groups.InProgressCategory)6 NoIgnoreTestCategory (com.owncloud.android.test.ui.groups.NoIgnoreTestCategory)6 SmokeTestCategory (com.owncloud.android.test.ui.groups.SmokeTestCategory)6 ElementMenuOptions (com.owncloud.android.test.ui.models.ElementMenuOptions)6 FileListView (com.owncloud.android.test.ui.models.FileListView)6 Category (org.junit.experimental.categories.Category)6 ShareView (com.owncloud.android.test.ui.models.ShareView)4 WaitAMomentPopUp (com.owncloud.android.test.ui.models.WaitAMomentPopUp)4 GmailSendMailView (com.owncloud.android.test.ui.models.GmailSendMailView)2 RemoveConfirmationView (com.owncloud.android.test.ui.models.RemoveConfirmationView)2 HashMap (java.util.HashMap)2 RemoteDevice (com.qaprosoft.carina.commons.models.RemoteDevice)1 Device (com.qaprosoft.carina.core.foundation.webdriver.device.Device)1 MobileElement (io.appium.java_client.MobileElement)1 Activity (io.appium.java_client.android.Activity)1 StartsActivity (io.appium.java_client.android.StartsActivity)1