We are getting a timeout error after our protractor tests have completed.
Error updating Sauce pass/fail status: 'Could not send request: connect ETIMEDOUT
We have tried adding these to the onComplete function in our conf.js:
browser.driver.quit(), browser.driver.stop(), and different forms like this. None seem to be stopping the web driver. for the stop() function we are obviously receiving the error that the function DNE. For the browser.driver.quit(), we are receiving the timeout still. How do we stop the webdriver?
My protractor version: Version 3.3.0
My Complete conf.js:
exports.config = {
sauceUser: process.env.SAUCE_USERNAME,
sauceKey: process.env.SAUCE_ACCESS_KEY,
tunnelIdentifier: process.env.SAUCE_TUNNELL_IDENTIFIER,
webDriverProxy: 'my-companies-proxy',
specs: ['e2e/*spec.js'],
framework: 'jasmine2',
onPrepare: function(){
var caps = browser.getCapabilities()
},
multiCapabilities: [{
browserName: 'chrome',
version: '41',
platform: 'Windows 7',
name: "chrome-tests",
shardTestFiles: true,
maxInstances: 25
}],
onComplete: function() {
var printSessionId = function(jobName){
browser.getSession().then(function(session) {
console.log('SauceOnDemandSessionID=' + session.getId() + ' job-name=' + jobName);
});
}
printSessionId("Protractor Tests");
browser.driver.quit();
}
}
Related
We are making a desktop app with Electron using AngularJS, we want to make end-to-end tests using Protractor, the problem is that we got issues on running it, we don't really know what is the problem but looks like there is some synchronization problems, like it's not waiting for the page to load, not closing the app after the test is finished.
Here is the protractor configuration file:
const ELECTRON_PATH = '/usr/bin/electron';
const APP_PATH = '/home/me/project/myapp';
exports.config = {
directConnect: true,
framework: 'mocha',
specs: [
'test.js'
],
capabilities: {
browserName: 'chrome',
platform: 'LINUX',
chromeOptions: {
binary: ELECTRON_PATH,
args: ['app=' + APP_PATH, '--e2e-testing']
}
},
onPrepare: function() {
browser.ignoreSynchronization = true;
browser.resetUrl = 'file://';
}
};
I am getting below error when loading the very first page (base url in the conf.ts)
Protractor Version 4.0.9
Error: Error while waiting for Protractor to sync with the page: "[ng:test] http://errors.angularjs.org/1.5.8/ng/test"
at C:\Users\A133928\AppData\Roaming\npm\node_modules\protractor\built\browser.js:273:23
at ManagedPromise.invokeCallback_ (C:\Users\A133928\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1379:14)
at TaskQueue.execute_ (C:\Users\A133928\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2913:14)
at TaskQueue.executeNext_ (C:\Users\A133928\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2896:21)
at asyncRun (C:\Users\A133928\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2775:27)
at C:\Users\A133928\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:639:7
at process._tickCallback (internal/process/next_tick.js:103:7)
I have gone through similar kind of question in here as well.
Resolution2
But the issue is, I tried Resolution1 and apply some wait as mentioned below. Still even after page fully loaded I get the same said error.
Code:
beforeEach(() => {
loginPage.getPage();
browser.sleep(5000);
loginPage.userLogin(data.users[1].email, data.users[1].password );
browser.waitForAngular();
Conf.ts
export let config: Config = {
framework: 'jasmine',
rootElement: '.myApp',
// capabilities: { browserName: 'chrome'},
multiCapabilities: [
{
browserName: 'chrome',
chromeOptions: {
args: ['--start-maximized']
},
}],
seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
seleniumPort: null,
seleniumArgs: [],
Any suggestion please.
I am new to Protractor (can say just 1 day old) and have been trying to run end to end test.
However, every time I run conf.js, I am being displayed with "Timed out waiting for Protractor to synchronize with the page after 11 seconds."
Before posting this question, have tried all options given by other respondents, but still am unable to resolve the issue and thus request your help.
To support, below are the details of my configurations and spec js files:
Conf.js:
exports.config = {
directConnect: true,
capabilities: {'browserName': 'chrome'},
framework: 'jasmine',
specs: ['example_spec.js'],
jasmineNodeOpts: {
defaultTimeoutInterval: 100000
}
};
example_spec.js:
describe('forfirm homepage', function() {
it('login window should open', function() {
browser.get('https://www.forfirm.com');
element(by.model('forfirm.email')).sendKeys('email#email.com');
element(by.model('form.password')).sendKeys('Password');
});
});
Output received:
Failures:
1) forfirm homepage login window should open
Message:
Failed: Timed out waiting for Protractor to synchronize with the page after 11 seconds. Please see https://github.com/angular/protractor/blob/master/docs/faq.md. The following tasks were pending:
- $timeout: function (){a.next(),h=f(j,5e3)}
Stack:
Error: Failed: Timed out waiting for Protractor to synchronize with the page after 11 seconds. Please see https://github.com/angular/protractor/blob/master/docs/faq.md. The following tasks were pending:
- $timeout: function (){a.next(),h=f(j,5e3)}
at /Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/jasminewd2/index.js:101:16
at Promise.invokeCallback_ (/Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1329:14)
at TaskQueue.execute_ (/Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2790:14)
at TaskQueue.executeNext_ (/Users/rohitgathibandhe/npm-global/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2773:21)
1 spec, 1 failure
Finished in 22.022 seconds
[launcher] 0 instance(s) of WebDriver still running
[launcher] chrome #01 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1
Also, while running the protractor conf.js, I could not see protractor launching Chrome browser.
You should take a look on Timeouts and try to set all of them first
allScriptsTimeout: 120000,
getPageTimeout: 120000,
jasmineNodeOpts: {
defaultTimeoutInterval: 120000
},
Update:
i hate ignoreSynchronization, you should read about it, how to avoid it in official protractor documentation - try this:
conf.js
exports.config = {
directConnect: true,
capabilities: {'browserName': 'chrome'},
framework: 'jasmine',
specs: ['example_spec.js'],
allScriptsTimeout: 120000,
getPageTimeout: 120000,
jasmineNodeOpts: {
defaultTimeoutInterval: 120000
},
onPrepare: function () {
browser.driver.manage().window().maximize();
}};
example_spec.js
describe('forfirm homepage', function() {
it('login window should open', function() {
browser.ignoreSynchronization = true;
browser.get('https://www.forfirm.com');
element(by.model('form.email')).sendKeys('email#email.com');
element(by.model('form.password')).sendKeys('Password');
browser.sleep(5000);
});});
I believe this should solve the issue, as per Protractor official documentation at "https://github.com/angular/protractor/blob/master/docs/timeouts.md".
Interestingly, in our application, I see that this still takes 11 seconds default even though I have set the allScriptsTimeout to a value say 120 seconds.
I tried doing this in OnPrepare too, despite that I am seeing the same time out error stating Protractor synching with the page for 11 seconds. Any thoughts would be highly appreciated.
Below is an example of my config (Node - 4.2.4, Protractor - 3.1.1)
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['DemoTest.js'],
getPageTimeout: 120000,
allScriptsTimeout: 120000,
capabilities: {
browserName: 'chrome',
},
onPrepare: function(){
browser.ignoreSynchronization = true;
getPageTimeout: 120000;
allScriptsTimeout: 120000;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 180000;
},
}
I'm writing an app using Ionic/Angular and testing it with Protractor. I'd like to test it using Sauselabs Appium so I can test the app running natively on the various target platforms. I'm launching Protractor with:
SAUCE_USERNAME=$(SAUCE_USERNAME) SAUCE_ACCESS_KEY=$(SAUCE_ACCESS_KEY) ./node_modules/.bin/protractor protractorConfig.js
But I get this error message:
[launcher] Running 1 instances of WebDriver
[launcher] Error: TypeError: Target browser must be a string, but is <object>; did you forget to call forBrowser()?
My protractorConfig.js looks like:
/* global exports */
/* global process */
exports.config = {
sauceUser: process.env.SAUCE_USERNAME,
sauceKey: process.env.SAUCE_ACCESS_KEY,
capabilities: {
appiumVersion: "1.0",
app: "sauce-storage:app.zip",
platformName: "iOS",
platformVersion: "7.1",
deviceName: "iPhone Simulator"
},
allScriptsTimeout: 30000,
specs: [
"spec/feature/*.js"
]
};
I should have read the docs more carefully. Appium's documentation for Desired Capabilities says that 'browserName' should be an empty string if you're not targeting a browser.
Updating my protractorConfig accordingly fixes the issue.
/* global exports */
/* global process */
exports.config = {
sauceUser: process.env.SAUCE_USERNAME,
sauceKey: process.env.SAUCE_ACCESS_KEY,
capabilities: {
appiumVersion: "1.0",
app: "sauce-storage:app.zip",
platformName: "iOS",
platformVersion: "7.1",
deviceName: "iPhone Simulator",
browserName: ""
},
allScriptsTimeout: 30000,
specs: [
"spec/feature/*.js"
]
};
Try adding of 'browserName': 'chrome' into your capabilities.
I would like to add to our CI build process some e2e tests. I have already added them against chrome + firefox (as the simplest ones). But I really want to do it for several IE versions. How is it possible to inject it in build process on linux/mac?
I found such article:
http://elgalu.github.io/2014/run-protractor-against-internet-explorer-vm/
But looks like it is not 100% what I need. Could some one provide a simple configuration sample?
You would need a selenium server, either your own, or at browserstack/SauceLabs. If you are planning to do it on your own, in short, you would need to setup a selenium grid and register nodes, one of the nodes should be a windows machine where you would run tests against IE.
Personally, I've been successfully running protractor e2e tests on multiple browsers including different Chrome, Firefox and IE versions on browserstack. Here's the configuration I use (it also includes jasmine junit reporter, needed this for the CI):
'use strict';
var browserstackUser = 'user';
var browserstackKey = 'key';
exports.config = {
multiCapabilities: [
{
'browserstack.user': browserstackUser,
'browserstack.key': browserstackKey,
'browserstack.local': 'true',
'browserstack.debug': 'true',
'browserName': 'Chrome',
'os': 'Windows',
'os_version': '8',
'resolution': '1024x768',
specs: [
'*.spec.js'
],
exclude: [
'footer.disabledCookies.spec.js'
]
},
{
'browserstack.user': browserstackUser,
'browserstack.key': browserstackKey,
'browserstack.local': 'true',
'browserstack.debug': 'true',
'browser': 'Internet Explorer',
'browser_version': '8.0',
'os': 'Windows',
'os_version': '7',
'resolution': '1024x768',
specs: [
'*.spec.js'
]
},
{
'browserstack.user': browserstackUser,
'browserstack.key': browserstackKey,
'browserstack.local': 'true',
'browserstack.debug': 'true',
'browserName': 'Internet Explorer',
'browser_version': '9.0',
'os': 'Windows',
'os_version': '7',
'resolution': '1024x768',
specs: [
'*.spec.js'
],
exclude: [
'footer.disabledCookies.spec.js'
]
}
],
// Browserstack's selenium server address
seleniumAddress: 'http://hub.browserstack.com/wd/hub',
framework: 'jasmine',
allScriptsTimeout: 300000,
baseUrl: 'http://localhost:9001',
onPrepare: function () {
require('jasmine-reporters');
var capsPromise = browser.getCapabilities();
capsPromise.then(function (caps) {
var browserName = caps.caps_.browserName.toUpperCase();
var browserVersion = caps.caps_.version;
var prePendStr = browserName + "-" + browserVersion + "-";
jasmine.getEnv().addReporter(new
jasmine.JUnitXmlReporter("test-results", true, true, prePendStr));
});
},
jasmineNodeOpts: {
showColors: true,
isVerbose: true,
includeStackTrace: true,
defaultTimeoutInterval: 3600000
}
};