Skip to main content

Development

JSSH – the driver of Firefox

This article will reveal you the secret of Watir/Watin.

Background

As popular as Selenium, Watir/Watin is another open source tool which can be used to conduct automated testing on different browsers. To support multiple browsers, drivers of different browsers have been developed by Watir & Watin. And for firefox, JSSH is employed to fulfill the purpose of manipulating the browser.

What is JSSH?
JSSH (JavaScript SHell) is a firefox extension written in C++. Through it, you can run javascript on the remote firefox, which makes it possiblel to manipulate Firefox through methods defined in DOM.

The source code of JSSH is available at http://code.google.com/p/firewatir/source/browse/trunk/?r=131#trunk/Installation

 

An “Hello JSSH” example – Google.com

 

  • You need to install the JSSH extension first. Click here for detail.
  • Start the firefox with JSSH support.
  • firefox -jssh

  • Telnet to the JSSH. The default port is 9997.

telnet localhost 9997

  • In the terminal, enter following javascript line by line.

var w0 = getWindows()[0];
var browser = w0.getBrowser();
browser.loadURI(“http://www.google.com“);
var doc = browser.contentDocument;
var input = doc.getElementsByName(“q”)[0];
var button = doc.getElementsByName(“btnG”)[0];
input.value = “hello JSSH”;
button.click();

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Diego Zhong

More from this Author

Categories
Follow Us
TwitterLinkedinFacebookYoutubeInstagram