Re: [wtr-general] Re: Help with Watir Page Checkers

2010-03-03 Thread Paul Rogers
the error checkers use the standard IE error page. Your app or web server
can override these to display a different page to the user. Youd have to
write your own checker for that.

Paul

On Wed, Mar 3, 2010 at 3:45 AM, yoggy samuelades...@googlemail.com wrote:

 Hi Marek,

 I did what you told me to do and it justs prints a space and nothing
 else. I am not sure the checker which ships with Watir is robust
 enough to check the page response. I think it doesnt raise any
 exception for page which i am testing. The watir page checker code is
 below:

  def check_for_http_error
  # check for IE7
  n = self.document.invoke('parentWindow').navigator.appVersion
  m=/MSIE\s(.*?);/.match( n )
  if m and m[1] =='7.0'
if m = /HTTP (\d\d\d.*)/.match( self.title )
  raise NavigationException, m[1]
end
  else
# assume its IE6
url = self.document.location.href
if /shdoclc.dll/.match(url)
  m = /id=IEText.*?(.*?)/i.match(self.html)
  raise NavigationException, m[1] if m
end
  end
  false

 I dont know ruby too well but it seems to be doing some checks on url
 and body text of page displayed which i dont think would work
 extremely well for all web apps

 The error on page looks like:

 Server Error in '/' Application.
 Access is denied.
 Description: An error occurred while accessing the resources required
 to serve this request. The server may not be configured for access to
 the requested URL.

 Error message 401.2.: Unauthorized: Logon failed due to server
 configuration.  Verify that you have permission to view this directory
 or page based on the credentials you supplied and the authentication
 methods enabled on the Web server.  Contact the Web server's
 administrator for additional assistance.

 so i wrote a custom error checker which uses the
 Net::Http.get_response for ruby and that seems to work okay. The code
 looks like that.

 RESPONSE_CODE_CHECKER = lambda do |browser|
  response = Net::HTTP.get_response(URI.parse(browser.url.to_s))
  raise Watir::Exception::NavigationException unless(response.code =~ /
 2|3\d{2}/ )
 end

 I would appreciate some comments or feeback on this as i am not a ruby
 guru ..

 On Mar 3, 2:39 am, marekj marekj@gmail.com wrote:
  When you run those lines what happens?
 
  begin
