Re: [wtr-general] Problem: Unable to validate HTML Report using Watir

53 views
Skip to first unread message

Željko Filipin

unread,
May 7, 2013, 6:10:08 AM5/7/13
to watir
On Tue, May 7, 2013 at 6:13 AM, v b baba kanchustambham <vbb...@gmail.com> wrote:
Can anyone please let us know the possibility of capturing the report elements and comparing them with the application data

As I said in stack overflow question[1], what is exactly the problem? 

Željko
--

v b baba kanchustambham

unread,
May 9, 2013, 3:06:45 AM5/9/13
to watir-...@googlegroups.com
Hi Filipin,
I am having problem while captuirng data from HTML Report. I have used the method " relationship_in_report = get_element_text(popup, :td, :class, 'A06df9158c527411db1b8fef473271b9a12896')" which is giving me the error "Unable to Return text in td class='A06df9158c527411db1b8fef473271b9a12896': 'Unable to locate element, using :class, "A06df9158c527411db1b8fef473271b9a12896"
I think i should use table methods to capture the data from this reoport but I am not sure which method to use. I am unable to attach screen shot of the HTML report source here also.

Željko Filipin

unread,
May 9, 2013, 6:18:46 AM5/9/13
to watir
On Thu, May 9, 2013 at 9:06 AM, v b baba kanchustambham <vbb...@gmail.com> wrote:
I am unable to attach screen shot of the HTML report source here also.

Do not attach screen shot, but copy/paste relevant HTML.

Željko

v b baba kanchustambham

unread,
May 9, 2013, 11:15:13 PM5/9/13
to watir-...@googlegroups.com
Hi Zeilko,
Below is the portion of HTML source code of the HTML Report from which i want to capture the value "POC_Reports_test" and store it in a varibale so that i can compare this value with the data in my application

><TD ROWSPAN="2" COLSPAN="3"></TD><TD COLSPAN="17"><DIV growRect="true" style="WIDTH:204.21mm;min-width:204.21mm;HEIGHT:33.43mm;" class="Abcc5464c1acc4c48b277f0e6d02ce75e12951"><TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0" COLS="25" LANG="en-US" class="P9c6206ae5b8642a285ee60c6c4ec8c6b_1_r10""><TR><TD style="HEIGHT:0.51mm;WIDTH:0.00mm"></TD><TD style="WIDTH:1.27mm;min-width:1.27mm"></TD><TD style="WIDTH:0.00mm;min-width:0.00mm"></TD><TD style="WIDTH:30.85mm;min-width:30.85mm"></TD><TD style="WIDTH:0.35mm;min-width:0.35mm"></TD><TD style="WIDTH:2.57mm;min-width:2.57mm"></TD><TD style="WIDTH:0.92mm;min-width:0.92mm"></TD><TD style="WIDTH:38.71mm;min-width:38.71mm"></TD><TD style="WIDTH:8.25mm;min-width:8.25mm"></TD><TD style="WIDTH:0.89mm;min-width:0.89mm"></TD><TD style="WIDTH:18.18mm;min-width:18.18mm"></TD><TD style="WIDTH:1.06mm;min-width:1.06mm"></TD><TD style="WIDTH:1.97mm;min-width:1.97mm"></TD><TD style="WIDTH:0.60mm;min-width:0.60mm"></TD><TD style="WIDTH:7.16mm;min-width:7.16mm"></TD><TD style="WIDTH:25.65mm;min-width:25.65mm"></TD><TD style="WIDTH:4.93mm;min-width:4.93mm"></TD><TD style="WIDTH:0.25mm;min-width:0.25mm"></TD><TD style="WIDTH:0.81mm;min-width:0.81mm"></TD><TD style="WIDTH:9.88mm;min-width:9.88mm"></TD><TD style="WIDTH:0.95mm;min-width:0.95mm"></TD><TD style="WIDTH:2.57mm;min-width:2.57mm"></TD><TD style="WIDTH:1.63mm;min-width:1.63mm"></TD><TD style="WIDTH:41.67mm;min-width:41.67mm"></TD><TD style="WIDTH:2.90mm;min-width:2.90mm"></TD></TR><TR VALIGN="top"><TD style="HEIGHT:0.16mm;WIDTH:0.00mm"></TD><TD COLSPAN="11"></TD><TD ROWSPAN="2" COLSPAN="2"><TABLE CELLSPACING="0" CELLPADDING="0" LANG="en-US" style=""><TR><TD style="WIDTH:2.57mm;min-width:2.57mm;HEIGHT:4.76mm;" class="Abcc5464c1acc4c48b277f0e6d02ce75e12818">:</TD></TR></TABLE></TD><TD COLSPAN="11"></TD></TR><TR VALIGN="top"><TD style="HEIGHT:4.61mm;WIDTH:0.00mm"></TD><TD></TD><TD COLSPAN="2"><TABLE CELLSPACING="0" CELLPADDING="0" LANG="en-US" style=""><TR><TD style="WIDTH:30.85mm;min-width:30.85mm;HEIGHT:4.76mm;" class="Abcc5464c1acc4c48b277f0e6d02ce75e12821">Relationship</TD></TR></TABLE></TD><TD></TD><TD><TABLE CELLSPACING="0" CELLPADDING="0" LANG="en-US" style=""><TR><TD style="WIDTH:2.57mm;min-width:2.57mm;HEIGHT:4.76mm;" class="Abcc5464c1acc4c48b277f0e6d02ce75e12824">:</TD></TR></TABLE></TD><TD></TD><TD COLSPAN="2"><TABLE CELLSPACING="0" CELLPADDING="0" LANG="en-US" style=""><TR><TD style="WIDTH:46.96mm;min-width:46.96mm;HEIGHT:4.76mm;" class="Abcc5464c1acc4c48b277f0e6d02ce75e12896">POC_Reports_test</TD></TR></TABLE></TD><TD>

