grunt-protractor-runner and Cross-Browser testing - selenium-webdriver

I am able to successfully run test on chrome on my current set-up, however I am unable to add other browsers to my tests. I am using the grunt module 'grunt-protractor-runner' to run my e2e tests.
Having looked around I know the grunt-protractor-runner module does support multiCapabilities, so on the face of it I would expect the simple task of editing the target config file to include multiCapabilities and update chromeOnly to false.
Although I can pass multiCapabilities, I cannot however change the chromeOnly option to 'false' and get my tests to run successfully. My errors when passing Firefox and Chrome to multiCapabilities,
Running 2 instances of WebDriver[launcher] Runner Process Exited With Error Code: 8
------------------------------------
PID: 7812 (capability: chrome #1)
------------------------------------
Using the selenium server at http://localhost:4444/wd/hub
C:\Project\node_modules\protractor\node_modules\selenium- webdriver\lib\webdriver\promise.js:1702
throw error;
^
------------------------------------
PID: 6444 (capability: firefox #1)
------------------------------------
Using the selenium server at http://localhost:4444/wd/hub
C:\Project\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1702
throw error;
^
I am running my set-up on Windows 7, using grunt-protractor-runner 1.0.1, protractor 0.23.1, chromedriver 2.9, and selenium-server-standalone 2.41.0

It would seem that I've been able to resolve this problem - it related to not starting a standalone selenium server, which grunt-protractor-runner does not do on it's own.
The way around this is to either open a new console at the location of the protractor web-driver using webdriver-manager start --standalone and running the tests using grunt-protractor-runner as before; or as I am currently, using the grunt-protractor-webdriver module and including it within the grunt task to be called.
In my protractor.conf.js file I removed chromeOnly: true and added a multiCapabilities array of browsers.

Related

gitlab CI + gradle + locally is not executing selenium test with shell executor

I am new to gradle and trying to fix a old gradle project. I am able to run it on local cmd using - gradle test 'taskToExecute' and it is able to run tests.
Then I tried to switch to Gitlab CI/CD. I was able to install gitlab runner and specific runner setup on gitlab. I have 2 stages Build and Test. Build stages gets completed everytime but with test stage I don't know the problem it always exit with timeout Either I set up timeout limit to 30 minute or 3 hours. I am also not sure if it running the selenium tests as test stage is getting completed very early.
I am using windows shell executor with gitlab runner. Will be posting screen shot for more details.
Gradle version - 7.2
Gitlab-runner version - 15.3.0
Need help to fix this issue.
I tried executing the same thing on my local machine and it works fine. As I am trying to run it using gitlab runner which is also installed on my local system I wanted to see the result that test gets executed and processed the reports.

Occasional ChromeDriver error when using Cucumber.js --parallel option

I have a UI test framework written in Selenium WebDriver JS, with test scenarios in Cucumber.js. I'm having an occasional issue when running these tests in Chrome and using the experimental --parallel CLI option. I tend to use --parallel 5 to speed up the overall execution time of the tests and this works well in all other browsers than Chrome, where the tests will sometimes end suddenly with the message
Error: EADDRNOTAVAIL connect EADDRNOTAVAIL 127.0.0.1:60730 - Local (0.0.0.0:0)
At that point the browsers remain open but the Cucumber process ends.
I know the --parallel option is experimental but I can find no other mentions of this online so I want to make sure I'm not doing something stupid.
I'm using:
Chrome 73.0.3683.103
ChromeDriver 73.0.0
Cucumber 5.1.0
Selenium WebDriver 4.0.0-alpha.1
(installed from npm).
This is on macOS 10.14.4 if that makes a difference. I can replicate this on other machines with the same OS version too, have not got a Windows machine to hand to try.
I suggest instead of using Selenium WebDriver JS with Cucumber that you use Protractor with Cucumber. Protractor is a JS wrapper of selenium and there is a project that has already done all the hard work of combining cucumber and selenium. Protractor has built-in parallel functionality that was built to run parallel browser testing. Check out https://github.com/protractor-cucumber-framework/protractor-cucumber-framework
This was an issue in selenium-webdriver that is now fixed in master.

Standalone webdirver vs firefox driver

What is the difference between standalone webdriver and firefox driver?
My main goal is to pass the firefox binary path to the tests. I was able to achieve this but it seems that I have to have the directConnect flag on the protractor config to true. This uses the firefox driver
Running the tests I get some failures on the assertions
For instance :
Following passes if I run using a standalone webdriver and fails if I set directConnect to true and pass firefox binary path
expect('Hello World!').toNotEqual('Hi!');

Manage Protractor tests with a single Gulp task

I'm trying to get e2e testing going with on my angular project using Gulp.
I'm able to get it working, but only if I manually launch a standalone selenium server using webdriver-manager start in a seperate terminal window.
Ideally I would like my gulp task to manage starting and stopping the server so as to not add more overhead for my team to run these tests.
I got set up following the instructions here:
https://github.com/mllrsohn/gulp-protractor
They describe 2 options for starting the selenium server. One is to set up a gulp task which appears to do the same thing as webdriver-manager start:
gulp.task('webdriver_standalone', require("gulp-protractor").webdriver_standalone);
This works, but not when I have my e2eTest task invoke it as a dependency. I have to run gulp webdriver_standalone in a seperate terminal window.
I cannot understand the other suggested option.
point to the selenium jar in the protractor config file
These instructions require a path to the selenium-server-standalone jar, in protractors node_modules (./node_modules/protractor/selenium/selenium-server-standalone-2.45.0.jar), but my node_modules/protractor/ directory does not have such a jar (or a selenium sub-directory at all)
The instructions for Running Protractor without a plugin seem to have the same problem of having to run the selenium server in another terminal window.
Is there a way to get this set up so that a single gulp task starts the standalone server, runs the tests, and shuts it down with no other intervention?
When you run Protractor you have several options regarding Selenium WebDriver (remember that WebDriver is web-service written in Java):
Run with Protractor with remote (standalone) service. It can be either local or on different machine. If Selenium is on different machine then your web app should be publicly available, not just localhost. If you choose to use standalone Selenium service then you configure your config file/Gulp task with seleniumAddress option.
"Ask" Protractor to run Selenium for you. In this case Protractor will run Selenium WebDriver with the Jar file you provide in seleniumServerJar configuration.
Do not use Selenium WD. Use direct connect instead, which is compatible with Chrome and (probably) Firefox only.
In your case simply run:
./node_modules/protractor/bin/webdriver-manager update
It will download Selenium. Then point config to the right jar.
The easiest way to get this working locally is using a local Selenium Standalone jar, as Igor suggested in option #2. (It is pretty difficult to get gulp to run webdriver-manager start as a spawned child_process or async task.)
You can get that jar in your node_modules folder easily by using:
npm install selenium-server-standalone-jar --save-dev
Then, in your protractor.conf.js comment out or remove the seleniumAddress line and add a line for seleniumServerJar.
exports.config = {
seleniumServerJar: '../node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-2.47.1.jar',
//seleniumAddress: 'http://localhost:4444/wd/hub',
/* Lines below for completeness only, leave yours as is. */
framework: 'jasmine2',
specs: ['login-spec.js'],
multiCapabilities: [{
browserName: 'chrome',
browserName: 'firefox'
}]
};

E2E Testing in Protractor using Firefox or Safari?

I am using Protractor to test my angular.js app and its working great in Chrome. I had some issues getting it set up and learning the extra webdriver syntax for jasmine, but now I'm getting the hang of it and have a number of tests that are running and passing in Chrome.
Does anyone know of any way to run Protractor in Firefox or Safari or IE or Opera? I'd like to be able to run these tests against more browsers than just Chrome. I've looked through the Protractor docs on GitHub but it only shows config files for the chromeDriver. Is there such thing as a Firefox driver or a Safari driver?
PS. I don't think it'll be much help, so I'm not posting my current config file, but if it is useful, let me know and I can post it here.
Yes! You'll need to do a little setup depending on which browser driver you want to use, but firefox and safari should be trivial. Their drivers are included in the Selenium Standalone server. Just add
capabilities: {
'browserName': 'firefox' // or 'safari'
},
to the config file.
For IE, you need to install a separate binary, and the Selenium Standalone Server needs that binary to be in your PATH. After that, you should be able to use ie as a browsername in your config. Check out the IEDriver documentation here - http://code.google.com/p/selenium/wiki/InternetExplorerDriver

Resources