Bamboo with selenium webdriver - selenium-webdriver

Tools: Java, Selenium WebDriver, Maven, Git, Bamboo
I'm not sure how I can run my test-cases under Bamboo which are written by java and build by maven and stored into Git repository. Bamboo can't open a real browser (IE, Firefox, chrome..)
It's worked when I tried to use HTMLUnitdriver (headless browser) instead of a real browser, BUT the problem with HTMLUnitdriver it is not functioning well (actually, it can't run most of the test scenarios even the other browsers do flawlessly).
I've Google it but could not found any good information on how to do it.
I'll really appreciate any help.

You should not run any test on Bamboo server. CI server is not meant to run any tests on. It should only controls how the tests will be executed instead. There are multiple ways to handle this. Selenium Grid is highly recommended. See another thread here on same topic

Use BrowserStack to execute test scripts and download reports/results as part of build as an artefact.
Or specify an agent that has the browser you need to test on.
https://www.browserstack.com/automate

Related

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.

How can I configure Selenium to have an extension pre-installed in Chrome?

We have a suite of tests that use Selenium to spawn Chrome instances when run locally. The Chrome instance that gets spawned is a completely vanilla profile with no extensions installed. For debugging purposes it would be useful to have the React & Redux dev tools extensions installed.
Is there a way to configure Selenium to install/enable extensions in the Chrome profile it spawns?
In an ideal world it wouldn't do a full install of the extension every time, but use a locally cached CRX file.
Thanks in advance for any help
#Kiril is right in saying that this question is asked often. You should do a thorough search before posting.
If you are using Javascript+ Selenium do something like this :
chromeOptions = {
'args': ['--test-type',
'--start-maximized',
'use-fake-ui-for-media-stream',],
'extensions': [encode(path.join(__dirname , '/your ext path/yourextention.crx'))],
};

What is the use of node.js in protractor?

I'm very new to AngularJS. I am trying to automate an angularJS app.
installed node.js
installed protractor (npm install -g protractor)
updated webdriver manager tool (webdriver-manager update)
started the driver (webdriver-manager start)
I create a simple conf.js and spec.js files. Everything works fine and set to go.
when we execute spec.js, protractor talk to selenium webdriver which then launches the browser and does the other stuff like interacting with angularJS app. Am I correct?
So, what is the role of node.js here in protractor?
I might be wrong, if so please do correct me and explain how protractor works.
Thanks in advance :)
Node.js is an open source runtime environment to develop applications in JavaScript.
WebDriverJS has been written in Node.js and Protractor has been written on top of WebDriverJS.
Node.js will be executing the javascript code you've written in your spec and po files with its JavaScript Engine (Google V8), or as you've so colourfully described: "does the other stuff like interacting with angularJS app".
Read more here and here
Protractor is a Node.js application... hence the Node requirement. Protractor is written in Javascript, so it requires a Javascript engine, which Node provides (Google V8), thus allowing it to run on a server.
Node.js is package file we are using in protractor automation tool to run the angular.js based application.It contains selenium and other browser drivers to run our applications in different environments.

Appium with Protractor: Working with AngularJS Asynchronous Calls

My Hybrid android app is built with angularjs library with lots of Asynchronous calls all over. How can I integrate Appium with Protractor, so that I can check for complete page loadings including asynchronous calls and other data bindings. My app is developed and ported as APK and not browsed in a browser. Am able to execute my selenium scripts but asynchronous calls is the place where I have stuck.
Please help me.
As of now Protractor doesn't officially support appium configurations. However there is a help file that is available in Protractor docs. All you need to do is update your conf.js file to include the appium configurations and remember to start your appium server before you run the test script.
To your question, you need to have below points ready -
Start your avd
Install the .apk file in your avd that you will be invoking through appium
Start the appium server using command - appium &
Update your protractor conf.js file to include appium android/chrome configurations. More details about configurations can be found in the below link.
Here's the link to it - Protractor-Appium Setup

Test runners for AngularJS - how to run the tests from eclipse IDE and CI server without too much complication?

