13
Property Name Description abs_x The object's absolute x-coordinate (left) relative to the screen (in pixels). abs_y The object's absolute y-coordinate (top) relative to the screen (in pixels). border The width of the object's border. class The object's class (className property). cols The number of columns in the table. height The object's height (in pixels). html id The object's HTML identifier. html tag The object's HTML tag. index The ordinal identifier that QuickTest assigns to the object to indicate the order in which the object appears in the code relative to other objects with an otherwise identical description. This property cannot be used with GetROProperty. innerhtml The HTML code contained between the object's start and end tags. innertext The text contained between the object's start and end tags. location The ordinal identifier that QuickTest assigns to the object to indicate where the object appears within the window, frame, or dialog box. Values are assigned from top to bottom, and left to right. This property cannot be used with GetROProperty. name The object's name. outerhtml The object's HTML code and its content. Supported in Internet Explorer only. outertext The object's text. Supported in Internet Explorer only. RepositoryNam e The name of the object as it is stored in the object repository. Note: This property is relevant only when working in the Siebel Test Automation environment with the Siebel Add-in loaded. rows The number of rows in the table. SiebelObjType The type of object that the HTML element represents. Note: This property is relevant only when working in the Siebel Test Automation environment with the Siebel Add-in loaded. text The text associated with the object. UIName The name of the object as it appears in the user interface. Note: This property is relevant only when working in the Siebel Test Automation environment with the Siebel Add-in loaded. visible Indicates whether the object is visible.

Web Table Methods

Embed Size (px)

DESCRIPTION

tables

Citation preview

Page 1: Web Table Methods

Property Name

Description

abs_x The object's absolute x-coordinate (left) relative to the screen (in pixels).

abs_y The object's absolute y-coordinate (top) relative to the screen (in pixels).

border The width of the object's border.

class The object's class (className property).

cols The number of columns in the table.

height The object's height (in pixels).

html id The object's HTML identifier.

html tag The object's HTML tag.

index The ordinal identifier that QuickTest assigns to the object to indicate the order in which the object appears in the code relative to other objects with an otherwise identical description. This property cannot be used with GetROProperty.

innerhtml The HTML code contained between the object's start and end tags.

innertext The text contained between the object's start and end tags.

location The ordinal identifier that QuickTest assigns to the object to indicate where the object appears within the window, frame, or dialog box. Values are assigned from top to bottom, and left to right. This property cannot be used with GetROProperty.

name The object's name.

outerhtml The object's HTML code and its content. Supported in Internet Explorer only.

outertext The object's text. Supported in Internet Explorer only.

RepositoryName The name of the object as it is stored in the object repository. Note: This property is relevant only when working in the Siebel Test Automation environment with the Siebel Add-in loaded.

rows The number of rows in the table.

SiebelObjType The type of object that the HTML element represents. Note: This property is relevant only when working in the Siebel Test Automation environment with the Siebel Add-in loaded.

text The text associated with the object.

UIName The name of the object as it appears in the user interface. Note: This property is relevant only when working in the Siebel Test Automation environment with the Siebel Add-in loaded.

visible Indicates whether the object is visible. Note: Only True and False are valid values for this property. 1 and 0 are not valid values.

width The object's width (in pixels).

x The object's x-coordinate (left) relative to the frame (in pixels).

y The object's y-coordinate (top) relative to the frame (in pixels).

Object identification properties can be used in the object repository description, in programmatic descriptions, in checkpoint and output value steps, and as argument values for the GetTOProperty

Page 2: Web Table Methods

and GetROProperty methods. The WebTable test object supports the identification properties listed in the table below. For a list of the run-time object's native properties and methods see:

DescriptionA table containing a variable number of rows and columns.

OperationsThe sections below list the built-in methods and properties that you can use as operations for the WebTable object. Note: You can also view a list and descriptions of the WebTable identification properties, for use in object repository descriptions, programmatic descriptions, checkpoint and output value steps, and as argument values for the GetTOProperty and GetROProperty methods.

Methods CaptureBitmap Saves a screen capture of the object as a .png or .bmp image,

depending on the specified file extension.  Check Checks whether the actual value of an item matches the

expected value.  CheckProperty Checks whether the specified object property achieves the

specified value within the specified timeout.  ChildItem Returns a test object from the cell by type and index.  ChildItemCount Returns the number of objects of a specific type in the specified

cell.  ChildObjects Returns the collection of child objects contained within the

