I'm working on a project to begin testing Node/Angular applications using Protractor and Jasmine. I have a POC working in most browsers but having a lot of trouble with MS Edge. Here's my environment:
OS: Windows 10 Pro (Version 1709, OS Build 16299.98)
Edge: 41.16299.15.0
EdgeHTML: 16.16299
MS Web Driver: 10.0.16299.15
Node: 6.12.0
Protractor: 5.2.1
Jasmine: 2.8.0
Selenium: 3.8.1
When I run the tests in Chrome, Firefox, and IE (11) the behavior is fine (tests run with expected results). However, with MS Edge the process fails before the test spec can even run.
Example code/output use the Protractor tutorial but I have the same issue when working with our application.
Working conf.js (for Chrome and Firefox)
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['./spec/spec.js'],
multiCapabilities: [
{ 'browserName': 'chrome' },
{ 'browserName': 'firefox', 'marionette': true, 'firefox_binary': "C:\\Program Files\\Mozilla Firefox\\firefox.exe" }//,
]
}
Failing conf.js (for MS Edge)
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://localhost:17556',
specs: ['./spec/spec.js'],
capabilites: { browserName: 'MicrosoftEdge' }
}
spec.js
// spec.js
describe('Protractor Demo App', function() {
it('should have a title', function() {
browser.get('http://juliemr.github.io/protractor-demo/');
expect(browser.getTitle()).toEqual('Super Calculator');
});
});
When I run the test for MS Edge after starting the Microsoft Web Driver the following occurs:
$ protractor conf.js
[14:14:18] I/launcher - Running 1 instances of WebDriver
[14:14:18] I/hosted - Using the selenium server at http://localhost:17556
[14:14:20] E/launcher - Error code: 135
[14:14:20] E/launcher - Error message: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:17556
[14:14:20] E/launcher - Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:17556
at ClientRequest.<anonymous> (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\http\index.js:238:15)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at Socket.socketErrorListener (_http_client.js:310:9)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at emitErrorNT (net.js:1281:8)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
From: Task: WebDriver.createSession()
at Function.createSession (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:769:24)
at Function.createSession (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\chrome.js:761:15)
at createDriver (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\index.js:170:33)
at Builder.build (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\index.js:626:16)
at Hosted.getNewDriver (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\built\driverProviders\driverProvider.js:53:33)
at Runner.createBrowser (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\built\runner.js:195:43)
at q.then.then (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\built\runner.js:339:29)
at _fulfilled (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:796:13)
[14:14:20] E/launcher - Process exited with error code 135
The problem seems to be somewhere around that it says it is using the server on 'localhost' but then makes requests on '127.0.0.1' instead. In theory, they are the same. But in operation, only 'localhost' is responsive. If I try to access 127.0.0.1:17556 it doesn't respond.
This website could not be found
Error Code: INET_E_RESOURCE_NOT_FOUND
I've been looking around a long time (here, SQA, and, the Protactor discussions on GitHub) for info on this but have not found a resolution. Some discussion on GitHub indicates MS Edge testing with Protractor was working at one point. Has anyone been able to successfully run Protractor tests with this version of MS Edge and MS Webdriver?
One final bit of info: I have access to another Windows 10 machine that has an older version of Edge (10240). On that machine I don't have this problem (localhost vs 127.0.0.1), but, it is old enough to still have issues with async and I'm not able to use it for testing with Protractor.
Thanks!
UPDATE
The spec file has not changed but I have updated the config file (conf.js):
// conf.js
exports.config = {
directConnect: false,
framework: 'jasmine',
specs: ['./spec/spec.js'],
seleniumAddress: 'http://localhost:4444/wd/hub',
multiCapabilities: [
//{ 'browserName': 'chrome' },
//{ 'browserName': 'firefox', 'marionette': true, 'firefox_binary': "C:\\Program Files\\Mozilla Firefox\\firefox.exe" },
{ 'browserName': 'MicrosoftEdge' }
]
};
When enabled Chrome and Firefox are able to run the test.
Edge fails with the following (timeout waiting for driver server to start):
$ protractor conf.js
[13:13:53] I/launcher - Running 1 instances of WebDriver
[13:13:53] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[13:14:13] E/launcher - Timed out waiting for driver server to start.
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: 'QA-01', ip: '10.1.1.80', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '9.0.1'
Driver info: driver.version: unknown
[13:14:13] E/launcher - WebDriverError: Timed out waiting for driver server to start.
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: 'QA-01', ip: '10.1.1.80', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '9.0.1'
Driver info: driver.version: unknown
at WebDriverError (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:27:5)
at Object.checkLegacyResponse (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:546:15)
at parseHttpResponse (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:109:7)
From: Task: WebDriver.createSession()
at Function.createSession (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:769:24)
at createDriver (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\index.js:170:33)
at Builder.build (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\index.js:635:14)
at Hosted.getNewDriver (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\built\driverProviders\driverProvider.js:53:33)
at Runner.createBrowser (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\built\runner.js:195:43)
at q.then.then (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\built\runner.js:339:29)
at _fulfilled (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:796:13)
at C:\Users\USER.NAME\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:556:49
[13:14:13] E/launcher - Process exited with error code 199
As before - the same setup on an older version of Windows 10, Edge (10240), and, the Edge Driver do try to run the tests (albeit with the async execution issue).
This setup is probably better than what I used before but the overall outcome is the same. Protractor tests (on this machine) aren't running in MS Edge (16299).
Any insight or advice is much appreciated.
Thanks!
From what I can gather you need to tell protractor where to find the Edge driver. I found a few blog posts that mention adding seleniumArgs to the config.
seleniumArgs: ['-Dwebdriver.edge.driver=your/path/to/MicrosoftWebDriver.exe']
After additional time and working with yet another Windows 10 machine I have successfully gotten this simple test to run.
I can only conclude that there was something on that particular machine preventing proper execution of the test. I wasn't able to figure out what that was, but, the "does it work?" question is answered. It does (which is what one would expect).
conf.js:
// conf.js
exports.config = {
directConnect: false,
framework: 'jasmine',
specs: ['./spec/spec.js'],
seleniumAddress: 'http://localhost:4444/wd/hub',
multiCapabilities: [
{ 'browserName': 'chrome' },
{ 'browserName': 'firefox', 'marionette': true },
{ 'browserName': 'MicrosoftEdge' }
]
};
spec.js:
// spec.js
describe('Protractor Demo App', function() {
it('should have a title', function() {
browser.get('http://juliemr.github.io/protractor-demo/');
expect(browser.getTitle()).toEqual('Super Calculator');
});
});
Results:
[10:07:15] I/launcher - 0 instance(s) of WebDriver still running
[10:07:15] I/launcher - chrome #01 passed
[10:07:15] I/launcher - MicrosoftEdge #21 passed
[10:07:15] I/launcher - firefox #11 passed
Related
1.Open the MS Chromium edge and type the command "edge://settings/help" to check the version
2. Download the MS Chromium edge webdriver and placed it into project directory
3. Set the desired capabilities in conf.js file
4. Start the server using command "webdriver-manager start --edge msedgedriver.exe"
5. Run the test using the "protractor conf.js"
Environment:
Chromium Edge Version = 83.0.478.37
Chromium web driver = 83.0.478.37
Selenium server version = 3.141.59
JDK =1.8.191
conf.js
exports.config = {
// The address of a running selenium server.
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
'browserName': 'chrome',
'goog:chromeOptions': {
// Faked out chrome binary
'binary':'C:\\Program Files (x86)\\Microsoft\\Edge Beta\\Application\\msedge.exe'
}
},
//Path of Chromium edge driver
chromeDriver:'./msedgedriver.exe',
specs: ['spec.js'],
}
};
Also tried with using desired capabilities in spec.js file as well but still blank page is opened
describe('slow calculator', function() {
beforeEach(function() {
let options = new edge.Options();
options.setEdgeChromium(true);
//options.setBinaryPath("C:\\Program Files (x86)\\Microsoft\\Edge Beta\\Application\\msedge.exe");
let browser = edge.Driver.createSession(options);
browser.get('http://juliemr.github.io/protractor-demo/');
});
});
While starting webdriver-manager, ensure the path to msedgedriver is specified.
webdriver-manager start --edge "pathToEdgeDriver/msedgedriver.exe"
The capabilities object should have MicrosoftEdge as browserName.
seleniumAddress: 'http://localhost:4444/wd/hub',
capabilities: {
'browserName': 'MicrosoftEdge'
}
I'm using protractor to test an application and webdriver-manager doesn't seem to want to install an appropriate Chrome driver, so I'm trying Firefox instead. However, the test gets stuck at the security warning page of my self-signed https:// test server. How do I configure protractor / selenium webdriver to skip the warning page?
Use this block in your protractor.conf.js to load Firefox, and ignore the certificate error presented by the test server's self-signed certificate. Note that if you're editing a Chrome config it's not enough to change browserName, you must remove any chromeOptions: { to avoid confusing the test runner.
capabilities: {
browserName: 'firefox',
'moz:firefoxOptions': {
// command line options could go here
},
'acceptInsecureCerts': true
},
In order to run protractor tests on multiple browsers, Protractor
offers a multiCapabilities configuration option. These options should
be defined as an array of objects.
1. Capabilities to be passed to the web driver instance.
capabilities: {
'browserName': 'firefox',
},
2. How to execute protractor tests on multiple browsers in parallel using multiCapabilities.
multiCapabilities: [
{'browserName': 'chrome'},
{'browserName': 'firefox'},
],
3. How we can do it using multiCapabilities.
multiCapabilities: [
{
'browserName': 'chrome',
'chromeOptions': {
'args': ['disable-infobars']
}
},
{
'browserName': 'firefox',
'moz:firefoxOptions': {
'args': ['--safe-mode']
}
}
],
I am unable to run "protractor test script" in "Internet explorer" browser.
I run below command.
webdriver-manager update --ie --versions.standalone 3.4.0 --versions.ie 3.4.0
my configuration file code is as below.
exports.config = {
allScriptsTimeout: 15000,
seleniumAddress:'http://localhost:4444/wd/hub',
capabilities:
{
'browserName': 'internet explorer',
'platform' : 'ANY',
'version' : '11'
},
suites: {
heropage: ['e2e/hero/hero.e2e-spec.ts'],
dashboardpage : ['e2e/dashboard/dashboard.e2e-spec.ts']
},
baseUrl: 'http://localhost:4200/',
// directConnect : true,
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 50000,
includeStackTrace: true
},
onPrepare() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
},
}
I change all the required setting for internet explorer browser in "internet options" by following http://elgalu.github.io/2014/run-protractor-against-internet-explorer-vm/
I am getting below error
Failed: JavaScript error in async script. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 26 milliseconds
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'BHUVISDESK-16', ip: '192.168.0.109', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0',
java.version: '1.8.0_144'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{se:ieOptions={browserAttachTimeout=0.0, ie.enableFullPageScreenshot=true, enablePersistentHover=true, i
e.forceCreateProcessApi=false, ie.forceShellWindowsApi=false, ignoreZoomSetting=false, ie.fileUploadDialogTimeout=3000.0,
ie.useLegacyFileUploadDialogHandling=false, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0.0, ie.
browserCommandLineSwitches=, requireWindowFocus=false, initialBrowserUrl=http://localhost:39545/, ignoreProtectedModeSetti
ngs=false, enableElementCacheCleanup=true}, browserName=internet explorer, pageLoadStrategy=normal, javascriptEnabled=true
, version=11, platform=WINDOWS, unexpectedAlertBehaviour=dismiss}]
Session ID: 01bf3915-d549-421b-a6f1-771e17c78cc7
Can any one help me what's my mistake in this process
I'm new to Protractor.
I'm declaring an element as a variable like :
txtSearch : element(by.xpath('//input[#type="search"]')),
In some point I want to log the locator as :
var clickOn = function(webElement)
{
webElement.click();
console.log("Successfully clicked on the " + webElement);
};
I'm calling this function from Spec file like - clickOn (txtSearch)
In Console.log I am getting like - Successfully clicked on the [object Object].
Please find the required details below :
Node Version: 7.5.0
Protractor Version: 5.1.1
Browser(s): Chrome
Protractor configuration file :
exports.config = {
capabilities: {
browserName: 'chrome',
},
onPrepare: function(){
jasmine.getEnv().addReporter(reporter);
global.isAngularSite = function(flag) {
browser.ignoreSynchronization = !flag;
};
browser.manage().timeouts().setScriptTimeout(60000);
browser.driver.manage().window().maximize();
},
seleniumServerJar: '../../protractor/selenium/selenium-server-standalone-2.52.0.jar',
chromeDriver: '../../protractor/selenium/chromedriver_2.27.exe',
directConnect: true,
framework: 'jasmine2',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['../PoC_Protractor/spec.js'],
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 600000,
isVerbose: true
}
I tried with webElement.locator().toString() but it is throwing-
Failed: webElement.locator is not a function
You can always output the locator used using webElement.locator().toString(). Check the output for the below code snipper.
Protractor spec:
describe('Locator testing by model', function(){
it('automate user register form', function(){
browser.get('http://www.way2automation.com/angularjs-protractor/registeration/#/login');
var search = element(by.model('Auth.user.name'))
console.log(search.locator())
console.log("Successfully clicked on the " + search.locator().toString());
console.log(search.locator().toString())
});
});
Output:
[14:01:48] I/local - Starting selenium standalone server...
[14:01:48] I/launcher - Running 1 instances of WebDriver
[14:01:49] I/local - Selenium standalone server started at http://10.96.61.119:56341/wd/hub
Started
{ findElementsOverride: [Function], toString: [Function] }
Successfully clicked on the by.model("Auth.user.name")
by.model("Auth.user.name")
.
1 spec, 0 failures
Finished in 0.942 seconds
[14:01:53] I/local - Shutting down selenium standalone server.
[14:01:53] I/launcher - 0 instance(s) of WebDriver still running
[14:01:53] I/launcher - internet explorer #01 passed
Hey it seems like you may not be resolving the promise in the correct way, try using -
webElement.click().then(function(element){
console.log(""Successfully clicked on the " + element);
};
We were evaluating Sauce labs for our application. We were trying to get protractor tests run on multiple browsers at same time in Sauce labs. Will there be a new instance of VM created to run tests on each browser? We have configured protractor for multicapablities.
When would the new instance of VM be created? and if possible how would we configure to run tests on single VM or multiple VM?
Thanks.
It is possible to have protractor start multiple capabilities at the same time as well as run multiple tests in parallel. ( i do it in a work project )
By default i believe that each capability will run in parallel, to have the tests run in parallel also you need to set the shardTestFiles: true option.
https://github.com/angular/protractor/blob/master/docs/referenceConf.js#L114-L117
note this will be limited to the max instances limit of your saucelabs account (normally 10)
you can see in the following code snippet that we have set our protractor to give precedence to IE8 as its is the slowest, then the other browsers will start a maximum of 3 test scripts in parallel with the rest queuing up
maxSessions: 10,
multiCapabilities: [
{
browserName: 'internet explorer',
version: '10',
shardTestFiles: true,
maxInstances: 3,
'screen-resolution': '1024x768',
build: process.env.CI_BUILD_NUMBER
},
{
browserName: 'internet explorer',
version: '8',
platform: 'Windows XP',
shardTestFiles: true,
maxInstances: 10,
'screen-resolution': '1024x768',
build: process.env.CI_BUILD_NUMBER
},
{
browserName: 'firefox',
platform: 'Windows 8',
shardTestFiles: true,
maxInstances: 3,
'screen-resolution': '1024x768',
build: process.env.CI_BUILD_NUMBER
},
{
browserName: 'safari',
version: '7',
platform: 'OS X 10.9',
shardTestFiles: true,
maxInstances: 3,
'screen-resolution': '1024x768',
build: process.env.CI_BUILD_NUMBER
},
{
browserName: 'chrome',
platform: 'Windows 8.1',
shardTestFiles: true,
maxInstances: 3,
'screen-resolution': '1024x768'
}
]