Need help to click a webelement "Click to show or hide grid controls"
I have to click on the webelement on a webtable I am not able to uniquely find the webtable. the below html is for the table. please help.
The hierarchy is as follows:-
The html code for the same is as follows:
<div style="display:inline" id="openGridControls">
<div title="Click to show or hide grid controls" onclick="showHideControls(this)" style="margin-left:1.5px;width:3em;height:1em;border-top:1px solid #BBB ;border-left:1px solid #BBB ;border-right:1px solid #BBB ;background-color:#EEE;border-top-left-radius: 4px 4px;border-top-right-radius: 4px;"> <hr class="style-two"/>
Last edited by kamal4test; 06-27-2014 at 07:12 AM.
Did you try use the DOM & xPath technique to identify the object then click on it?
Just my 2 cents.
Thanks Helen for the response, I have not tried DOM yet.
Originally Posted by HelenPeters
Just want to confirm one thing, can we use DOM if the webelement is in a Frame, when I use to spy the weblement the object structure is as follows:-
But When I am trying recording the same it is displayed as
QTP adds only the path which is sufficient to re identify the objects in object repository, Suggestion would be to create run time object using Description.Create and Then click on it.
There are couple of methods. Use any one fo the following:-
Browser("name:=.*").Page("title:=.*").WebElement(" html id:="&WebElementHtmlId,"html tag:=TD","Index:=0").Click
TableRowCount = Browser("name:=.*").Page("title:=.*").WebTable("ht ml id:="&WebTableHtmlId,"html tag:=TABLE","Index:=0").RowCount
TableColumnCount=Browser("name:=.*").Page("title:= .*").WebTable("html id:="&WebTableHtmlId,"html tag:=TABLE","Index:=0").ColumnCount(TableRowCount)
For r=1 to TableRowCount
For cnt = 1 to TableColumnCount
If GetTextCounter=0 Then
Text = Browser("name:=.*").Page("title:=.*").WebTable("ht ml id:="&WebTableHtmlId,"html tag:=TABLE","Index:=0").GetCellData(r,cnt)
If instr(Text,ElementTextLike) Then
Setting.WebPackage("ReplayType") = 2
Browser("name:=.*").Page("title:=.*").WebTable("ht ml id:="&WebTableHtmlId,"html tag:=TABLE","Index:=0").Object.rows(r-1).cells(cnt).Click
Setting.WebPackage("ReplayType") = 1
Bottom line is for unique identification, you have to use Index property.
thank charanpreet for the response.
can we identify webtable using column names or DIV or SPAN Id. Can you please share the sample for the same.
I found that the column header are unique but starting with Text like "|", how can we use this special character as an object property for the identification of the webtable.
Thank in advance!!
Originally Posted by charanpreet_hora
You can use wild card characters as . .* instead of "|" . You will be able to recognize objects in this way.
Thanks charanpreet I found that there are three webtables(webtable1>webtable2>webtable3)
I am able to uniquely find the webtable1 and webtable2 using DP, not able to find the unique property to find webtable3 and Index is changing i.e. dynamic.
Suppose we have to click on the webelement of <webtable3> , can we find the index relatively or using parent child relationship.
Please have a look and suggest.
Originally Posted by charanpreet_hora
If there are any column names that are unique in the table you need to work with, you can see which table it exists in. Its not my first choice of distinguishing a table, but I have used it. Hopefully the column name wont be used in any of the other two tables in the future.
Instead of finding column names by text, you can try by identifying col and row numbers
obviously column name should lies on the first row if it is not then find the correct row number of the column.
lets consider row number as rNum = 1
cNum = 1
colname1 = B().P().WebTable().GetCellData(rNum, cNum)