自动化 Web 访问和 Watir

发布于 2024-09-06 05:09:40 字数 690 浏览 11 评论 0原文

我正在构建一个使用其他几个程序的 Ruby 程序,虽然其中大多数程序都是我可以在这台计算机上下载和运行的程序,但其中一个程序必须通过 Web 浏览器访问和运行。

我实际上有两个问题:我发现 Watir 看起来像是一个很好的网络自动化工具,但它是用于测试的。在主程序中使用 Watir 进行自动化而不是测试还可以吗?或者有更好的东西可以使用吗?

我的另一个问题是我无法让 Watir 工作。我下载了 firewatir-1.6.5 gem 并为 Firefox 3.6 安装了 jssh,但是当我运行

b = Watir::Browser.start("the_web_page_address")

它时,它只是向 Google 打开一个新的 Firefox 窗口,并且出现错误:

Unable to connect to machine : foo.bar.baz.blah on port 9997. Make sure that JSSh is properly installed and Firefox is running with '-jssh' option (Watir::Exception::UnableToStartJSShException)

I've run Firefox with -jssh< /code> 但这似乎没有帮助。

I'm building a Ruby program that uses several other programs, and while most of them are programs I can download and run on this computer, one has to be accessed and run through a web browser.

I actually have two questions: I've found Watir which looks like a good web automation tool, but it's meant for testing. Is it still okay to use Watir for automation in the main program, not for testing? Or is there something better out there to use?

The other question I have is that I can't get Watir to work. I downloaded the firewatir-1.6.5 gem and installed jssh for Firefox 3.6, but when I run

b = Watir::Browser.start("the_web_page_address")

it just opens a new Firefox window to Google, and I'm given the error:

Unable to connect to machine : foo.bar.baz.blah on port 9997. Make sure that JSSh is properly installed and Firefox is running with '-jssh' option (Watir::Exception::UnableToStartJSShException)

I've run Firefox with -jssh but that doesn't seem to help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

超可爱的懒熊 2024-09-13 05:09:40

Watir 非常适合自动化浏览任务。我个人为此目的使用过几次。但是,您可能还想查看其他解决方案,例如 Selenium


现在,说实话,对于你的第二个问题我没什么可说的。
我假设您已通过设置“

Watir::Browser.default = 'firefox'

如果是这样,则一切应该正常运行”来设置 Watir 打开 Firefox。安装jssh后你重启过firefox吗?您是否按照教程中的说明安装了 Watir 和 jssh?

我建议使用 Internet Explorer 而不是 Firefox 运行 Watir,但这可能不适合您的应用程序。如果一切都失败了,请尝试我之前推荐的其他框架。

Watir is perfectly suitable for automating browsing tasks. I've personally used it a couple of times for that purpose. However, you might also want to look at other solutions, such as Selenium.


Now, to be honest, I don't have much to say about your second question;
I'm assuming you've set Watir to open firefox by setting

Watir::Browser.default = 'firefox'

If so, things should be running as normal. Did you restart firefox since installing jssh? Did you install Watir and jssh as instructed on the tutorial?

I can suggest running Watir with Internet Explorer, instead of Firefox, but that might be unsuitable for your application. If all else fails, try the other framework I recommended earlier.

夜司空 2024-09-13 05:09:40

您可能还想查看无头选项。有时,当像 mechanize 这样简单的东西就足够了时,就没有必要安装像 Watir 或 Selenium 这样的自动化框架。实际上取决于您想要自动化的复杂性!

http://mechanize.rubyforge.org/mechanize/EXAMPLES_rdoc.html

You also might want to check out a headless option. Sometimes it's not necessary to install an automation framework like Watir or Selenium when something simple like mechanize would suffice. Really depends on the complexity of what you're trying to automate!

http://mechanize.rubyforge.org/mechanize/EXAMPLES_rdoc.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文