06 November 2017

Accessing Web Table using UFT

Set brw = Browser("micclass:=Browser").Page("micclass:=Page"

Row = brw.WebTable("micclass:=WebTable""index:=0").RowCount
col = brw.WebTable("micclass:=WebTable""index:=0").ColumnCount(1)

Msgbox "Row : " & Row & " Col : " & col 

brw.WebTable("micclass:=WebTable""index:=0").ChildItem(2,1,"WebButton",0).click
brw.WebTable("micclass:=WebTable""index:=0").ChildItem(2,2,"WebCheckBox",0).set "ON"
brw.WebTable("micclass:=WebTable""index:=0").ChildItem(2,3,"WebEdit",0).set "Test1"
brw.WebTable("micclass:=WebTable""index:=0").ChildItem(2,2,"WebCheckBox",0).set "OFF"
b = brw.WebTable("micclass:=WebTable""index:=0").ChildItem(2,5,"WebList",0).GetROProperty("items count")
b1 = brw.WebTable("micclass:=WebTable""index:=0").ChildItem(2,5,"WebList",0).GetROProperty("all items")

Msgbox "Total Items : "&b&" Items are: "&b1
brw.WebTable("micclass:=WebTable""index:=0").ChildItem(2,5,"WebList",0).Select "Mercedes"
brw.WebTable("micclass:=WebTable""index:=0").ChildItem(2,5,"WebList",0).Select "Audi"
Browser("micclass:=Browser").Page("micclass:=Page").WebEdit("index:=1").Set "Test2"

Browser("micclass:=Browser").Page("micclass:=Page").WebRadioGroup("index:=1").Select "choice2"

Browser("micclass:=Browser").Page("micclass:=Page").WebCheckBox("index:=1").Set "ON"
Browser("micclass:=Browser").Page("micclass:=Page").WebList("index:=1").Select "D"

l1 = Browser("micclass:=Browser").Page("micclass:=Page").WebList("index:=1").GetROProperty("items count")   'Get total number of items present in a List

l2 = Browser("micclass:=Browser").Page("micclass:=Page").WebList("index:=1").GetROProperty("all items")   'Get All the Items name present in a List

Msgbox "Total Items : "&l1&" Items are: "&l2
Msgbox "Total Items : "&l1&" Items are: "&l2



... Use this HTML page to test the above code ...

Save this with .html and then perform the above operations - 

<!DOCTYPE html>
<html>
<body>
<h1>First Heading</h1>
<p>First paragraph ... </p>

<table class="dynatable">
        <thead>
            <tr>
                <th><button class="add">Add</button></th>
                <th>ID</th>
                <th>Name</th>
                <th>Col 3</th>
                <th>Col 4</th>
                <th><button style="width: 100px; height: 25px" class="addColumn">Add Column</button></th>
            </tr>
        </thead>
        <tbody>
            <tr class="prototype">
                <td><button class="remove">Remove</button>
                <td><input type="checkbox" name="id[]" value="" class="id" /></td>
                <td><input type="text" name="name[]" value="" /></td>
                <td><input type="text" name="col4[]" value="" /></td>
<TD class = "select">Online Password
<select>        
                <option value="volvo">Volvo</option>
                <option value="saab">Saab</option>
                <option value="mercedes">Mercedes</option>
                <option value="audi">Audi</option>
        </select>
           </tr>
    </table>

<p>Second paragraph ... </p>

<p>
<input type="text" name="mail1" size="25">
<input type="text" name="mail2" size="25">
<input type="text" name="mail3" size="25">
</p>
<p>
<input type="radio" name="choices1" value="choice1">
<input type="radio" name="choices2" value="choice2">
<input type="radio" name="choices3" value="choice3">
</p>
<p>
<input type="checkbox" name="checkbox1">
<input type="checkbox" name="checkbox2">
<input type="checkbox" name="checkbox3">
</p>
<p>
<select name="continent" size="1">
  <option value="A">A</option>
  <option value="B">B</option>
  <option value="C">C</option>
  <option value="D">D</option>
  <option value="E">E</option>
</select>
</p>

</body>
</html>


No comments:

Post a Comment

AOM - Automation Object Model

'Creating QuicTest Object Set  qtapp =  createobject ( "QuickTest.Application" ) 'Launching the Application If  qtapp...