angular / protractor

E2E test framework for Angular apps
http://www.protractortest.org
MIT License
8.74k stars 2.31k forks source link

No Browser Other Than Chrome Is Working #4853

Open DarthOpto opened 6 years ago

DarthOpto commented 6 years ago

Protractor does not appear to be working with any other browser than Chrome. I would like be able to run my tests across multiple browsers, but this is a major hindrance.

// Test report setup w/ screenshots var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter'); var reporter = new HtmlScreenshotReporter({ dest: 'report', filename: 'artemis-e2e-report.html' });

var seleniumServer = process.env.IS_WINDOWS ? 'http://slc-dev-win-curtis2:4444/wd/hub' : 'http://slc-dev-curtis1:4444/wd/hub'; // 'http://slc-dev-curtis1:4444/wd/hub' : 'http://127.0.0.1:4444/wd/hub';

var browserCapabilities = [ { browserName: 'chrome', seleniumAddress: seleniumServer, platform: 'ANY', version: 'ANY', chromeOptions: { args: ['--no-sandbox', '--test-type=browser', '--lang=en', '--window-size=1680,1050'], prefs: { 'credentials_enable_service': false, 'profile': { 'password_manager_enabled': false }, download: { prompt_for_download: false, directory_upgrade: true, default_directory: 'C:\downloads\' }, }, }, loggingPrefs: { browser: 'SEVERE' } }, { browserName: 'firefox', seleniumAddress: seleniumServer, }, { browserName: 'internet explorer', platform: 'ANY', version: '11', // seleniumAddress: seleniumServer, }, { browserName: 'MicrosoftEdge', seleniumAddress: seleniumServer, } ];

// Protractor config exports.config = { baseUrl: baseUrl, directConnect: false, allScriptsTimeout: 25 1000, jasmineNodeOpts: { defaultTimeoutInterval: 90 1000 }, getPageTimeout: 120 * 1000, suites: { testspecs here },

multiCapabilities: browserCapabilities,

maxSessions: 1,
framework: 'jasmine2',
onPrepare: function() {
    //Set Up a JUnit XML Reporter - Makes a nice test results area and trend graph in Jenkins
    var jasmineReporters = require('jasmine-reporters');
    jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
        consolidateAll: true,
        savePath: 'report',
        filePrefix: 'xmloutput'
    }));

    //Setup screenshots
    jasmine.getEnv().addReporter(reporter);
    browser.get(browser.baseUrl);
},

// Setup the report before any tests start
beforeLaunch: function() {
    return new Promise(function(resolve) {
        reporter.beforeLaunch(resolve);
    });
},

// Close the report after all tests finish
afterLaunch: function(exitCode) {
    return new Promise(function(resolve) {
        reporter.afterLaunch(resolve.bind(this, exitCode));
    });
},

};

- A relevant example test

describe('Smoke Tests', () => { beforeAll(() => { jasmine.DEFAULT_TIMEOUT_INTERVAL = 999999 loginPage.login(user.email, user.password) })

    afterEach(() => {
        common.navigationOpenByClick().then(() => {
            navPage.navigateToApp(AppParams.apps.home.navLink)
        })
    })

    afterAll(() => {
        common.signOut()
    })

    it('Create a Cohort', () => {
        console.log('\n ### Creating a Cohort - Smoke Test ### \n')
        const cohort = {
            type: EntityType.Cohort,
            name: 'Cohort - Smoke Test',
            config: {
                filters: CommonFilters.Filters.ageBins,
            },
        }
        cohorts.create(cohort)
        expect(listView.hasItem(cohort.name))
        listView.deleteItem(cohort.name)

    })

}

- Output from running the test **Firefox**
Error: Error while running testForAngular: Document was unloaded
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:08.936Z'
System info: host: 'USE-DEV-WIN2', ip: '192.168.20.45', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_171'
Driver info: driver.version: unknown

Stack: Error: Error while running testForAngular: Document was unloaded Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:08.936Z' System info: host: 'USE-DEV-WIN2', ip: '192.168.20.45', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0171' Driver info: driver.version: unknown at executeAsyncScript.then (/Users/csalisbury/src/helios/nodemodules/protractor/built/browser.js:727:23) at ManagedPromise.invokeCallback (/Users/csalisbury/src/helios/node_modules/protractor/nodemodules/selenium-webdriver/lib/promise.js:1376:14) at TaskQueue.execute (/Users/csalisbury/src/helios/node_modules/protractor/nodemodules/selenium-webdriver/lib/promise.js:3084:14) at TaskQueue.executeNext (/Users/csalisbury/src/helios/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:3067:27) at asyncRun (/Users/csalisbury/src/helios/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2927:27) at /Users/csalisbury/src/helios/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:668:7 at process._tickCallback (internal/process/next_tick.js:68:7)


- Output from running the test **IE 11**

Error: Error while running testForAngular: Page reload detected during async script Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:08.936Z' System info: host: 'USE-DEV-WIN2', ip: '192.168.20.45', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_171' Driver info: driver.version: unknown Stack: Error: Error while running testForAngular: Page reload detected during async script Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:08.936Z' System info: host: 'USE-DEV-WIN2', ip: '192.168.20.45', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0171' Driver info: driver.version: unknown at executeAsyncScript.then (/Users/csalisbury/src/helios/nodemodules/protractor/built/browser.js:727:23) at ManagedPromise.invokeCallback (/Users/csalisbury/src/helios/node_modules/protractor/nodemodules/selenium-webdriver/lib/promise.js:1376:14) at TaskQueue.execute (/Users/csalisbury/src/helios/node_modules/protractor/nodemodules/selenium-webdriver/lib/promise.js:3084:14) at TaskQueue.executeNext (/Users/csalisbury/src/helios/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:3067:27) at asyncRun (/Users/csalisbury/src/helios/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2927:27) at /Users/csalisbury/src/helios/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:668:7 at process._tickCallback (internal/process/next_tick.js:68:7)

- Output from running the test **Edge**

WebDriverError: Unable to parse remote response: Unknown error Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:08.936Z' System info: host: 'USE-DEV-WIN2', ip: '192.168.20.45', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_171' Driver info: driver.version: unknown at Object.checkLegacyResponse (/Users/csalisbury/src/helios/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:546:15) at parseHttpResponse (/Users/csalisbury/src/helios/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:509:13) at doSend.then.response (/Users/csalisbury/src/helios/node_modules/protractor/node_modules/selenium-webdriver/lib/http.js:441:30) at process._tickCallback (internal/process/next_tick.js:68:7) From: Task: WebDriver.createSession() at Function.createSession (/Users/csalisbury/src/helios/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:769:24) at createDriver (/Users/csalisbury/src/helios/node_modules/protractor/node_modules/selenium-webdriver/index.js:170:33) at Builder.build (/Users/csalisbury/src/helios/node_modules/protractor/node_modules/selenium-webdriver/index.js:635:14) at Hosted.getNewDriver (/Users/csalisbury/src/helios/node_modules/protractor/built/driverProviders/driverProvider.js:53:33) at Runner.createBrowser (/Users/csalisbury/src/helios/node_modules/protractor/built/runner.js:195:43) at q.then.then (/Users/csalisbury/src/helios/node_modules/protractor/built/runner.js:339:29) at _fulfilled (/Users/csalisbury/src/helios/node_modules/q/q.js:834:54) at /Users/csalisbury/src/helios/node_modules/q/q.js:863:30 at Promise.promise.promiseDispatch (/Users/csalisbury/src/helios/node_modules/q/q.js:796:13) at /Users/csalisbury/src/helios/node_modules/q/q.js:556:49



It looks like the main problem with IE and Firefox is that we are redirecting and the driver can't handle it. Edge on the other simply never loads
dsuren1 commented 6 years ago

I have a similar problem with Firefox 60. But the issue is with the firefox synchronization with the angular page. The application under test is angular 2.

Same configuration as above

Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined.  This could be either because this is a non-angular page or because
your test involves client-side navigation, which can interfere with Protractor's bootstrapping

And when I use browser.ignoreSynchronization=true;

Error in browser instance firefox while taking the logs:POST

sri85 commented 6 years ago

For Firefox you will need to pass an additional flag marionette:true in the capabilities

DarthOpto commented 6 years ago

@sri85 I have tried that as well and it did not work.

IgorSasovets commented 6 years ago

Hi, @DarthOpto ! I will take a look at your issue and provide feedback or some suggestions. Protractor has problems when is used with Angular2+ apps (especially when app uses angular/material).

DarthOpto commented 6 years ago

Thank you @IgorSasovets

IgorSasovets commented 6 years ago

@DarthOpto , I ran your config on my Windows machine and at least two browsers work as expected (Chrome, Firefox). Here are conf.js

// Configuration constants
var baseUrl = 'https://formetoknow.com/';

// Test report setup w/ screenshots
var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
var reporter = new HtmlScreenshotReporter({
    dest: 'report',
    filename: 'artemis-e2e-report.html'
});

var seleniumServer = process.env.IS_WINDOWS ?
    //'http://slc-dev-win-curtis2:4444/wd/hub' : 'http://slc-dev-curtis1:4444/wd/hub';
  'http://slc-dev-curtis1:4444/wd/hub' : 'http://127.0.0.1:4444/wd/hub';

 var browserCapabilities = [
    {
        browserName: 'chrome',
        seleniumAddress: seleniumServer,
        platform: 'ANY',
        version: 'ANY',
        chromeOptions: {
            args: ['--no-sandbox', '--test-type=browser', '--lang=en', '--window-size=1680,1050'],
            prefs: {
                'credentials_enable_service': false,
                'profile': {
                    'password_manager_enabled': false
                },
                download: {
                    prompt_for_download: false,
                    directory_upgrade: true,
                    default_directory: 'C:\\downloads\\'
                },
            },
        },
        loggingPrefs: { browser: 'SEVERE' }
    },
    {
        browserName: 'firefox',
        seleniumAddress: seleniumServer,
    },
    /*{
        browserName: 'internet explorer',
        platform: 'ANY',
        version: '11',
        // seleniumAddress: seleniumServer,
    },
    {
        browserName: 'MicrosoftEdge',
        seleniumAddress: seleniumServer,
    }*/
 ];

// Protractor config
exports.config = {
    baseUrl: baseUrl,
    directConnect: false,
    allScriptsTimeout: 25 * 1000,
    jasmineNodeOpts: {
        defaultTimeoutInterval: 90 * 1000
    },
    getPageTimeout: 120 * 1000,
    specs: ['spec.js'],

    multiCapabilities: browserCapabilities,

    maxSessions: 1,
    framework: 'jasmine2',
    onPrepare: function() {
        //Set Up a JUnit XML Reporter - Makes a nice test results area and trend graph in Jenkins
        var jasmineReporters = require('jasmine-reporters');
        jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
            consolidateAll: true,
            savePath: 'report',
            filePrefix: 'xmloutput'
        }));

        //Setup screenshots
        jasmine.getEnv().addReporter(reporter);
    },

    // Setup the report before any tests start
    beforeLaunch: function() {
        return new Promise(function(resolve) {
            reporter.beforeLaunch(resolve);
        });
    },

    // Close the report after all tests finish
    afterLaunch: function(exitCode) {
        return new Promise(function(resolve) {
            reporter.afterLaunch(resolve.bind(this, exitCode));
        });
    },

};

and spec.js

describe('Get type example', function()
{
    it('should get web app type', async function() {
        await browser.get('https://www.osianama.com/');
        await browser.sleep(5000);
        const script = `return document.querySelector('meta[name="og:type"]').content;`;
        const title = await browser.executeScript(script);
        expect(title).toEqual('website');
    });
});

Did you try to run it on other OS? My node version - 8.9.4.

image

IgorSasovets commented 6 years ago

Please try my example and provide feedback.

DarthOpto commented 6 years ago

@IgorSasovets So the above may work with firefox, I found out yesterday that our site has an issue with firefox which is getting resolved. Once that has been fixed I will test again. Any thoughts on Edge and IE11?

IgorSasovets commented 6 years ago

I commented IE11 and Edge because I haven't these browser on my local machine. You can test it just by removing my comments. I can try it with IE 10 and provide feedback if needed.

laflaneuse commented 5 years ago

Any news on this one? I have the same issue with Edge - only at times though, even for a testcase that if re-run works.

DarthOpto commented 5 years ago

Same results for me no other browser except Chrome is working I have even been running it through SauceLabs now and get the same results.