Qtp-gui-objects

提供:Dev Guides
移動先:案内検索

QTP-GUIオブジェクトの操作

スクリプトの実行中に、QTPが相互作用するさまざまなGUIオブジェクトがあります。 したがって、効果的に作業できるようにするために使用する主要なGUIオブジェクトの基本的な方法を知ることが重要です。

テキストボックスでの作業

以下は、実行時にテキストボックスにアクセスする方法です-

  • 設定-テスターがテキストボックスに値を設定するのに役立ちます
  • クリック-テキストボックスをクリック
  • SetSecure -パスワードボックスのテキストを安全に設定するために使用
  • WaitProperty -プロパティ値がtrueになるまで待機
  • 存在-テキストボックスの存在を確認します
  • * GetROProperty( "text")*-テキストボックスの値を取得
  • * GetROProperty( "Visible")*-表示されている場合はブール値を返します

Browser("Math Calculator").Sync
Set Obj = Browser("Math Calculator").Page("SQR Calc").WebEdit("n")

'Clicks on the Text Box
Obj.Click

'Verify if the Object Exist - Returns Boolean value
a = obj.Exist
print a

'Set the value
obj.Set "10000" : wait(2)

'Get the Runtime Object Property - Value of the Text Box
val = obj.GetROProperty("value")
print val

'Get the Run Time Object Property - Visiblility - Returns Boolean Value
x = Obj.GetROProperty("visible")
print x

チェックボックスの使用

以下は、チェックボックスで作業できる主要な方法の一部です-

  • 設定-テスターがチェックボックスの値を「オン」または「オフ」に設定するのに役立ちます
  • クリック-チェックボックスをクリックします。 ONまたはOFFをチェックしますが、ユーザーはステータスを確認できません
  • WaitProperty -プロパティ値がtrueになるまで待機
  • 存在-チェックボックスの存在を確認します
  • * GetROProperty( "name")*-チェックボックスの名前を取得
  • * GetROProperty( "Visible")*-表示されている場合はブール値を返します

'To Check the Check Box
Set Obj = Browser("Calculator").Page("Gmail").WebCheckBox("PersistentCookie")
Obj.Set "ON"

'To UnCheck the Check Box
Obj.Set "OFF"

'Verifies the Existance of the Check box and returns Boolean Value
val = Obj.Exist
print val

'Fetches the Name of the CheckBox
a = Obj.GetROProperty("name")
print a

'Verifies the visible property and returns the boolean value.
x = Obj.GetROProperty("visible")
print x

ラジオボタンの使用

以下は、ラジオボタンを操作できる主要な方法の一部です-

  • * Select(RadioButtonName)*-テスターがラジオボックスを「オン」に設定できるようにします
  • クリック-ラジオボタンをクリックします。 ラジオボタンのオンまたはオフでもテスターはステータスを取得できません
  • WaitProperty -プロパティ値がtrueになるまで待機
  • 存在-ラジオボタンの存在を確認します
  • * GetROProperty( "name")*-ラジオボタンの名前を取得
  • * GetROProperty( "Visible")*-表示されている場合はブール値を返します

'Select the Radio Button by name "YES"
Set Obj = Browser("Calculator").Page("Forms").WebRadioGroup("group1")
Obj.Select("Yes")

'Verifies the Existance of the Radio Button and returns Boolean Value
val = Obj.Exist
print val

'Returns the Outerhtml of the Radio Button
txt = Obj.GetROProperty("outerhtml")
print text

'Returns the boolean value if Radio button is Visible.
vis = Obj.GetROProperty("visible")
print vis

コンボボックスでの作業

以下は、コンボボックスで作業できる主要な方法の一部です-

  • * Select(Value)*-テスターがComboBoxから値を選択するのに役立ちます
  • クリック-オブジェクトをクリックします
  • WaitProperty -プロパティ値がtrueになるまで待機
  • 存在-コンボボックスの存在を確認します
  • * GetROProperty( "Text")*-コンボボックスの選択値を取得
  • * GetROProperty( "all items")*-コンボボックス内のすべてのアイテムを返します
  • * GetROProperty( "items count")*-コンボボックス内のアイテムの数を返します

'Get the List of all the Items from the ComboBox
Set ObjList = Browser("Math Calculator").Page("Statistics").WebList("class")
x = ObjList.GetROProperty("all items")
print x

'Get the Number of Items from the Combo Box
y = ObjList.GetROProperty("items count")
print y

'Get the text value of the Selected Item
z = ObjList.GetROProperty("text")
print z

ボタンの使用

以下は、ボタンで作業できる主要な方法の一部です-

  • クリック-ボタンをクリック
  • WaitProperty -プロパティ値がtrueになるまで待機
  • 存在-ボタンの存在を確認します
  • * GetROProperty( "Name")*-ボタンの名前を取得
  • * GetROProperty( "Disabled")*-有効/無効の場合、ブール値を返します

'To Perform a Click on the Button
Set obj_Button = Browser("Math Calculator").Page("SQR").WebButton("Calc")
obj_Button.Click

'To Perform a Middle Click on the Button
obj_Button.MiddleClick

'To check if the button is enabled or disabled.Returns Boolean Value
x = obj_Button.GetROProperty("disabled")
print x

'To fetch the Name of the Button
y = obj_Button.GetROProperty("name")
print y

webTablesの使用

今日のWebベースのアプリケーションでは、webTablesが非常に一般的になっているため、テスターはWebTablesがどのように動作し、webTablesでアクションを実行するかを理解する必要があります。 このトピックは、webTablesを効果的に使用するのに役立ちます。

Sr.No. Statement & Description
1

if statement

  • if* ステートメントは、ブール式とそれに続く1つ以上のステートメントで構成されます。
2

if…​else statement

  • if else* ステートメントは、ブール式とそれに続く1つ以上のステートメントで構成されます。 条件がTrueの場合。 *if* ステートメントの下のステートメントが実行されます。 条件が偽の場合。 *Else* スクリプトの一部が実行されます
3

if..elseif…​else statement

ブール式で構成される1つ以上の Elseif ステートメントが続き、その後にオプションの* elseステートメント*が続くifステートメント。すべての条件が偽になると実行されます。

4

nested if statements

別の if または elseif ステートメント内のifまたは elseif ステートメント。

5

switch statement

  • switch* ステートメントを使用すると、変数の値のリストを均等にテストできます。
  • html id -テーブルにidタグがある場合、このプロパティを使用することをお勧めします。
  • innerText -テーブルの見出し。
  • sourceIndex -テーブルのソースインデックスを取得します
  • ChildItemCount -指定された行に存在するChildItemsの数を取得します
  • RowCount -テーブル内の行数を取得します
  • ColumnCount -テーブル内の列の数を取得します
  • GetcellData -列と行インデックスに基づいてセルの値を取得します

Browser("Tutorials Point").Sync
' WebTable
Obj = Browser("Tutorials Point").Page("VBScript Decisions").WebTable("Statement")
' Fetch RowCount
x = Obj.RowCount
print x

' Fetch ColumnCount
y = Obj.ColumnCount(1)
print y

' Print the Cell Data of the Table
For i = 1 To x Step 1

   For j = 1 To y Step 1
      z = Obj.GetCellData(i,j)
      print "Row ID : " & i & " Column ID : " & j & " Value : " & z
   Next
Next

'Fetch the Child Item count of Type Link in a particular Cell
z = Obj.ChildItemCount(2,1,"Link")
print z