使用 Protractor + Appium + SauceLabs

Using Protractor + Appium + SauceLabs

我一直在尝试针对 Mobile 我的量角器测试自动化。 我已经阅读了网络上的大部分博客,我读到了这个,它是带有 Saucelabs 的 Appium 的 "official": https://docs.saucelabs.com/tutorials/appium/#mobile-web-application 我按照那里的说明进行操作,并将我的 config.js 文件配置为这个

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;
        });

    }

};

这是我在测试中尝试做的事情(我知道这不是一个很好的测试,我只是想测试 Appium 是否与我的 angular 应用程序一起工作。):

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

但是当我 运行 我的测试时,我不断收到此错误 android:

编辑:我可以看到网页正在打开。

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

我也试过这种情况:

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();
});

但是为此我得到了上面的错误加上这条消息:

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"

我做错了什么????请帮助pppp!!

编辑 2: 分享我在 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)

我终于能够让它在我的测试中发挥作用,唯一能在 SAUCELABS 上发挥魔力的组合是

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>'
        }


        ], 

除这些组合之外的其他组合将不起作用,至少对于我的应用程序而言。

我已经为 Protractor 团队对我的原始问题发表了评论,希望他们能回答。

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