Monday, 6 September 2010

How to handle ssl certificate error in firefox

Hi all,
As soon as your tests redirect to an HTTPS URL on the same host, where your SSL certificate is self-signed, things go wrong. As Selenium effectively runs Firefox with a new profile every time, you potentially lose any certificate exceptions you might accept.
One technique we were using was to create a custom profile; run Firefox using that profile; browse to the HTTPS URL and accept the exception into that profile; then close the profile.

Steps to create a Firefox profile:
1. Close down any running Firefox instances.
2. Start Firefox (the one you're going to run your tests with) with the profile manager: firefox –ProfileManager using command prompt.
3. Create a new profile. You'll be prompted to choose a directory for the profile. Put it somewhere inside the project where you're writing the tests.
4. Select the profile and run Firefox using it.
5. Browse to the HTTPS URL (with self-signed certificate) you're going to be testing against.
6. Accept the self-signed certificate when prompted. This creates an exception for it in the profile.
7. Close the browser.
8. Go to the Firefox profile directory.
9. When you run your Selenium server, pass a -firefoxProfileTemplate /path/to/profile/dir argument to it. This tells Selenium to use your partial profile (with certificate exceptions) as a basis for minting its new profile. So you get the certificate exceptions, but without any of the other clutter you would get if you used a whole profile.


command for using the firefox profile template in selenium server.

java -jar selenium-server.jar -firefoxProfileTemplate /path/to/profile \
-htmlSuite “*chrome firefox-bin” “http://host.com” “testSuite.html” “seleniumResults.html”

How to run selenium testing in liferay

Hello ALL,
In this blog i have explained briefly about selenium configuration with liferay, liferay source itself has its own selenium scripts in the following path.

D:\liferay-portal-src-5.2.3\portal-web\test\com\liferay\portalweb

Before running the selenium default liferay scripts, we need do some changes in properties files, like test-portal-web.properties and portal-ext.properties.

edit few lines in test-portal-web.properties file like following sample code.

selenium.host=localhost
selenium.port=4444

#browser.type=*chrome
#browser.type=*firefox
#browser.type=*iehta
browser.type=*iexplore

company.id=1
portal.url=http://localhost:8080


Edit portal-ext.properties(inside server you have to create this file)

In this file we need mention "captcha.max.challenges=-1" this sentence to avoid captcha.

after this we need to open a command prompt and execute the following command.

ant start from d:/portal-src

once build successful we need start selenium-server and also liferay's tomcat server.

Finally we need to execute one more command from command prompt.

ant test from D:\liferay-portal-src-5.2.3\portal-web

now you can able to see the selenium scripts are running in liferay portal successfully.

Hope this will help lot for liferay testers in selenium.

To run selenium scripts(html) parallel

I used to run selenium scripts one-by-one in selenium rc, in that case it will take 3 to 4 hours to execute all the scripts completely. client will not wait such a long time to get the results. for that i have taken a selenium grid concept to run selenium scripts(html) and one more thing also using selenium grid we cant run selenium html scripts we can run only selenium scripts in java and c#.

Before running our scripts parallel we need to create one .xml file, so i have given one example .xml file. try to understand this file then you will able to create your own .xml for your projects.

.xml sample:



Steps to run our scripts in parallel.

Step 1: download psexec.exe file from google and paste it inside your scripts folder.

Step 2. open command prompt and run the following command.
ant Main

Main is target name you can change whatever you want.