aceishigh
13 years agoContributor
EvaluateXPath Not Working on Firefox or Chrome
Hi All,
I'm using TestComplete 9.0 on 2008 R2 Server. I have a function which extracts the text value of a table cell on a web page if it knows the table ID and text contents of one cell in the desired row. My problem is that it works fine on IE9 but not on Firefox or Chrome. Anyone know why?
I don't think it's my xpath expression as I tested it on Firefox using Firebug and it returned the correct TD cell. The EvaluateXPath function is supposed to return an array but it doesn't do this for Firefox.
My Function is as follows.
Public Function GetTableCellText(strTableID,strRowIdentifier,intCell)
'Assuming you're on the page with the table
Set pg = GetPage
arrCellText = pg.EvaluateXPath("//table[@id='" & strTableID & "']//tr[td//text()[contains(., '" & strRowIdentifier & "')]]/td[" & intCell & "]")
i=0
Do While IsNull(arrCellText) AND (i < 10)
'Refresh the browser
Sys.Desktop.Keys "[F5]"
'Wait for a minute
aqutils.Delay(60000)
arrCellText = pg.EvaluateXPath("//table[@id='" & strTableID & "']//tr[td//text()[contains(., '" & strRowIdentifier & "')]]/td[" & intCell & "]")
i = i + 1
Loop
If Not IsNull(arrCellText) Then
GetTableCellText = aqString.Trim(strCellText, aqString.stAll)
Log.Message "GetTableCellText: ID: " & strTableID & ", Cell Text: " & strCellText
Else
Log.Error "GetTableCellText found no object matching ID: " & strTableID & ", Cell Text: " & strCellText
End If
'Destroy objects
Set pg = Nothing
End Function
I'm using TestComplete 9.0 on 2008 R2 Server. I have a function which extracts the text value of a table cell on a web page if it knows the table ID and text contents of one cell in the desired row. My problem is that it works fine on IE9 but not on Firefox or Chrome. Anyone know why?
I don't think it's my xpath expression as I tested it on Firefox using Firebug and it returned the correct TD cell. The EvaluateXPath function is supposed to return an array but it doesn't do this for Firefox.
My Function is as follows.
Public Function GetTableCellText(strTableID,strRowIdentifier,intCell)
'Assuming you're on the page with the table
Set pg = GetPage
arrCellText = pg.EvaluateXPath("//table[@id='" & strTableID & "']//tr[td//text()[contains(., '" & strRowIdentifier & "')]]/td[" & intCell & "]")
i=0
Do While IsNull(arrCellText) AND (i < 10)
'Refresh the browser
Sys.Desktop.Keys "[F5]"
'Wait for a minute
aqutils.Delay(60000)
arrCellText = pg.EvaluateXPath("//table[@id='" & strTableID & "']//tr[td//text()[contains(., '" & strRowIdentifier & "')]]/td[" & intCell & "]")
i = i + 1
Loop
If Not IsNull(arrCellText) Then
GetTableCellText = aqString.Trim(strCellText, aqString.stAll)
Log.Message "GetTableCellText: ID: " & strTableID & ", Cell Text: " & strCellText
Else
Log.Error "GetTableCellText found no object matching ID: " & strTableID & ", Cell Text: " & strCellText
End If
'Destroy objects
Set pg = Nothing
End Function