object.  Click Clicks the object. QuickTest records clicks with the right mouse

button only if the Web objects and QuickTest Professional are both configured correctly. For more information, refer to the "Testing Web Objects" chapter in the QuickTest Professional Add-ins Guide Help.

 ColumnCount Returns the number of columns in the table.  Drag Performs the 'drag' part of a drag and drop operation.  Drop Performs the 'drop' part of a drag and drop operation.  FireEvent Triggers an event.  GetCellData Returns the text contained in the specified cell.  GetROProperty Returns the current value of the test object property from the

object in the application.  GetRowWithCellText Returns the number of the first row found that contains a cell

with the specified text.  GetTOProperties Returns the collection of properties and values used to identify

the object.  GetTOProperty Returns the value of the specified property from the test object

description.  Output Retrieves the current value of an item and stores it in a

specified location.  RefreshObject Instructs QuickTest to re-identify the object in the application

the next time a step refers to this object.  RowCount Returns the number of rows in the table.  SetTOProperty Sets the value of the specified property in the test object

description.  Submit Submits a form.  ToString Returns a string that represents the current test object.

Page 3: Web Table Methods

 WaitProperty Waits until the specified object property achieves the specified value or exceeds the specified timeout before continuing to the next step.

DescriptionChecks whether the object currently exists in the open application.

Syntaxobject.Exist([TimeOut])

Syntax Details

Argument Description

object A test object of type WebTable.

TimeOut Optional. An ULong object. The length of time (in seconds) to search for the object before returning a True or False value.

If a timeout value is specified, QuickTest waits until it finds the object or until the timeout is reached.

If the value 0 is specified, the property returns the True or False value immediately.

If no value is specified, the value specified in the Test Settings dialog box for the Object Synchronization Timeout is used for tests. For business components, the pre-defined value of 20 seconds is used.

For more information on the Object Synchronization Timeout

ExampleCheck Whether a Browser Window Exists

Sub Exist_Example()'The following example uses the Exist method to determine the'existence of the "Mercury Tours" browser. If the object exists,'a message box appears confirming its appearance.

If Browser("Mercury Tours").Exist Then  MsgBox "The browser exists."End If

End Sub

