Using Protractor + Appium + SauceLabs

1.9k views Asked by At

I've been dealing to try to automate against Mobile my protractor tests. I've read most of the blogs around the web, I reached this one which is the "official" for Appium with Saucelabs: https://docs.saucelabs.com/tutorials/appium/#mobile-web-application I followed instructions there, and configured my config.js file as this

var testName = 'Testing'; //Change Project's name here in order to be identified in BrowserStack

exports.config = {
    // The address of a running selenium server.
    seleniumAddress: 'http://bmsoko:[redacted]@ondemand.saucelabs.com:80/wd/hub',
    // Capabilities to be passed to the webdriver instance.
    multiCapabilities: [{
        name: testName,
        'appium-version': '1.4.0',
        'browserName': 'Android',
        'deviceName': 'Android Emulator',
        'deviceOrientation': 'portrait',
        'platform': 'Linux',
        'version': '5.1',
        username: 'bmsoko',
        accessKey: '[redacted]'
    }],

    // Spec patterns are relative to the current working directly when
    // protractor is called.

    suites: {
        mobile: './././specs/mobile.js'
    },

    // Maximum number of total browser sessions to run. Tests are queued in
    // sequence if number of browser sessions is limited by this parameter.
    // Use a number less than 1 to denote unlimited. Default is unlimited.
    maxSessions: 2,

    // protractor will save the test output in json format at this path.
    // The path is relative to the location of this config.
    resultJsonOutputFile: null,

    framework: 'jasmine2',

    // Options to be passed to Jasmine-node.
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 100000,
        realtimeFailure: true,
        showTiming: true,
        includeStackTrace: true,
        isVerbose: true,
        onComplete: null
    },

    onPrepare: function () {
        //browser.driver.manage().window().maximize();
        global.dvr = browser.driver; //variable to call selenium directly
        global.isAngularSite = function (flag) {
            browser.ignoreSynchronization = !flag; //This setup is to configure when testing non-angular pages
        };
        browser.manage().timeouts().implicitlyWait(10000);
        browser.getCapabilities().then(function (cap) {
            browserName = cap.caps_.browserName;
        });

    }

};

and here's what I'm trying to do in my test (I know its not a very good test, I just wanted to test Appium works with my angular app.):

it('User should see module 1s elements on the web page', function () {
   browser.sleep(6000); 
   browser.driver.findElement(by.css('.play__video'));
});

But when I run my tests, I keep getting this error for android:

EDIT: I can see that the web page is being opened.

Stack: Error: Failed: {"message":"[$injector:modulerr] Failed to instantiate module p due to:\nError: [$injector:nomod] Module 'p' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.\nhttp://errors.angularjs.org/1.3.14/$injector/nomod?p0=p\n at http://WEBAPPLICATION.com/assets/javascripts/global.js:107:21272\n at http://WEBAPPLICATIONs.com/assets/javascripts/global.js:107:29604\n at t (http://WEBAPPLICATION.com/assets/javascripts/global.js:107:29176)\n

I've also tried this scenario:

it('User should see module 1 s video start on the web page', function () {
    browser.wait(EC.visibilityOf(basePage.videoButtonModule1), 10000);
    basePage.videoButtonModule1.click();
    expect(basePage.videoContainerModule1.isDisplayed()).toBeTruthy();
});

but for this I get the above error plus this message:

Message: Failed: Error while waiting for Protractor to sync with the page: "[ng:test] no injector found for element argument to getTestability\nhttp://errors.angularjs.org/1.3.14/ng/test"

What am I doing wrong???? Please helppppp!!

EDIT 2: Sharing the error that I'm getting with iOS

New Landing page module verification --> User should see module 1 s video start on the web page Message: Failed: Angular could not be found on the page WEBAPP.com/ : angular never provided resumeBootstrap Stack: Error: Failed: Angular could not be found on the page WEBAPP.com/ : angular never provided resumeBootstrap at /usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:102:16 at [object Object].promise.ControlFlow.runInFrame_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1877:20) at [object Object].promise.Callback_.goog.defineClass.notify (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:2464:25) at [object Object].promise.Promise.notify_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:563:12)

1

There are 1 answers

0
Bruno Soko On BEST ANSWER

I was able to finally make it work for my tests, the only combination that does the magic ONLY ON SAUCELABS is

multiCapabilities: [
        {
            platformName: 'iOS',
            platformVersion: '7.1',
            browserName: '',
            app: 'safari',
            deviceName: 'iPhone Simulator',
            'appium-version': "1.4.0",
            username: '<USERNAME>',
            accessKey: '<KEY>'

        }
        ,
        {
            platformName: 'Android',
            platformVersion: '4.4',
            browserName: 'Browser',
            deviceName: 'Android Emulator',
            'appium-version': "1.4.0",
            username: '<USERNAME>',
            accessKey: '<KEY>'
        }


        ], 

Other combination rather than these won't work, at least for my app.

I have placed a comment on my original issue for Protractor team hoping they'll answer it.

https://github.com/angular/protractor/issues/2247