Page 1 of 1

Code Table HTML works only on a single line in the grid

Posted: Sun Aug 04, 2013 9:19 am
by yoad
Hello,
Code Table HTML works only on a single line in the grid
how it does work on a all lines?
I prefer to work without Repository

Code: Select all

            dim repo As EasyadminRepository = EasyadminRepository.Instance
        	Dim someTableTag As TableTag
        	someTableTag = "/dom[@domain='localhost:7019']//div[@id~'gridview-\d\d\d\d']/table"
        	
        	
        	
        	Dim webDocument As WebDocument ="/dom[@domain='localhost:7019']"
'            Dim rows as Integer=repo.OpenLMEasyAdmin2.Table.Find(".//div[@id~'gridview-\d\d\d\d']/table/tbody/tr[2]").Count
'             Dim rows As Integer = repo.HTMLTables.Table.TBody.Find("TR").Count  - 1
             Dim rows As Integer=someTableTag.Find(".//tbody/tr[2]").Count-1
'             If(rows>1) Then
         
        	' List all elements of a table
        	
        	For Each row As TrTag In someTableTag.Find("./tbody/tr[2]")
        		
        		Dim rowInfo As String = ""
        		
        		Dim rowNameCell As TdTag = row.FindSingle("./td[2]")
                

        		
        		'Get all cells from the row
        		rowInfo += "All Cells: "
        		For Each cell As DivTag In row.Find("./td/div")
'
'                    if(cell.InnerText.Length>1) Then
'        			report.Info(cell.InnerText() )
'                    Else
'                    report.Warn(cell.InnerText())
'        			End If
        			' Move the mouse to each cell element
        			cell.MoveTo()
        			' Set css style
        			cell.SetStyle("background-color", "#33ff00")
        			
        		Next
        		
        	

        	Next

        End Sub
    End Module
kind regards,
Yoad

Re: Code Table HTML works only on a single line in the grid

Posted: Tue Aug 06, 2013 1:33 pm
by Support Team
Hello,

Could you please post a little example solution using an example website?
I guess the problem is that you are only searching the second row (tr[2]) in your table. I don't know how your application looks like, but in general you can try to create a loop and increase the index within the "TR" tag.

Regards,
Bernhard

Re: Code Table HTML works only on a single line in the grid

Posted: Wed Aug 07, 2013 9:31 am
by yoad
hello Bernhard,
I have tr empty and tr with data
then I wrote tr[2]
I hope that website is working for you
http://localhost:7019/EasyAdmin2/index.html

i choose start-->Licenses

Kind regards,
Yoad

Re: Code Table HTML works only on a single line in the grid

Posted: Wed Aug 07, 2013 1:46 pm
by yoad
hello again,
I did spy and I add 2 sanpshot files

kind regards,
Yoad

Re: Code Table HTML works only on a single line in the grid

Posted: Thu Aug 08, 2013 12:50 pm
by Support Team
Hello,

Could you please describe in detail what you are trying to do?
Do you want to iterate through each div tag inside your table's tr tags?
If yes you can use the following code:
' ....
For Each row As TrTag In someTableTag.Find("./tbody/tr")

				For Each cell As DivTag In row.Find("./td/div")
					'
					'                    if(cell.InnerText.Length>1) Then
					'                 report.Info(cell.InnerText() )
					'                    Else
					'                    report.Warn(cell.InnerText())
					'                 End If
					' Move the mouse to each cell element
					cell.MoveTo()
					' Set css style
					cell.SetStyle("background-color", "#33ff00")
					
				Next
				
			Next
Regards,
Markus

Re: Code Table HTML works only on a single line in the grid

Posted: Tue Aug 13, 2013 12:46 pm
by yoad
Hello,
I tried your code but it does not work
and I got error message

Ranorex Test Report
Log LevelDebugInfoWarnErrorTest Result Time Level Category Message
2013/08/13 14:38:58.929 ERROR Module No element found for path './td'

then I must write it because I have empty tr and tr with data

For Each row As TrTag In someTableTag.Find("./tbody/tr[2]")

For Each cell As DivTag In row.Find("./td[2]/div")

it working for me but just for singe line in the grid

Re: Code Table HTML works only on a single line in the grid

Posted: Fri Aug 16, 2013 5:35 pm
by Support Team
Hi,

You are getting the error since the first TR tag, representing the header of the grid, doesn't include a TD tag.
You need to add a mechanism that handles this case, in the first iteration the child elements needs to be handled differently.

Regards,
Markus

Re: Code Table HTML works only on a single line in the grid

Posted: Tue Aug 20, 2013 2:14 pm
by yoad
Hello Markus,
You mean that I need to use method "Relationship Operators" in Ranorex User Guide ?

Regards,
Yoad

Re: Code Table HTML works only on a single line in the grid

Posted: Thu Aug 22, 2013 4:50 pm
by Support Team
Hi Yoad,

I meant that the header row (first tr tag) has no div tags and therefore needs to be handled differently.
You could use a code similar to the following one:
Dim headerName as String = "x-grid-header-row"
			Dim className As String = ""
			
			For Each row As TrTag In someTableTag.Find("./tbody/tr")
				
				className = row.Element.GetAttributeValueText("Class")
				
				if className<>headerName Then
					For Each cell As DivTag In row.Find("./td/div")
						'
						'                    if(cell.InnerText.Length>1) Then
						'                 report.Info(cell.InnerText() )
						'                    Else
						'                    report.Warn(cell.InnerText())
						'                 End If
						' Move the mouse to each cell element
						cell.MoveTo()
						' Set css style
						cell.SetStyle("background-color", "#33ff00")
						
					Next
					
				End If
				
			Next
Regards,
Markus

Re: Code Table HTML works only on a single line in the grid

Posted: Sun Aug 25, 2013 2:08 pm
by yoad
Hello Markus,
Thank you
I give you feedback

Kind Regards,
Yoad