Showing posts with label Selenium. Show all posts
Showing posts with label Selenium. Show all posts

Thursday, April 8, 2010

Firefox 3.6.3 and Selenium issue with FirefoxChromeLauncher$FileLockRemainedException: Lock file still present!

As part of development, we tend to use and write functional test cases using Selenium. The Selenium IDE integration with Firefox is seamless and it's very easy to record the user actions and just get the functional test case code out of it. With the latest version of Firefox 3.6.3, I've faced issue of "parent.lock" file on my Windows box and "parentlock" file on linux box with error
org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher$FileLockRemainedException: Lock file still present!

The internet search was not proving to be useful and the Selenium Test cases are refusing to launch the Firefox browser because of this parentlock files. These files are getting created under the custom profile being prepared by firefox for each browser session and remains in that folder, if firefox is not properly closed. Also, on windows, I've found problem of Firefox process still running even if browser is closed and not getting closed automatically. You've to manually go to the Task Manager and kill the process of Firefox.

So, overall the situation was not good for the Selenium Test cases to run. The log was clearly indicating issue with Custom Profile and server jar. So, there must be some issue with it. If it'd have run on Linux and not on Windows, it'd have been easy for me to crib about Microsoft, but that was not the case here.

I had Selenium Server 1.0.1 jar, so I decided to digg into this jar.

Explode the jar in a location and digg through it, you'll find the restriction placed in this jar as...





{ec8030f7-c20a-464f-9b0e-13a3a9e97384}
1.4.1
3.5.*




Ahhh.... that seems to be the problem. I've gone ahead and edited "install.rdf" files under selenium-server-1.0.1-standalone.jar\customProfileDirCUSTFFCHROME to support max version as 3.6.*. The updated install.rdf file have contents as below...





{ec8030f7-c20a-464f-9b0e-13a3a9e97384}
1.4.1
3.6.*





Then just re-build the jar file and then just use the newly build jar file.

And whoilla !!! it seems to have worked smoothly on both Linux and Windows.

I'm sure this will be fixed in next releases of Selenium Server, but as of now, who are facing the issues with it, they can solve it by above method.

Tuesday, January 12, 2010

Java Web UI Functional Testing with Selenium

All of us required to write Functional test cases for the Web UI. As Java developers, we are not used to write Web UI automated test cases and it is really a cumbersome job to write those test cases. It requires a lot of learning curve and lot of experience to write really good UI test cases, that are automated.
But wait, here comes the simple and free to use rescue. The Selenium. It comes with an easy to use and interactive IDE, that we can leverage to record our Web UI workflow and it will generate Java Test Cases for us. Moreover, it has support for not only Java, but different technologies like C#, Perl, PHP, Ruby, Groovy etc.

Selenium IDE is a great tool to quickly write the automated test cases for web UI. for Selenium tests.It can be downloaded and installed as a Firefox extension, and it allows you to record, edit, and debug tests. More information is at Selenium Site

Simply download the Selenium IDE to your firefox. Then start the application server, where you are running your web app and open web UI in firefox.
  1. Go to Tools -> Selenium IDE and it will open up interactive IDE.
  2. You can click on record icon and start recording your web actions.
  3. Once it is over, go to IDE and stop recording and see your actions got recorded.
  4. You can edit the code using wonderful facilities of Selenium IDE using Xpath and other simple syntax.
  5. Run the test through Selenium and see the test results.

You can also get the Java code of the Selenium recording.
In Selenium IDE, go to Options -> Format -> Java. And you will get the Java Junit / TestNG
code for your WebUI functional testing.

Ajax and Selenium Issues:
Now, if you're using Ajax based Web UI, it may happen that Selenium tries to test the component before Ajax request actually getting processed.
  • So, if you are running from Selenium IDE, slow down the speed of test.
And in Java code, just add one line as per the requirement.


//This is important step to set the speed as per test case
//It requires the Selenium to wait for Ajax components to load and available
//If you're setting low speed, you may encounter element not found, because
//Selenium will try to access components, before they are loaded.
selenium.setSpeed("1000");


Windows Vista and Selenium Issues:
In Windows Vista, due to User Account Control, when you run from normal command prompt, you may encounter Firefox crash or firefox chrome registration issues. In order to solve these issues, just run command prompt as an administrator and run your Selenium test cases through it.

Selenium and Maven Integration:
Selenium has very good support with Maven Integration. Just do some google search and you'd get lots of references about how to integrate and run through.
A simple and good example is present at: Selenium-Maven Integration