I am trying to figure out a simple way to run tests on angularjs application.
I am new to the testing world, so it's a little hard to understand all the options and the difference between them.
My goal: to be able to run the tests simply from within my IDE - Eclipse.
And to tests the code on google chrome browser.
I found jasmine to be the obvious choice for writing js unit tests. The problem is choosing a runner both for the jasmine tests and for e2e tests.
Trying to keep it simple, I've come up with the following idea for a setup:
Write the unit tests in jasmine, and the e2e tests in phantomjs and syn.js.
Then configure eclipse to run phantomjs as an external tool, so that the output will go to the console in eclipse.
I also plan to have a CI job in Jenkins, and to my understanding Jenkins can also run phantom, so theoretically this solution will work the same for CI.
Alternatively, there are test running tools like Karma and Protractor. On one hand, they seem to be recommended, but on the other hand they seem to me like overkill in some cases. They require a lot of different tools/services/processes to be running in order to work, and it seems like a pain maintain all that setup if it breaks.
To my understanding: protractor runs on webdriverjs which runs on nodejs, and it requires a selenium server to be running in the background, and on top of all that the selenium opens real browser windows which seems a little pointless as opposed to headless browser testing.
Then there is Karma, that I did not yet fully understand what it's supposed to do. From what I've read it monitors the files in my project and whenever a file is changed it runs the tests. I'm not sure how it runs the tests - is it also using selenium?
And lastly, there are grunt and yeoman, which I did not understand at all what they do and how they interact or fit together with the other tools I've listed.
I would appreciate if someone could clarify what these different tools do, and how they fit together. Also, how would they fit with Jenkins as a CI server?
Also if you could comment on my "simpler setup" - does it make sense? Am I missing something?
Karma is for unit testing your JS, regardless of whether it is using Angular or not. The ins and outs of unit testing with Karma are covered very well here: http://www.yearofmoo.com/2013/01/full-spectrum-testing-with-angularjs-and-karma.html. Yes, Karma opens and closes browser windows as needed and specified in the configuration file. If you don't want any browser windows opened, you can use PhantomJS. You can run Karma from within most any IDE that is capable of running an external script, or run it via the command line.
Protractor is for end-to-end (or E2E) testing of your project as a whole. It will open a browser window and click through the pages as though it were a user, entering data where you tell it to and looking for the specified results. Protractor is a bit more complicated than just writing some Jasmine, but the results are worth it. Like Karma, you can run Protractor from within most any IDE that is capable of running external scripts or via the command line.
Yeoman is a process management system that incorporates dependency management via Bower, task automation via Grunt, and project management via Yo. It will run your tests in Karma and Protractor, minify your JS, CSS, and HTML, compile everything into appropriate files (internal JS, external libraries, and CSS) and provide you with a complete package that can be deployed. The beauty of Yeoman is that it is not specific to any one IDE. Everything it does can be done by scripting in your IDE or via the command line.
Now, having said all of this about Yeoman, you do still have to write the tests (it won't magically come up with them for you) and learn to integrate it into your development routine, but it is definitely the way to go for JS development. Eclipse is fine for JS development, but you'll get better performance and ease of use (IMHO) from WebStorm.
As for how these all fit into CI like Jenkins, I believe that both Karma and Protractor output test results in a format that Jenkins can read and display. With the scripting possibilities in Jenkins you can configure it to run the build process each time your source control repository (you are using some sort of source control, aren't you?) changes and show those results on the Jenkins page. My office has a very similar setup and we use it daily. I'm not the guy that has to do the Jenkins configuration, but I do work with Yeoman (and thus Karma and Protractor) via WebStorm on a regular basis and have had very good results.
I would say the clear choice here is Karma and Protractor. While it is true that they rely on a bunch of other stuff, they do so pretty antiseptically: protractor starts up the selenium server and then shuts it off when it's done. Once you have node installed, the other installations are all super simple. I would also install httpster, which will serve up your public director on port 3333.
Frankly, having come from a decade of doing TDD in the Java world, when I first looked at Javascript a few years ago (again), the testing picture was a complete joke. But now, I think the combination of Karma and Protractor is pretty fantastic. Inside IntelliJ, you can run the Karma tests and they are stupid fast and the results are presented in a runner that's as good as anything I've seen in the Java world (Xcode 5 has the best test integration). You can also install the ddescribe plugin in IntelliJ and have a ui for running individual tests or excluding tests.
On the protractor side, I found this post because I am at the point now where I am going to run my karma, protractor and then JUnit tests on a continuous integration server (either Jenkins or TeamCity). I was kind of surprised at the paucity of info on that leg of the trip, but the clear direction I see there is Grunt, because it will run your protractor tests then generate the JUnit-style output Jenkins wants. Grunt is also a pretty impressive addition to the JS world.
I know this sounds like a bunch of opinions, but I think that as happened in the Java world, the Javascript world has now reached that level of maturity where you are just going to have to expect things to drag other things in with them. Frankly, looks like node and npm do a pretty nice job of making that pretty seamless (vs. a decade down the drain on Maven in the Java world).
Updated: Sorry I did not read your question properly.
karma is a test runner, which is best suited for jasmine. For setting up is very very easy. Please download node, and install npm install karma. Follow the angular seed sandbox project it contains all the basic config set up for unit testing and end to end testing (in config folder).all you need is nodejs plugin installed in eclipse
Yeoman can be used for javascript minification, sass compilation e.t.c.
Install node eclipse and you can set all up in eclipse.
http://www.nodeclipse.org/

Resources