Remote selenium server for protractor - protractor

How to setup a remote webdriver-manager for protractor? If i change seleniumAddress in conf to 'http://remoteAddressInLan:4444/wd/hub', it opens browser in remote machine, but i want it in my local. Is it possible?

try removing the seleniumAddress config altogether, that should launch it locally
So you'll have:
exports.config = {
specs: ['todo-spec.js']
};
instead of:
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['todo-spec.js']
};

Related

How to change what port SolidJS server runs on in your local enviornment

After initally setting up Solid and starting it with npm start it runs on http://localhost:3000/.
How do you change what port it runs on?
vite is the package that is used to run the local server environment.
You can change it's settings in a file called vite.config.ts.
By default the setting isn't in there, but you can set it like so:
import { defineConfig } from 'vite';
import solidPlugin from 'vite-plugin-solid';
export default defineConfig({
plugins: [solidPlugin()],
server: { port: 3001 }, // <-- add this line
build: {
target: 'esnext',
polyfillDynamicImport: false,
},
});
Documentation about this and other settings can be found in the vite documentation

Can't run protractor on internet explorer

I try to run protractor on IE11 and i keep get this failuer:
E/launcher - Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones.
I did set in explorer for all zones but still get this error.
my conf.js file is:
exports.config = {
// The address of a running selenium server.
seleniumAddress: 'http://localhost:4444/wd/hub',
// Capabilities to be passed to the webdriver instance.
capabilities: {
browserName: 'internet explorer'
},
// Spec patterns are relative to the configuration file location passed
// to protractor (in this example conf.js).
// They may include glob patterns.
specs: ['todo-spec.js'],
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true, // Use colors in the command line report.
}
};
Help please.
Shaked
Go to Tools -> Internet Options -> Security Tab and set all zones to the same protected mode (can be enabled or disabled).
Try including these capabilities:
capabilities: {
...
"ignoreProtectedModeSettings": true
}

ECONNREFUSED Webdriver errors in eclipse when running Protractor

So, I was following this tutorial on getting my existing protractor files imported to Eclipse as Java project, installing angular/protractor configurations on eclipse and running the files:
https://www.youtube.com/watch?v=8dZ3isYcthI
But then I got into the weeds on this error: Error while running conf.js file from Eclipse
In attempt to resolve it, following instructions on the youtube tutorial, I replaced the selenium webdriver folder in Eclipse with the selenium webdriver folder in my node modules folder in AppData by dragging and dropping
Now my conf.js file will not run as protractor on Eclipse even though the file will execute successfully from the command line. Error is:
(node:53640) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[15:11:38] I/launcher - Running 1 instances of WebDriver
[15:11:38] I/hosted - Using the selenium server at http://localhost:4444 /wd/hub
[15:11:39] E/launcher - Error code: 135
[15:11:39] E/launcher - Error message: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444
[15:11:39] E/launcher - Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444 at ClientRequest. (C:\Workspace\testUltimateQASite\node_modules\selenium-webdriver\http\index.js:238:15)
The js line it is pointing to in the index file is the last line of this function:
request.on('error', function(e) {
if (e.code === 'ECONNRESET') {
setTimeout(function() {
sendRequest(options, onOk, onError, opt_data, opt_proxy);
}, 15);
} else {
var message = e.message;
if (e.code) {
message = e.code + ' ' + message;
}
onError(new Error(message));
}
});
My conf.js file is as follows:
// conf.js
//var jasmineReporters = require('jasmine-reporters');
var os = require('os'); os.tmpDir = os.tmpdir;
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['qaSpec.js'],
//module.exports = {
params: {
url : 'http://phptravels.com/demo/'
/* login: {
url: 'http://phptravels.com/demo/',
username: 'juliel#ibm.com',
password: 'password'
}*/
}
};
The error is basically stating that your Selenium server doesn't seem to be running. Notice how you are seeing a connection refused error.
Please check if you have started the selenium server as described in the official documentation here : http://www.protractortest.org/#/tutorial#setup
For more information on setting up eclipse and protractor you might want to refer here as well :https://github.com/angelozerr/angularjs-eclipse/wiki/Protractor
I tried to understand your project's architecture by reading post several times and still got a bit confused.
I am not sure how do you manage Webdriver?
For Protractor project I would recommend using proper NodeJS project's structure as well as using any JS task runner. Grunt might be a good choice.
There are plenty Webdriver Manager plugins as well as Protractor managers so you will be able to load your project's dependencies and run test with single Grunt command.
UPDATE: this demo project might be useful in understanding the use of Grunt and its dependencies in Angular project's architecture.

