Discussion:
[wtr-general] Re: Log file for test results
Aqua
2017-11-04 09:21:41 UTC
Permalink
Hi All,

I am new to Watir and Ruby. I am trying to create a Log file to capture log
messages to
1. validate successful google search and
2. unsuccessful google search attempt

I am using Eclipse IDE for executing the ruby scripts. Here is the code
that I am trying

require 'watir'
require 'logger'

$log = Logger.new('log.txt')
$browser = Watir::Browser.new :chrome
$browser.goto('http://www.google.com')
$browser.text_field(:name,'q').set 'Quality Assurance'
$browser.button(:name,'btnK').click

begin
assert($browser.pageContainsText("Quality Assurance"))
$log.info("Given search text showed up!")
rescue
$log.error("Given search text did not show up!")
end

The code was running fine before I added the begin.... and ....end blocks.
(Also is the log file generated in the Ruby folder by default?)
Could someone help me out with this?
Thanks in advance.
Hi All,
Is it possble to generat log files Using Watir. I am using
Ruby+ Watir for my Testing. Test results and exceptions are appearing
in command line. Instead of that, is possible to catch those test
results and exceptions in log files.
Thanks in advance and appreciate your help.
Regards,
Prasad
--
--
Before posting, please read http://watir.com/support. In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to watir-general+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Chuck van der Linden
2017-11-06 19:50:57 UTC
Permalink
Post by Aqua
Hi All,
I am new to Watir and Ruby. I am trying to create a Log file to capture
log messages to
1. validate successful google search and
2. unsuccessful google search attempt
I am using Eclipse IDE for executing the ruby scripts. Here is the code
that I am trying
require 'watir'
require 'logger'
$log = Logger.new('log.txt')
$browser = Watir::Browser.new :chrome
$browser.goto('http://www.google.com')
$browser.text_field(:name,'q').set 'Quality Assurance'
$browser.button(:name,'btnK').click
begin
assert($browser.pageContainsText("Quality Assurance"))
$log.info("Given search text showed up!")
rescue
$log.error("Given search text did not show up!")
end
The code was running fine before I added the begin.... and ....end blocks.
(Also is the log file generated in the Ruby folder by default?)
Could someone help me out with this?
Thanks in advance.
Post by Aqua
Hi All,
Please do not play necromancer and raise 9 year old threads from the dead.

The 'logger' gem (from what I can see) appears not to have had any commits
for a very long time, and is likely not being maintained. I would
consider looking at a logging gem that shows signs of more current
maintenance (and thus by implication, support) The two most likely
suspects I see are:
Logging <https://github.com/TwP/logging>
Timber <https://github.com/timberio/timber-ruby>
--
--
Before posting, please read http://watir.com/support. In short: search before you ask, be nice.

watir-***@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+***@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to watir-general+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...