''Browser("MINDQ RANFORD BANK").Page("MINDQ RANFORD BANK").WebEdit("txtuId").Set "Mercury"''z=Browser("MINDQ RANFORD BANK").Page("MINDQ RANFORD BANK").WebEdit("txtuId").CheckProperty ("value", "Mercury")''msgbox z'''The following example uses the CheckProperty method to verify the''number of items in a WebList. Note that if the original count''is not equal to 15, an error message is displayed in the Test Results.''Browser("Fill-Out Form Example").Page("Fill-Out Form Example").WebList("what-to-do").CheckProperty "items count", 15, TimeLimitation

Page 4: Web Table Methods

'Item_Count = Browser("Fill-Out Form Example").Page("Fill-Out Form Example").WebList("what-to-do").GetROProperty("items count")'If Item_Count = 15 Then' 'Remove one item from the list' Browser("Fill-Out Form Example").Page("Fill-Out Form Example").WebButton("Remove Item From List").Click' 'Check if the item was removed from the list' Browser("Fill-Out Form Example").Page("Fill-Out Form Example").WebList("what-to-do").CheckProperty "items count", 14, TimeLimitation'Else' Reporter.ReportEvent micFail, "Number Of List Items", "The item count in the list should be 15, not " & Item_Count & "."'End If'ChildItem_Example()'The following example uses the ChildItem method to set the second'edit box from the FirstName table to Example.

Set WebEditObj = Browser("Register: Mercury Tours").Page("Book a Flight: Mercury").WebTable("Summary").ChildItem(8, 2, "WebEdit", 0)WebEditObj.Set "Example"

'ChildObjects_Example()'The following example uses the ChildObjects method to find all the'list objects on a Web page, and then to select an item in each list.

Set oDesc = Description.Create() oDesc("micclass").Value = "WebList"Set Lists = Browser("Mercury Interactive").Page("Mercury Interactive").ChildObjects(oDesc) NumberOfLists = Lists.Count()For i = 0 To NumberOfLists - 1 Lists(i).Select i + 1Next

ChildObjects_Example()

'The following example retrieves the collection of'WebEdit objects in order to find a specific'WebEdit object in a page and set a value for it.

Dim EditToSearch, ValueToSet, NumberOfEdits

'This is the value of the 'name' property for the WebEdit object we want to find.EditToSearch = "credit_card_number"

ValueToSet = "3558986773230578"

'Create a description object to help retrieve all WebEdit objects in a specific page.Set oDesc = Description.Create() oDesc("micclass").Value = "WebEdit" oDesc("name").Value = "credit_card_number"

'Retrieve all WebEdit objects in this pageSet EditCollection = Browser("Book a Flight: Mercury").Page("Book a Flight: Mercury").ChildObjects(oDesc)

Page 5: Web Table Methods

NumberOfEdits = EditCollection.Count

'Search for a specific WebEdit object and set its valueFor i = 0 To NumberOfEdits - 1 If EditCollection(i).GetROProperty("name") = EditToSearch Then EditCollection(i).Set ValueToSet End IfNext

ChildObjects_Example()

'The following example retrieves the collection of'WebEdit objects that contain credit card numbers'and inserts them in an Excel file.

Dim NumberOfEdits

'Create a Description object to help retrieve all'WebEdit objects in a specific page.Set oDesc = Description.Create() oDesc("micclass").Value = "WebEdit"

'Retrieve all WebEdit objects from this page.Set EditCollection = Browser("Book a Flight: Mercury").Page("Book a Flight: Mercury").ChildObjects(oDesc)NumberOfEdits = EditCollection.Count

'Use the GetROProperty to retrieve the "text" property'(which in this case represents a credit card number),'and insert all retrieved credit card numbers in an Excel file.For i = 0 To NumberOfEdits - 1 CurrentCreditNumber = EditCollection(i).GetROProperty("text") WriteToCreditCardNumberExcelFile (CurrentCreditNumber)Next

Click_Example()'The following example uses the Click method on a form.

Browser("New Page").Page("New Page").WebElement("html tag:=Form").ClickColumnCount_Example()'The following example uses the ColumnCount method to determine the'number of columns in the first row of the OutboundFlights table.

NumColumns = Browser("Mercury Tours").Page("Search Results").WebTable("OutboundFlights").ColumnCount(1) MsgBox "The number of columns in the row is " & NumColumns

Drag_and_Drop_Example()'The following example uses the Drag and Drop methods to drag a copy of an item from the Inbox pane of'Microsoft Outlook Web Access and drop it in the Junk folder. Then it uses the Drag and Drop methods again'to move the item from the Junk folder to the Deleted Items folder.

Browser("Microsoft Outlook Web").Page("Microsoft Outlook Web_2").Frame("viewer").WebElement("MyEmail").Drag , micNoCoordinate, micNoCoordinate, micCtrl

Page 6: Web Table Methods

Browser("Microsoft Outlook Web").Page("Microsoft Outlook Web_2").Frame("navbar").Link("Junk E-mail").DropBrowser("Microsoft Outlook Web").Page("Microsoft Outlook Web_2").Frame("viewer").WebElement("MyEmail").DragBrowser("Microsoft Outlook Web").Page("Microsoft Outlook Web_2").Frame("navbar").Link("Deleted Items").Drop

FireEvent_Example()'The following example uses the FireEvent method to trigger'the onpropertychange event on a form.

Browser("New Page").Page("New Page").WebElement("html tag:=Form").FireEvent "onpropertychange"

GetCellData_Example()'The following example uses the GetCellData method to display the'contents of the cell located in cell 1, column 1 in a message box.

Set Text = Browser("Mercury Tours").Page("Search Results").WebTable("OutboundFlight").GetCellData(1, 1) MsgBox "text contains" & Text

GetCellData_GetRowWithCellText_Example()'The following example retrieves the names of all employees that live in'the same city as John Smith so that he can arrange rides home with them.'First, the example finds the table row containing'"John Smith". Then it checks the value of the CityColumnn cell to determine'the city in which John lives. It searches the table cells to find all other'employees that live in that city. Finally it uses the GetCellData method to'return those employees names and, using a function, generates a list'containing those names.

CityColumn = 4NameColumn = 2'Get the row number for employee 'John Smith'RowNumber = Browser("CorporateEmployees").Page("CorporateEmployees").WebTable("EmployeesTable").GetRowWithCellText("John Smith")Set AccommodationsCity = Browser("CorporateEmployees").Page("CorporateEmployees").WebTable("EmployeesTable").ChildItem(RowNumber, CityColumn, "WebEdit", 0)TableRows = Browser("CorporateEmployees").Page("CorporateEmployees").WebTable("EmployeesTable").RowCount'Search for all employees that live in the same city as 'John Smith' and add them to his ride home listFor i = 1 To TableRows Set CurrentCity = Browser("CorporateEmployees").Page("CorporateEmployees").WebTable("EmployeesTable").ChildItem(i, CityColumn, "WebEdit", 0) If CurrentCity.GetROProperty("value") = AccommodationsCity.GetROProperty("value") Then EmployeeName = Browser("CorporateEmployees").Page("CorporateEmployees").WebTable("EmployeesTable").GetCellData(i, NameColumn) AddToJohnSmithRideHomeList (EmployeeName)

Page 7: Web Table Methods

End If

NextGetRowWithCellText_Example()'The following example uses the GetRowWithCellText method to'find the row in the "OutboundFlights" table that contains the'text "Price" and then find the cell in that row that contains'a link and click it.

row = Browser("Mercury Tours").Page("Search Results").WebTable("OutboundFlights").GetRowWithCellText("Price", 2, 2)Set Link = Browser("Mercury Tours").Page("Search Results").WebTable("OutboundFlights").ChildItem(row, 2, "Link", 0)Link.Click'The following example checks whether the "url" property exists, and, if not,'generates an error. The example calls the HasPropertyURL(LinkObj) function'(defined below as commented text).

has_url_prop = HasPropertyURL(Browser("Browser").Page("Page").Link("Continue"))

If has_url_prop = False Then Err.Raise 91End If''The following function, used in the above example, uses the GetTOProperties method'to retrieve the list of properties and values for the Link test object in order'to check if a Link test object has the "url" property.''Public Function HasPropertyURL(LinkObj)''PropertyToSearch = "url"'PropertyExistInTO = False'Set PropertyCollection = LinkObj.GetTOProperties''For i = 0 To PropertyCollection.Count - 1'' If PropertyCollection(i).Name = "url" Then' PropertyExistInTO = True' Exit For' End If''Next''HasPropertyURL = PropertyExistInTO''End FunctionGetTOProperties_Example()'The following example uses the GetTOProperties method to retrieve'the list of properties and values used to identify the FirstName'WebTable.

Set TableDesc = Browser("Mercury Tours").Page("Method of Payment").WebTable("FirstName").GetTOProperties

GetTOProperties_Example()'The following example uses the GetTOProperties method to return a'Property collection containing the test object description

Page 8: Web Table Methods

'(properties and values) for the All kind of Link object.'It then displays the property name and value of each property in'the returned collection.

Set LinkObject = Browser("Index").Page("index").Link("All kind of")Set Props = LinkObject.GetTOProperties PropsCount = Props.CountFor i = 0 To PropsCount - 1 PropName = Props(i).Name PropValue = Props(i).Value MsgBox PropName & " = " & PropValueNext

GetTOProperty_Example()'The following example uses the GetTOProperty method to retrieve'the value of the WebTable's HtmlTag property from the Object'Repository.

TableTag = Browser("Mercury Tours").Page("Method of Payment").WebTable("FirstName").GetTOProperty("HtmlTag")' TableTag contains "TABLE"

GetTOProperty_Example()'The following example uses the GetTOProperty method to retrieve the number of items from a WebList'test object containing a list of student names. Then it generates an array according to the list size,'inserting the each of the student's names into the array. Finally, it retrieves each student's name and'uses a function to send grades to the students.

ListSize = Browser("ListOfStudentNames").Page("ListOfStudentNames").WebList("ListOfStudentNames").GetTOProperty("items count")Dim NamesArray()'Dynamically allocate an array according to the list sizeReDim NamesArray(ListSize - 1)

For i = 1 To ListSize NamesArray(i - 1) = Browser("ListOfStudentNames").Page("ListOfStudentNames").WebList("ListOfStudentNames").GetItem(i)Next

'The following function uses the array of student names in order to send grades to the students.SendGradesByStudentName (NameArray)

Output_Example()'The following example uses the Output method to output data from'a link text item.

Browser("Mercury Technologies").Page("Mercury Technologies").Link("Jobs").Output CheckPoint("Jobs")

RefreshObject_Example()

'In the following example, the variable MyLink represents a 'Contact HP' link object.

Page 9: Web Table Methods

'Because the link object exists on every page of the HP Web site, you can perform operations on'this object from different locations in the test. In this example, the second time an operation'is performed on the 'Contact HP' link, the operation is performed from a different Web page'(and thus on a different object, even though its test object description still matches'the one in the object repository).'Therefore, a RefreshObject statement is performed on the MyLink variable to ensure that QuickTest can'successfully identify the object before performing the second Click statement.

Set MyLink = Browser("HP United States - Computers,").Page("HP United States - Computers,").Link("Contact HP")MyLink.ClickBrowser("HP United States - Computers,").SyncMyLink.RefreshObjectRowCount_Example()'The following example uses the RowCount method to determine the'number of rows in the Outbound Flights table.

NumRows = Browser("Mercury Tours").Page("Search Results").WebTable("OutboundFlights").RowCount' NumRows contains 5SetTOProperty_Example()'The following example uses the SetTOProperty method to set the'style of a image's WebElement in run-time.

Browser("New Page").Page("New Page").WebElement("just text").SetTOProperty "Style", "'color:blue'"

SetTOProperty_Example()'The following example uses the SetTOProperty method to set the'html id of the WebFile object.

Browser("Fill-Out-Form").Page("Fill-Out-Form").WebFile("name-of-files").SetTOProperty "html id", 4

SetTOProperty_Example()

'The following example uses the SetTOProperty to add additional'identification properties for QuickTest to use when identifying a test object'whose existing test object description is not enough to identify it.

If Browser("Table with objects").Page("Table with objects").WebEdit("WebEdit").Exist Then Browser("Table with objects").Page("Table with objects").WebEdit("WebEdit").Set "Sunday"Else Set EditObject = Browser("Table with objects").Page("Table with objects").WebEdit("WebEdit") EditObject.SetTOProperty "html tag", "TEXTAREA" EditObject.SetTOProperty "type", "textarea" EditObject.Set "Sunday"End If

ToString_Example()'The following example retrieves a list of links from the'"Simple Web Example" page, creates the FileSystemObject,'and uses the ToString method to write the test object (link) names (for example,

Page 10: Web Table Methods

'"banner" and "contents") and test object type (for example, "Frame")'to c:\Links.txt.

Dim fso, ResultFile, oDesc'Get a collection of all Links in the "Simple Web Example" pageSet oDesc = Description.CreateoDesc("Class Name").Value = "Link"Set oLinkCollection = Browser("Simple XML Example from").Page("Simple Web Example").ChildObjects(oDesc)

'Create the FileSystemObjectSet fso = CreateObject("Scripting.FileSystemObject")Set ResultFile = fso.OpenTextFile("c:\Links.txt", 2, True) ' 2 = Open file for writing

'Write to the fileFor i = 0 To oLinkCollection.Count - 1 ResultFile.Write oLinkCollection.Item(i).ToString & vbNewLineNext ResultFile.Close

ToString_Example()

'The following example uses the ToString method to insert'the test object's name and generic type in the Test Results.

ObjectString = Browser("Fill-Out Form Example").Page("Fill-Out Form Example").WebList("who-to-do-it-with").ToString'Use the ToString to return value to enhance the reporter.Reporter.ReportEvent micDone, "We are selecting the fourth item in the " & ObjectString, ""Browser("Fill-Out Form Example").Page("Fill-Out Form Example").WebList("who-to-do-it-with").Select "#4"WaitProperty_Example1()'The following example uses the WaitProperty method to wait for the'All kind of link's readyState to be complete or for'4 seconds (4000 milliseconds) to pass, whichever comes first.'If the link achieves this value before 4000 milliseconds pass,'QuickTest clicks the link.

If Browser("index").Page("index").Link("All kind of").WaitProperty("attribute/readyState", "complete", 4000) Then Browser("index").Page("index").Link("All kind of").ClickEnd IfWaitProperty_Example2()'The following example uses the WaitProperty method to wait for the'Account edit box to be enabled before setting its value to 123.'If it is still disabled after the test's'Object Synchronization Timeout time has been exceeded, it will not'perform the Set method.

If Browser("index").Page("index").WebEdit("Account").WaitProperty("disabled", 0) Then Browser("index").Page("index").WebEdit("Account").Set ("123")End If

Exist_Example()'The following example uses the Exist method to determine the'existence of the "Mercury Tours" browser. If the object exists,'a message box appears confirming its appearance.

Page 11: Web Table Methods

If Browser("Mercury Tours").Exist Then MsgBox "The browser exists."End IfObject_Example()'The following example uses the .Object property to activate an'edit box's native focus method:

Set MyWebEdit = Browser("Mercury Tours").Page("Mercury Tours").WebEdit("username").ObjectMyWebEdit.focus