Not sure what you're considering a failure, but you'll want to use some
exception handling in that case. See below for an example. :none is not a
valid browser so, it'll fail to initialize it, but keep going with some
exception handling.
require 'watir-webdriver'
browsers = [:none,:firefox,:chrome,:safari].each do |br|
begin
b = Watir::Browser.new br
b.goto("google.com")
puts b.title
b.close
rescue => e
puts e.message
next
end
end
On Thursday, September 19, 2013 6:47:54 PM UTC-4, Ankita@Adslot wrote:
>
> Hi Dan
>
> Thanks for your reply. This does work if the script runs without any
> failure, but, in case any failure happens script stops and does not execute
> on other browsers.
>
> I wanted something where even if script fails on one browser, it still
> runs on others to complete the test.
>
> Your help is much appreciated!
>
> On Thursday, September 19, 2013 11:07:48 PM UTC+10, Dan wrote:
>>
>> Not sure what framework you're using or whatever, but you can do this
>> pretty easy with a loop. Below is the basic concept.
>>
>> require 'watir-webdriver'
>> browsers = [:firefox,:chrome,:safari].each do |br|
>> b = Watir::Browser.new br
>> b.goto("google.com")
>> puts b.title
>> b.close
>> end
>>
>> On Wednesday, September 18, 2013 11:57:44 PM UTC-4, Ankita@Adslot wrote:
>>>
>>> Hi
>>>
>>> Just wondering if there is a way I could automate my script to run on
>>> three different browsers one after another...
>>>
>>> wanted something like
>>>
>>> Open Browser1 - firefox
>>> Run script
>>> Close Browser
>>> <output>
>>> Open Browser2 - ie
>>> Run script
>>> Close Browser
>>> <output>
>>> OpenBrowser3- phantomjs
>>> Run script
>>> Close Browser
>>> <output>
>>>
>>>
>>> I know we could initiate browser of our choice through command prompt
>>> and then run the script but just wondering if there is something which
>>> could automate the process rather then running the test manually 3 times
>>> with three different browsers?
>>>
>>
--
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]
---
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.