Total Pageviews

Thursday, August 18, 2011

Validation of a tool tip

To validate the tooltipof below mentioned site:

https://www.google.com/adsense/g-app-single-1?hl=en&sourceid=aso&subid=ww-en-et-ads&medium=link

selenium.mouseOver(""//img[contains(@id,'tooltipImage')])
Thread.sleep(1000);
selenium.mouseOver("//div[contains(@class,tooltipPopup)]")
Thread.sleep(1000);
selenium.getText("//div[contains(@class,tooltipPopup)]/meta/a")

Launching the Selenium RC - Window Service.

Lunching the selenium RC as window service by following manner:

Here are the steps:
  1. Install the latest Java runtime if you don't have it installed already
  2. Install the Selenium server (e.g. C:\Selenium\selenium-server-1.0.1
  3. Download srvany.exe and instsrv.exe (these are part of the Microsoft Windows Resource Kit - you will need to download the correct version for your OS) and copy these files to a location on your server (e.g. C:\reskit)
  4. Browse to this folder, and type: instsrv "Selenium RC" "C:\reskit\srvany.exe" - this will create the windows service named "Selenium RC", which will now be installed as a Windows service, although it won't start up yet
  5. Open up regedit, and browse to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Selenium RC
  6. Right-click "Selenium RC" in the tree, and click New - Key, and add a key called "Parameters"
  7. Open Parameters, and create a new string value called "Application"
  8. Add the following to the data value for the new string value: "C:\Program Files (x86)\Java\jre6\bin\java.exe" -jar "C:\Selenium\selenium-server-1.0.1\selenium-server.jar", substituting paths to the java exe and the selenium server jar file where appropriate
  9. Load up the windows services console (services.msc) and start the service





Wednesday, August 17, 2011

Launching Broswer using different methods

we can launch the browser by following ways:
  • Using default selenium object.
  • Using webdriver object.
  • Using HTTPCommandProcesser object.
  • Using WebDriver backed Selenium object.

By default selenium object:

    browser=new DefaultSelenium("localhost",4444, "firefox","http://www.google.com");
    browser.start();
    browser.windowMaximize();
    browser.open("http://www.google.com");

By Webdriver Object:
  
    WebDriver browser1;
    browser1=new FirefoxDriver();
    browser1.get("http://www.google.com");

By HTTPCommandProcesser object:

    HttpCommandProcessor browser2;
    browser2= new HttpCommandProcessor("localhost", 4444, "*firefox", "http://www.google.com");
    browser2.start();
    String[] url={"http://www.google.com"};
    browser2.doCommand("open", url);
  
By WebDriver backed Selenium object:
  
    browser1=new FirefoxDriver();
    browser=new WebDriverBackedSelenium(browser1,"http://www.google.com");
    browser.open("http://www.google.com");
    browser.windowMaximize();








How to handle ssl certificate error in selenium rc

Hi all,
when 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.

We have a technique to avoid this problem:
  - create a custom profile;
  - run Firefox using that profile;
  - browse to the HTTPS URL and accept the exception into that profile;
  - 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”