BrowserStack + Protractor + TravisCi and secure localhost server - configuration

Trying to have an e2e test to test my server and it's UI on TraviCI. I'm however not able to come up with the necessary configuration in order to run all the components and access seleniumServer on BrowserStack.
I am able to get my session started, but when launching a browser to https://localhost:3000/login I see that the browser shows a page not found. If I manually run the ./BrowserStackLocal tool and use browserstack to access my localhost, I can do so no problem.
Here are my files:
./travis.yaml
....
addons:
browserstack:
username: "<my username>"
access_key:
secure: "<secure key goes here>"
config.js
var browserstack = require('browserstack-local');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'specs/*.js'
],
'seleniumAddress': 'http://hub.browserstack.com/wd/hub',
'capabilities': {
'browserstack.user': '<my username>', //<<--- I also had a version without these properties for browserstack, and that didn't work either
'browserstack.key': '<my key>',
'browserName': 'chrome',
'acceptSslCerts': true,
'browserstack.debug': true,
'chromeOptions': {
'excludeSwitches': ["disable-popup-blocking"]
}
},
baseUrl: 'https://localhost:3000/',
rootElement: 'div[ng-app]',
framework: 'jasmine',
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
},
// Code to start browserstack local before start of test
beforeLaunch: function(){
console.log("Connecting local");
return new Promise(function(resolve, reject){
exports.bs_local = new browserstack.Local();
exports.bs_local.start({'key': exports.config.capabilities['browserstack.key'] }, function(error) {
if (error) return reject(error);
console.log('Connected. Now testing...');
resolve();
});
});
},
// Code to stop browserstack local after end of test
afterLaunch: function(){
return new Promise(function(resolve, reject){
exports.bs_local.stop(resolve);
});
}
};
Since you are testing your local/private environment on BrowserStack Automate you have to follow these steps:
1) Create the Local Testing connection via the BrowserStackLocal Binary.
2) Add the capability 'browserstack.local' : true in your config file.
I do not see the capability in the config.js file. Add the capability and things should work.
Your script looks similar to the one here.
I ran into this same problem myself recently. First, Ashwin is right that you need to add 'browserstack.local' : true to your protractor config file. Next you need to add "browserstack-local": "^1.3.0" to package.json under devDependencies. This is required for the Browserstack Local binary to be installed on your build server.
package.json:
...
"devDependencies": {
"browserstack-local": "^1.3.0"
}
Beyond that, it is not a problem with the config/setup. Rather, it is how you kick off the tests that affects the port your app is served on.
The reason it works when you run with the local binary is because your app is started on http://localhost:3000.
But when you build and run the app via Travis (by running ng e2e or similar), it actually starts your app on a different port (refer to this post for more on the angular ports). You can confirm this by looking at the console log, it should start with something like this:
> ng e2e
** NG Live Development Server is listening on localhost:49152, open your browser on http://localhost:49152 **
In the example above, it started on port 49152. So now if you have localhost:3000 hardcoded somewhere in your test spec, it won't find anything there. To fix this, in your test spec file, instead of browser.get('http://localhost:3000/login'), try browser.get(browser.baseUrl + '/login').
I realize this answer is probably too late for you, but hopefully it will be helpful to others.

Protractor test's within Webstorm has no Browser Connection

While trying to start the default protractor tests, WebStorm or protractor can not launch the default pages inside the Browser.
The Error Message is a simple Exception:
FA Jasmine spec timed out. Resetting the WebDriver Control Flow.
The setup for protractor is as follows:
The protractor.conf.js is as follows
exports.config = {
allScriptsTimeout: 11000,
specs: [
'*.js'
],
capabilities: {
'browserName': 'chrome'
},
baseUrl: 'http://localhost:8000/app/',
framework: 'jasmine2',
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
}
};
and the tests are the default webstorm tests.
Configuration looks OK.
Please make sure you have started the local webserver on port 8000 (npm start) prior to running protractor - webserver needs to be serving up the application, so that Protractor can interact with it.
Also, make sure that web driver is installed (npm run update-webdriver)