browser.add_checker PageCheckers::NAVIGATION_CHECKER
browser.goto(
 http://www.somecrazynonexistantthing.com/reallynonexistant;)
  resuce= e
put e
  end
 
  what is the value of e?
 
  marekj
 
  Watirloo: Semantic Page Objects in UseCaseshttp://
 github.com/marekj/watirloo/
  Support Watir Projecthttp://pledgie.com/campaigns/2982
 
  On Tue, Mar 2, 2010 at 10:16 AM, yoggy samuelades...@googlemail.com
 wrote:
   I have included the raise and it doesnt work still.
 
   I also removed the rescue and puts line
 
   still this doesnt work,
 
   My test stak is using Cucumber + Watir, could this be a reason ...
   Confused :(
 
   --
   You received this message because you are subscribed to the Google
 Groups Watir General group.
   To post to this group, send email to watir-general@googlegroups.com
   Before posting, please read the following guidelines:
 http://wiki.openqa.org/display/WTR/Support
   To unsubscribe from this group, send email to
 watir-general+unsubscr...@googlegroups.comwatir-general%2bunsubscr...@googlegroups.com
   For more options, visit this group athttp://
 groups.google.com/group/watir-general
 
 

 --
 You received this message because you are subscribed to the Google Groups
 Watir General group.
 To post to this group, send email to watir-general@googlegroups.com
 Before posting, please read the following guidelines:
 http://wiki.openqa.org/display/WTR/Support
 To unsubscribe from this group, send email to
 watir-general+unsubscr...@googlegroups.comwatir-general%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/watir-general


-- 
You received this message because you are subscribed to the Google Groups 
Watir General group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general


Re: [wtr-general] Re: Help with Watir Page Checkers

2010-03-03 Thread marekj
Are you using IE8 ? or IE 7?

When using IE 8 the IE#check_for_http_error doesn't raise an error as
expected and always returns false.
in IE7 it works.
The implementation checks for IE 7 condition or assumes it's IE6 (yes,
code was written before IE8 here)
this line
 if m and m[1] =='7.0'
could be patched as:
if ['7.0', '8.0'].member?(m[1])

this would account for both IE7 and IE8 browsers.
it's a bit late for me and I am too lazy to check further.
but I think this is the reason the error is not raise when using checkers.
Also please check the blog post I did a while back on checkers if you
fancy that stuff.
http://rubytester.com/blog/2009/07/27/watir-run-error-checks-callback-in-wait-method.html

hth

marekj

Watirloo: Semantic Page Objects in UseCases
http://github.com/marekj/watirloo/
Support Watir Project http://pledgie.com/campaigns/2982



On Wed, Mar 3, 2010 at 10:01 AM, yoggy samuelades...@googlemail.com wrote:
 Just an update to my previous post. Because the website am testing
 requires some form of LDAP authentication, the RESPONSE_CODE_CHECKER
 code checker i have written fails with a 401 everytime, any ideas as
 to how to fix this???

 On Mar 3, 10:45 am, yoggy samuelades...@googlemail.com wrote:
 Hi Marek,

 I did what you told me to do and it justs prints a space and nothing
 else. I am not sure the checker which ships with Watir is robust
 enough to check the page response. I think it doesnt raise any
 exception for page which i am testing. The watir page checker code is
 below:

  def check_for_http_error
       # check for IE7
       n = self.document.invoke('parentWindow').navigator.appVersion
       m=/MSIE\s(.*?);/.match( n )
       if m and m[1] =='7.0'
         if m = /HTTP (\d\d\d.*)/.match( self.title )
           raise NavigationException, m[1]
         end
       else
         # assume its IE6
         url = self.document.location.href
         if /shdoclc.dll/.match(url)
           m = /id=IEText.*?(.*?)/i.match(self.html)
           raise NavigationException, m[1] if m
         end
       end
       false

 I dont know ruby too well but it seems to be doing some checks on url
 and body text of page displayed which i dont think would work
 extremely well for all web apps

 The error on page looks like:

 Server Error in '/' Application.
 Access is denied.
 Description: An error occurred while accessing the resources required
 to serve this request. The server may not be configured for access to
 the requested URL.

 Error message 401.2.: Unauthorized: Logon failed due to server
 configuration.  Verify that you have permission to view this directory
 or page based on the credentials you supplied and the authentication
 methods enabled on the Web server.  Contact the Web server's
 administrator for additional assistance.

 so i wrote a custom error checker which uses the
 Net::Http.get_response for ruby and that seems to work okay. The code
 looks like that.

 RESPONSE_CODE_CHECKER = lambda do |browser|
   response = Net::HTTP.get_response(URI.parse(browser.url.to_s))
   raise Watir::Exception::NavigationException unless(response.code =~ /
 2|3\d{2}/ )
 end

 I would appreciate some comments or feeback on this as i am not a ruby
 guru ..

 On Mar 3, 2:39 am, marekj marekj@gmail.com wrote:

  When you run those lines what happens?

  begin
    browser.add_checker PageCheckers::NAVIGATION_CHECKER
    
  browser.goto(http://www.somecrazynonexistantthing.com/reallynonexistant;)
  resuce= e
    put e
  end

  what is the value of e?

  marekj

  Watirloo: Semantic Page Objects in 
  UseCaseshttp://github.com/marekj/watirloo/
  Support Watir Projecthttp://pledgie.com/campaigns/2982

  On Tue, Mar 2, 2010 at 10:16 AM, yoggy samuelades...@googlemail.com 
  wrote:
   I have included the raise and it doesnt work still.

   I also removed the rescue and puts line

   still this doesnt work,

   My test stak is using Cucumber + Watir, could this be a reason ...
   Confused :(

   --
   You received this message because you are subscribed to the Google 
   Groups Watir General group.
   To post to this group, send email to watir-general@googlegroups.com
   Before posting, please read the following 
   guidelines:http://wiki.openqa.org/display/WTR/Support
   To unsubscribe from this group, send email to 
   watir-general+unsubscr...@googlegroups.com
   For more options, visit this group 
   athttp://groups.google.com/group/watir-general



 --
 You received this message because you are subscribed to the Google Groups 
 Watir General group.
 To post to this group, send email to watir-general@googlegroups.com
 Before posting, please read the following guidelines: 
 http://wiki.openqa.org/display/WTR/Support
 To unsubscribe from this group, send email to 
 watir-general+unsubscr...@googlegroups.com
 For more options, visit this group at 
 http://groups.google.com/group/watir-general


-- 
You received this message because you are subscribed to the Google Groups 
Watir General group.
To 

Re: [wtr-general] Re: Help with Watir Page Checkers

2010-03-02 Thread marekj
When you run those lines what happens?

begin
  browser.add_checker PageCheckers::NAVIGATION_CHECKER
  browser.goto(http://www.somecrazynonexistantthing.com/reallynonexistant;)
resuce= e
  put e
end

what is the value of e?


marekj

Watirloo: Semantic Page Objects in UseCases
http://github.com/marekj/watirloo/
Support Watir Project http://pledgie.com/campaigns/2982



On Tue, Mar 2, 2010 at 10:16 AM, yoggy samuelades...@googlemail.com wrote:
 I have included the raise and it doesnt work still.

 I also removed the rescue and puts line

 still this doesnt work,

 My test stak is using Cucumber + Watir, could this be a reason ...
 Confused :(


 --
 You received this message because you are subscribed to the Google Groups 
 Watir General group.
 To post to this group, send email to watir-general@googlegroups.com
 Before posting, please read the following guidelines: 
 http://wiki.openqa.org/display/WTR/Support
 To unsubscribe from this group, send email to 
 watir-general+unsubscr...@googlegroups.com
 For more options, visit this group at 
 http://groups.google.com/group/watir-general


-- 
You received this message because you are subscribed to the Google Groups 
Watir General group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general