How to Install FirePath in FireBug

How To

FireBug logoYou may be familiar with FireBug, a Firefox add-on that lets you edit, debug, and view code from any web site. If you’re delving into automated testing, you’ll also want to use FirePath, a FireBug extension that lets you get the XPath for different web page elements, so that you can interact with them in your tests.

So how do you install FirePath?

Easy! In fact, it only takes two steps:

1. Install FireBug if you haven’t already. Open Firefox, navigate here, and click “+ Add to Firefox.”

2. While still in Firefox, navigate here and click “+ Add to Firefox” to add FirePath.

Voila! You should now have FirePath installed and ready to go. If you need help understanding how to use it, check out this straightforward guide with step-by-step instructions.

Four Ways to Create Strings in Java

How To

Creating strings is one of the easiest things you can do in Java, and there are four main ways to do so.

In the examples below, let’s assume you want to create a string of the word “testing,” using “qa” as the reference word.

Way #1:

String qa;

qa = “testing”;

First, you’re declaring the String type variable, then you’re assigning text to the variable.

Way #2 – String Literal:

String qa = “testing”;

This way, known as “string literal,” is perhaps the most common way of creating a string, and usually the quickest — it’s all done in one line, with the least amount of text.

It’s also less memory-intensive, since it’s stored in what’s called “String Constant Pool.”

Way #3 – String Object:

String qa = new String(“testing”);

As you can see, this way (“string object”) is similar to the second way shown above, but requires extra text. This type of string is stored in Heap Memory.

 

Way #4 – From Array:

char mylist[] = {‘t’, ‘e’, ‘s’, ‘t’, ‘i’, ‘n’, ‘g’};

String qa = new String(mylist);

First, you’re creating an array of each letter in the word “testing.”

Then, you’re converting that array into one string, which consists of the word “testing.”

 

How to Create a Java Project in Eclipse

How To

So you want to create a Java project in Eclipse? Cool. Follow the steps below and get to coding!

Starting a New Java Project in Eclipse:

  1. Open Eclipse and select File –> New –> New Java Project. Give it a name in the resulting pop-up, then click “Next” and then “Finish.” That will create the JRE System Library.
  2. In the left-nav menu, right-click the new source folder (“src”) and select “New” and then “Class.”
  3. Give your new class a name, and under “which method stubs would you like to create?” select “public static void main” and click “Finish.” (If you forget to select public static void main, you can add it after. Once the new class is created, you can type “main” after the first “{” symbol, then control-space and the enter key to create the main method.)
  4. Delete the auto-generated “TO DO” stub in the main method, and add your own code.
  5. To save: File –> Save (or Save As)
  6. To run your code, click the green play button in the top nav and select “Run as —> Java Application.” After the first time, you can simply click the green play button once and it will automatically run that way.

How to Export Java Code from Selenium IDE

How To

Selenium LogoIf you’re reading this, you’re probably familiar with Selenium IDE, a Firefox extension that lets you record actions and turn them into automated test scripts.

Maybe you’ve created your first recording, and now you’re wondering how you can export the raw Java code. Read on for step-by-step instructions!

Getting Java Code from Selenium IDE:

  1. Open Selenium IDE, and select the recording you want to use in the “Test Cases” list (see the left nav)
  2. In the top menu, click “Options” and in the resulting drop-down, select “Options…”
  3. Make sure the option for “Enable experimental features” is checked, and click “OK”
  4. Click on “Options” again in the top menu, and select “Format”
  5. Choose the Java test case format you want the code in — for example, “Java / TestNG / WebDriver”
  6. Copy the code that shows up (in the “Source” tab), and use it however you’d like!

For example, you can create an Eclipse TestNG file and paste the code in there. Just delete any irrelevant placeholder code in your new file, and remove the package name from the top of your Selenium IDE code, as you’ll already have a package name in your Eclipse file.

Do you use a different language than Java in your automated tests? No problem! For step number five above, you can choose Python, Ruby, or C# instead.