简体   繁体   English

使用watir和ruby的webbrowser的自动化

[英]Automation of webbrowser using watir and ruby

I have installed ruby 1.9.2 and watir on my windows 7 system. 我在我的Windows 7系统上安装了ruby 1.9.2和watir。 Now I want to automate my web browser. 现在我想自动化我的网络浏览器。 Suppose there are 10 different links which I want my browser to browse after certain amount of time. 假设有10个不同的链接,我希望我的浏览器在一定时间后浏览。 How do I do this? 我该怎么做呢? I am new to ruby and watir. 我是ruby和watir的新手。 Can someone suggest me how the process of coding would be or suggest me a site or an ebook where I can get material regarding this. 有人可以建议我如何编码过程或建议我一个网站或电子书,我可以得到有关这方面的材料。

Since a lot of the basics of scripting (conditional logic, loops, waiting, etc) are relative to the basic Ruby language and not the specific classes and methods implemented by Watir, I'd suggest starting off with a good book on scripting with Ruby. 由于脚本的许多基础知识(条件逻辑,循环,等待等)都与基本的Ruby语言相关,而不是Watir实现的特定类和方法,所以我建议从一本关于Ruby编写脚本的好书开始。

My favorite is by one of the original folks responsible for Watir itself, Brian Marick " Everyday Scripting with Ruby: for Teams, Testers, and You ". 我最喜欢的是一位负责Watir本身的人,Brian Marick“ 用Ruby编写日常脚本:为团队,测试人员和你 ”。

In terms of watir, there's the tutorials in the Watir wiki , and the book that Zelkjo is working on. 在watir方面,有Watir wiki中的教程和Zelkjo正在编写的书。

The thing you describe, is 90% scripting (repeating a given type of action, with a different input, after a specified time interval) and 10% watir (navigating to the link value), so I'd start with the scripting stuff first. 你描述的东西是90%的脚本(重复一个给定类型的动作,在指定的时间间隔后输入不同的输入)和10%watir(导航到链接值),所以我先从脚本编写的东西开始。

For someone on a budget, I would also offer the following "free" books (I put 'free' in quotes because I'm familiar with all the time and effort that goes into authoring a book, and these are not 'free'. They come at the expense of a lot of blood, sweat and tears on the part of authors/editors etc. who have then been generous enough to then offer up their work without pay. I think calling them 'free' devalues the labor that went into creating them.) 对于预算有限的人,我还会提供以下“免费”书籍(我把'免费'放在引号中,因为我熟悉编写一本书的所有时间和精力,而且这些都不是'免费'。他们以牺牲工作人员/编辑等大量的血汗,泪水为代价,然后他们慷慨地提供他们无偿工作的工作。我认为称他们“免费”贬低了劳动力创造它们。)

  • "Programming Ruby: The Pragmatic Programmers Guide" is often installed by the Ruby installer (depending on version) or can be accessed at the link above. “编程Ruby:实用程序员指南”通常由Ruby安装程序安装(取决于版本),或者可以在上面的链接中访问。 I've used this more as a reference than a learning tool, but it might work for you. 我更多地使用它作为参考而不是学习工具,但它可能对你有用。
  • Why's (Poignant) Guide to Ruby, available in both HTML and PDF versions, is somewhat iconic in the Ruby community. 为什么(Poignant)Ruby指南( HTMLPDF版本都有)在Ruby社区中具有一定的标志性。 I found the writing style amusing and got some good stuff out it it, but then I'v been programming in a variety of languages since the days of teletypes and 110baud acoustically coupled modems. 我发现这种写作风格很有趣并且得到了一些好的东西,但是自从远程类型和110baud声学耦合调制解调器以来,我一直在用各种语言进行编程。
  • Mr. Neighborly's Humble Little Ruby Book - I've not read this one, but it seems well regarded if a tiny bit out of date. 邻居谦虚的小红宝石书 - 我没有读过这本书,但似乎有点过时了。 Aaron Sumner said of it " it's relatively short (under 150 pages) and in a very friendly, accessible tone. If you're still getting familiar with the Ruby language itself, it's as good an introduction as there is out there." Aaron Sumner说它“ 它相对较短(不到150页),而且非常友好,易于理解。如果你还熟悉Ruby语言本身,它就像那里一样好。”

All of those are I think more geared to someone who already understands programming, and not as good for a new tester starting out doing automation. 所有这些都是我认为更适合已经理解编程的人,而不是一个新的测试员开始做自动化的好。 For that you'd be better served spending the money for Marik's book, Since he's worked as a tester, and understands testing, and the book is largely aimed at testers, I thus think you can get far more out of it. 为此,你可以更好地为Marik的书花钱,因为他是一名测试员,并且理解测试,而且这本书主要针对测试人员,因此我认为你可以从中获得更多。 Seriously it may not be free, but consider it an investment in your education and career. 说真的可能不是免费的,但认为这是对你的教育和事业的投资。

I would suggest that you browser Watir web site: http://watir.com/ 我建议您浏览Watir网站: http ://watir.com/

I have also started writing a book (current version is 0.6): 我也开始写一本书(当前版本是0.6):

https://github.com/zeljkofilipin/watirbook https://github.com/zeljkofilipin/watirbook
https://github.com/zeljkofilipin/watirbook/downloads https://github.com/zeljkofilipin/watirbook/downloads

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM