Running Karma and Protractor tests with or without a headless browser - selenium

I am confused about running Karma and Protractor on a TeamCity CI server. Should I run these tests with a headless browser or not and how can I do that?

You can use a headless browser for unit testing. If you need a headless browser with karma/jasmine,you can use PhantomJS karma launcher . You can simply specify this when you run karma init , and it will ask you for a browser launcher in one of the steps of that configuration . or add the following to your package.json file
{
"devDependencies": {
"karma": "~0.10",
"karma-phantomjs-launcher": "~0.1"
}
}
But with protractor i recommend you to not to use a headless browser . Because you might want to see the actual happening of the testing when the protractor tests run (like what's happening with the actions and interactions in the interface of your application and such) . It is up to you. there are few headless browsers available for protractor tests along with PhantomJS for protractor

Related

is possible run selenium with headless browser to handle functionalities?

My objective is running automation based selenium webdriver from Jenkins, but jenkins cannot open browser when build job. so I modified my code to run in headless mode. since implementing headless browser, having some big question
is possible to handle end to end business on headless browser? cause end to end need inspect element as the process
if headless browser cannot handle, do you have some suggestion?
thanks, I'm very low to integrate automation
You don't have to change the code to run a Selenium test with Jenkins in headless mode.
You can use a Jenkins plugin of a headless X server to run your tests on an installed browser. You will even get screenshots.

How to let Karma skip a browser if not installed

I have a karma.config.js file in a repo that lists different browsers that karma needs to run test on. If I run the test on ubuntu which doesn't have safari install and karma will complain
No binary for Safari browser on your platform. Please set "SAFARI_BIN" env variable.
How do I configure Karma to automatically skip the browser without giving error if a browser is not installed. I don't want everyone who download the repo to edit the config file.
Let me answer my own question. After some searching and experimenting. I found a karma plugin that Karma detect browsers. In the karma config, I added
detectBrowsers: {
enable: true,
},
and removed the browsers array.
You still have to install the runners for each of the potential browser that you want to test on.
When I run karma now, it will try out different browsers and see if they are installed in the current system. If installed, run the test.

How to keep data after headless browser selenium tests are passed?

Currently, we are using selenium for the automation test within our projects. We are using PhantomJs WebDriver to be able to run headless browser tests on bamboo. We want to be able to see the data(or content) which are created and saved by tests using PhantomJs but looks like the content will be gone after that tests are passed.
If we run the tests on Firefox driver without PhantomJs, we can see the content (or data) which is created by tests.
How we could config Phantomjs WebDriver in selenium to be able to see new content (or data) after running tests?
Any suggestion?

Selenium IDE and Headless Browser Testing

How do I run test cases made with Selenium IDE (Firefox Plugin) in a headless browser?
When I create test cases with the firefox plugin it saves them as .html files.
I am trying to setup a way of running them in a headless browser, (using phantomJS or another tool/lib). I have seen many people mention running firefox in a hidden frame, but this is not the same as headless (ie. PhantomJS)
I have already figured out how to run selenium test cases from command line, but only in firefox or ie, I can't get it to run .html testcases on phantomjs:
java -jar selenium-server-standalone-2.39.0.jar -htmlSuite "*firefox" "http://127.0.0.1" "ts-ProjectList/TestSuite.html" "ProjectList-results.html"
I know the IDE can export test cases in different languages, but I want non-tech team members to be able to create tests using the firefox plugin.
Have you looked at http://code.tutsplus.com/tutorials/headless-functional-testing-with-selenium-and-phantomjs--net-30545?
Changing "*firefox" to phantomjs should get you started.
You'll need the phantomJS driver:
http://selenium.googlecode.com/svn/trunk/docs/api/py/webdriver_phantomjs/selenium.webdriver.phantomjs.webdriver.html

Use phantomjs to drive chrome

Is there a way to use phantomjs to drive my firefox/chrome browser?
We have a bunch of casperjs tests, that I would like to run directly in the browser for debugging ( or just pure interrest ).
I seem to recall that a long time ago, before phantomjs became pure headless, I could do this by making it run on X instead of xvfb and removing/uncommenting the phantom.exit() line.
PhantomJs IS a browser, so the answer is no. You may want to look into Karma however.
You just use a config file which allows you to provide a browser to run your tests in:
Chrome
ChromeCanary
Firefox
Opera
Safari (only Mac)
PhantomJS
IE & Edge (only Windows)
SauseLabs, BrowserStack Electron, & more
Still, your tests will need to be written in QUnit, Jasmine, Mocha, ... which can be too much work to port from CasperJs.