如何从 rake 文件中的命令行决定我的浏览器(*firefox,*ie)?
我有一个运行一些任务的 rake 文件。我想在多个浏览器上运行测试,而不是在每个测试中对其进行硬编码。任何建议都会很棒。
I have a rake file which runs few tasks. I want to run my tests on several browsers without hard-coding it on each test. Any suggestions would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您考虑过使用 Watir 吗?它为浏览器提供了一个用于测试的抽象接口,包括 Internet Explorer(默认)、Firefox (firewatir)、Chrome (ChromeWatir) 和 Safari (SafariWatir) 的接口 - IE 仅在 Windows 上(显然),Safari 仅在 OS X 上(我'我不确定,我认为他们没有让它与 Windows 版 Safari 兼容)。
您基本上可以创建一个方法或类,它接受浏览器和您想要加载的 URI,并使用相关的 Watir 类加载它们。然后您创建调用相关方法的 Rake 任务。这样做的好处是您不必知道 Firefox 在哪里,也不必在它运行与否时以不同的方式调用它。
我有一段时间没有做过任何 Watir 的东西了 - 我已经转移到 Celerity/Culerity 进行浏览器测试 - 但即使你不使用它进行测试,你应该能够使用它从 Ruby 启动浏览器至少是 Windows 和 Mac,也可能是 Linux。
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.
我想最好的方法是根据您当前的操作系统遍历文件系统并找到您想要的浏览器的可执行文件。
也许您可以使用 Launchy 代码并使其执行您想要的操作? :)
http://copiousfreetime.rubyforge.org/launchy/
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/
在 OS X 上,这对我有用:
On OS X, this works for me: