O'Reilly logo

Advanced UFT 12 for Test Engineers Cookbook by Jonathon Lee Wright, Meir Bar-Tal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing a simple search class

In this recipe, we will see how to create a class that can be used to execute a search on Google.

Getting ready

From the File menu, navigate to New | Test, and name the new test SimpleSearch. Then, create a new function library by navigating to New | Function Library, or use the Alt + Shift + N shortcut. Name the new function library cls.Google.vbs and associate it with your test.

How to do it...

Proceed with the following steps:

  1. Define an environment variable as OPEN_URL.
  2. Insert the following code in the new library:
    Class GoogleSearch Public Function DoSearch(ByVal sQuery) With me.Page_ .WebEdit("name:=q").Set sQuery .WebButton("html id:=gbqfba").Click End With me.Browser_.Sync If me.Results.WaitProperty("visible", ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required