Can you please let me know which method i should use to capture the value "POC_Reports_test"
In similar way we want to capture all the values from HTML report and compare them against the values in application to ensure that values displayed in report are matching with the data in application.
Thanks,
Veera.

v b baba kanchustambham

unread,
May 9, 2013, 11:39:18 PM5/9/13
to watir-...@googlegroups.com
Hi
The report we are trying to generate from out web application is an SSRS Report, just want to add this
 
Veera

Željko Filipin

unread,
May 10, 2013, 4:01:10 AM5/10/13
to watir
On Fri, May 10, 2013 at 5:15 AM, v b baba kanchustambham <vbb...@gmail.com> wrote:

<TD style="WIDTH:46.96mm;min-width:46.96mm;HEIGHT:4.76mm;" class="Abcc5464c1acc4c48b277f0e6d02ce75e12896">POC_Reports_test</TD>

Can you please let me know which method i should use to capture the value "POC_Reports_test"

This should do it:

browser.td(:class => "Abcc5464c1acc4c48b277f0e6d02ce75e12896").text

Željko

v b baba kanchustambham

unread,
May 13, 2013, 7:07:04 AM5/13/13
to watir-...@googlegroups.com
Hi Zeljko,
The code "browser.td(:class => "Abcc5464c1acc4c48b277f0e6d02ce75e12896").text" is giving me an error "Undefinde method td".
here the class value for td is not unique.

Željko Filipin

unread,
May 13, 2013, 8:11:59 AM5/13/13
to watir
On Mon, May 13, 2013 at 1:07 PM, v b baba kanchustambham <vbb...@gmail.com> wrote:
The code "browser.td(:class => "Abcc5464c1acc4c48b277f0e6d02ce75e12896").text" is giving me an error "Undefinde method td".

Which version of Watir do you have?
 
here the class value for td is not unique.

What _is_ unique? How would you find the element manually?

Željko 

v b baba kanchustambham

unread,
May 14, 2013, 12:36:55 AM5/14/13
to watir-...@googlegroups.com
We are using the version 1.8.1 of Watir and to find out the element manually  I am searching the source code by the text 'POC_Reports_test' .
-Veera.

v b baba kanchustambham

unread,
May 14, 2013, 12:38:13 AM5/14/13
to watir-...@googlegroups.com
Here the value for class is dynamic

v b baba kanchustambham

unread,
May 14, 2013, 7:34:54 AM5/14/13
to watir-...@googlegroups.com
I mean to say the :class ' Abcc5464c1acc4c48b277f0e6d02ce75e12896 ' is dynamically changing every time we generate the report.

Željko Filipin

unread,
May 14, 2013, 7:36:28 AM5/14/13
to watir
On Tue, May 14, 2013 at 1:34 PM, v b baba kanchustambham <vbb...@gmail.com> wrote:
I mean to say the :class ' Abcc5464c1acc4c48b277f0e6d02ce75e12896 ' is dynamically changing every time we generate the report.

What is _not_ changing?

Željko

Chuck van der Linden

unread,
May 15, 2013, 6:00:26 PM5/15/13
to watir-...@googlegroups.com
Actually, lets ask that a slightly different way.  If you were a human, looking at the report in a browser, how would you verify it was correct?  what would you look at, how would you know where to locate things?  are there labels or identifiers that are in a fixed relation to the values you need to examine? 

Usually it's possible to construct your tests to mimic that logic, instead of looking for a specific cell location (row,column).

That or if testability is important, you may want to ask your developers to generate HTML that is easier to test and verify, such as giving predictable name or ID values to cells holding specific data that needs to be validated.  Potentially it could cost a LOT less developer time to make a few simple changes to make this stuff easier to automate, than having you have to review it manually, or create brittle unreliable tests that can't be trusted.  
Reply all
Reply to author
Forward
0 new messages