开发者

How can I decide my browser (*firefox,*ie) from command line in the rake file?

开发者 https://www.devze.com 2022-12-17 23:23 出处:网络
I have a rake file whic开发者_StackOverflow社区h runs few tasks. I want to run my tests on several browsers without hard-coding it on each test. Any suggestions would be great.Have you considered usin

I have a rake file whic开发者_StackOverflow社区h runs few tasks. I want to run my tests on several browsers without hard-coding it on each test. Any suggestions would be great.


Have you considered using Watir? It provides an abstract interface to browsers for testing including interfaces to Internet Explorer (by default), Firefox (firewatir), Chrome (ChromeWatir) and Safari (SafariWatir) - IE only on Windows (obviously) and Safari only on OS X (I'm not sure, I don't think they've made it work with Safari for Windows).

You basically make either a method or a class which takes the browser and the URI you want to load and loads them using the relevant Watir classes. Then you create Rake tasks which call the relevant method. The advantage of this is you aren't having to work out where Firefox is, and call it differently if it's running or not.

I haven't done any Watir stuff for a while - I'm moved to Celerity/Culerity for browser testing - but even if you aren't using it for testing, you should be able to use it for launching browsers from Ruby across at least Windows and Mac, and possibly Linux too.


I guess the best way would be to traverse the filesystem based on your current OS and finding the executables of the browsers you want.

Maybe you can take the Launchy code and make it do what you want? :)
http://copiousfreetime.rubyforge.org/launchy/

Launchy is helper class for launching cross-platform applications in a fire and forget manner. Currently only launching a browser is supported.

Launchy.open("http://www.ruby-lang.org/")


On OS X, this works for me:

`open #{url}`
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号