Is it possible to use Selenium / PHPUnit outside the browser? - unit-testing

Right now this is my workflow to write tests for a website:
Record using Selenium IDE plugin in Firefox
Export Test Case As >> PHP (PHP Unit)
Run the tests on a Windows machine that has PHPUnit installed as well as the Selenium extension for it using this command:
phpunit --verbose --log-junit some\path\result.xml some\path\test.php
What this command does is runs the test and saves the output (assertions and failures) in a log file called result.xml. And all has been good.
But now I have run into a need to test a part of the site that involves flash and I am using an application called Arthropod to capture the requests and responses coming to and from the flash component on the site.
Is there any way I can get selenium to to capture the text that appears on this program's interface?

I believe Arthropod is an AIR application. If it is associated with the browser you may try using seleniumForAir for your testing.
You may like to have a look here.

Related

How to Mock MVC4 application when UI testing with Watin?

What Im trying to achieve is to write UI tests for my MVC4 web application using Watin. Now I create a Browser object and open on URL localhost:xxxxx.
Problem is that the code running on localhost:xxxx using IIS Express is using production code which I dont want to be doing during test. In test I want for instance my IAuth and IDataProvider implementations to behave differently.
How do you UI test on a mocked instance of your application?
Ideas? :)
Solution was to make a bat file which runs a msbuild command which deploy to my local IIS. This works like a charm.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe C:\Source\...\ProjectName.csproj /p:DeployOnBuild=true /p:PublishProfile="UnitTest" /p:Platform="Any CPU" /p:OutputPath="C:\inetpub\web" /p:VisualStudioVersion=11.0

Testing phantomJS scripts

I have a phantomjs script that navigates to some pages and store some information about them in a file. Now I want to unit test this script. My problem is that usually the frameworks test my code on client side, so I can't use the PhantomJS API.
I tried to use jasmine-node (https://github.com/mhevery/jasmine-node). It works "server-side", but I can't use all the PhantomJS API because it obviously run my tests with nodejs instead of phantom. Is there a better option to test PhantomJS apps at server-side?
I found two solutions. I think the most complete way to test phantomJS at "server side" is to use CasperJS.
Another solution I have found looking at the phantomjs source code. They use jasmine for testing and it's possible to apply the same idea to my own tests. The run-tests.js is the starting point for this approach.

running jstd-maven-plugin tests without a browser

I've got jsTestDriver up and running, and I use jstd-maven-plugin to run the tests during a build.
The plugin needs a browser to be specified in order to work though, and I'd like to use something like rhino or htmlunit that won't actually launch a browser.
The jasmine-maven-plugin does this with htmlunit, and works quite well.
Is there a way to specify a headless browser for jstd-maven-plugin?
One of the reasons that I prefer JsTestDriver over other JavaScript testing frameworks, is that the tests are made on real browsers, and allows me to test on all the major browsers that consumes my application, and verify compatibility issues with older versions of IE for example.
If you prefer to run a complete headless JavaScript testing server, perhaps JsTestDriver is not your best choice. I think CasperJS is a very good alternative to achieve that. It uses PhantomJS, a scriptable headless WebKit engine to run the tests.
In my case, I have a complete headless server running an instance of JsTestDriver, and Other server whit a couple of virtual machines, with common SO/Browsers combinations (Windows/IE7; Windows/IE8; Linux/Firefox...), which have actual browsers connected to the headless JsTestDriver server. But if you don't need to use real browsers, the CasperJS alternative may be a good choice.
JsTestDriver need a browser to run the javascriptcode. So there is no way to run your tests without a browser.
There is a way to open the browser in a virtual monitor. This is described in this question:
Run Headless JsTestDriver?
JSTD maven plugin can be extended to run phanatomjs.

Django test client response context None

I have moved my Django app from my development machine (OS X, Python 2.6.5, Django 1.2.3) to a staging server (Ubuntu VM, Python 2.6.6, Django 1.2.3).
If I now run my test suite on the staging server, two tests fail when using the Django TestClient because response.context is None (but response.content is correct).
For example:
self.assertEquals(self.session.pk, response.context['db_session'].pk)
These test cases pass on the development machine.
Has anybody encountered similar problems?
You need to add the test setup statement.
import django
django.test.utils.setup_test_environment()
Find more details by following my link:
http://jazstudios.blogspot.com/2011/01/django-testing-views.html
From Django documentation:
Although * your code * [+] would work in the Python interactive interpreter, some of the test client's functionality, notably the template-related functionality, is only available while tests are running. The reason for this is that Django's test runner performs a bit of black magic in order to determine which template was loaded by a given view. This black magic (essentially a patching of Django's template system in memory) only happens during test running.
So if you run it in a test run, it should work.
You can see this question

UI Testing Tool on linux

Looking for a tool to UI testing on Linux .Platform used for development is django.
The idea is that the analysts will capture the tests thru some UI and it will be able to be played back over and over again.
Try with Selenium IDE, http://seleniumhq.org/projects/ide/