[译]使用WATiN向Orkut朋友自动生日报废
By robot-v1.0
本文链接 https://www.kyfws.com/applications/automatic-birthday-scrap-to-orkut-friends-using-wa-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 9 分钟阅读 - 4322 个词 阅读量 0[译]使用WATiN向Orkut朋友自动生日报废
原文地址:https://www.codeproject.com/Articles/41886/Automatic-Birthday-Scrap-to-Orkut-Friends-Using-WA
原文作者:jawed.ace
译文由本站 robot-v1.0 翻译
前言
By using this application, Orkut users can send birthday wishes scrap to their friends without fail and even without logging into Orkut site
通过使用此应用程序,Orkut用户可以将生日祝福报废发送给他们的朋友而不会失败,甚至无需登录Orkut网站
- 下载源1.9 MB(Download source - 1.9 MB)
- 下载设置-1.84 MB(Download setup - 1.84 MB)
- 具有Invisible Mode功能的下载安装程序-1.83 MB(Download setup with Invisible Mode functionality - 1.83 MB)
介绍(Introduction)
通过使用此应用程序,Orkut用户可以将生日祝福剪贴簿消息发送给他们的朋友,而不会失败,甚至无需登录Orkut网站.这就像消除人类与网站的互动,同时向Orkut朋友发送生日短信而不错过最近,最亲爱的朋友的生日一样.只需运行该应用程序,您就可以在几秒钟内完成这项工作.您可以设置一个时间,每天在预定义的时间运行此应用程序.(By using this application, Orkut users can send birthday wishes scrap to their friends without fail and even without logging into Orkut site. It is just like eliminating human interaction with website while sending birthday scrap to Orkut friends without missing nearest, dearest friend’s birthdays. Just by running this application, you can finish this work within seconds. You can set a time to run this application on a daily basis at a predefined time.)
实作(Implementation)
您必须使用预定义的时间将此应用程序添加到控制面板调度程序中.并且在预定义的时间,该应用程序将运行并执行您应该在Orkut中执行的所有操作,同时将生日短信发送给您的朋友. :)如果运行此控制台应用程序,我们将看到Internet Explorer浏览器打开并自动完成整个手动过程.那不是很酷吗? :)(You have to add this application in your control panel scheduler with some predefined time. And at the predefined time, this application will run and will do all the operations that you are supposed to do in Orkut while sending birthday scrap to your friend. :) If we run this console application, we will see an Internet Explorer browser opening and automating the entire manual process. Isn’t that cool? :))
背景(Background)
我记得那些日子,我曾经登录过Orkut来检查朋友的生日.如果有的话,我曾经以最好的祝愿报废他们.但是最困难的部分是记住朋友的生日(这是我的经验).假设我们无法在特定的日子(恰好是我朋友的生日)打开Orkut,那就像我们错过了希望的朋友一样.如果隔天我们有机会登录Orkut,则需要用一个迟来的词发送祝福. :(然后,有一天,我认为我们需要一个可以消除痛苦状况的应用程序.该应用程序应该在我的控制下,并且由我自己掌控,并且可以处理所有这些事情.就像计算机在代替我工作一样.经过了数小时的思考,想法和知识的奋斗,我想到一个想法,就是我可以开发一个可以按照我的想法做的应用程序.太好了.:)所以,我很想提出一个应用程序,它可以是我的知识/思想的复制品(I remember those days when I used to login in to Orkut to check for friends' birthdays. if it’s there, then I used to scrap them with best wishes. But the most difficult part is to remember friends' birthdays (that’s my experience). Suppose we were not able to open Orkut on a particular day (that happens to be my friend’s birthday), then it would be like we missed wishing friends. If the next day, we get a chance to login to Orkut, then we need to send wishes with a belated word. :( Then one day I thought we need to have an application which can remove our painful situation. The application should be in my control, in my hand and can take care of all this stuff. It’s like a computer is working in place of me. After struggling for a few hours with my thinking, ideas and knowledge, I came up with an idea that I could develop an application which could do as per my thinking. That’s great. :) So, I would love to present an application which is a replica of my knowledge/idea in)C#. NET和WATIN(C#, .NET and WATIN).(.)
什么是WATiN(What is WATiN)
威丁(WATIN),发音为" What-in",是" .NET中的Web应用程序测试"的首字母缩写. WATiN是一个工具包,用于在Web应用程序开发过程中自动执行基于浏览器的测试.此自动测试工具使用C#语言来驱动Internet Explorer Web浏览器.要了解有关WATiN工具套件的更多信息,请参阅(, pronounced “What-in”, is an acronym standing for “Web Application Testing in .NET”. WATiN is a toolkit used to automate browser-based tests during web application development. This automated test tool uses the C# language to drive the Internet Explorer web browser. To know more about WATiN tool kit, please refer) 到这个链接(to this link) .(.)
使用代码(Using the Code)
为了与Orkut网站互动,我使用WATIN工具作为代码与Orkut网站之间的API互动.对于编程语言,我将C#与.NET 2.0结合使用,希望大家熟悉WATiN.我希望逐行解释该代码,以便我们对如何将WATiN用于自动化目的以及与API等其他目的进行交互(例如与其他网站进行交互)有关的想法.(To interact with Orkut web site, I have used WATIN tool as API interaction between my code and Orkut web site. For programming language, I used C# with .NET 2.0 and I hope that you guys are familiar with WATiN. I would prefer to explain the code line by line so that we will get an idea about how we can use WATiN for automation purposes as well as for other purposes like Interacting with other web sites just like an API.)
流程图((Flow Chart () http://jawedm.blogspot.com(http://jawedm.blogspot.com) )())
-
打开Internet Explorer的新实例(可以处于可见模式).(Open a new instance of Internet Explorer (can be in visible mode).)
-
去(Go to) http://www.orkut.com/(http://www.orkut.com/) .(.)
-
使用预定义的电子邮件ID和密码登录.(Login with predefined email id and password.)
-
转到登录用户主页.(Move to Login User home page.)
-
检查今天是否有朋友的生日,如果是,则转到步骤6,否则转到步骤10(Check if any friends' birthday falls today, if yes, then go to step 6, else step 10)
-
单击链接"留下残骸",然后转到选定的朋友剪贴簿.(Click at link LEAVE a SCRAP and go to selected friend’s scrap book.)
-
键入预定义的生日消息/愿望并张贴该剪贴簿.(Type predefined BIRTHDAY MESSAGE/WISHES and post that scrap.)
-
返回到"登录用户"主页.(Move back to Login User home web page.)
-
进一步检查下一个生日日期(如果今天是今天),请重复步骤6至8.(Further check for the next birthday date, if it falls today, repeat steps 6 to 8.)
-
点击Orkut网站的注销链接.(Click on logout link of Orkut web site.)
-
成功注销后,关闭浏览器.(On successful logout, close the browser.) 现在,将以上步骤放入代码中.(Now let’s put the above steps in code.)
-
打开Visual Studio,然后选择"新建项目"作为控制台应用程序. (我假设您熟悉Visual Studio 2005)(Open Visual Studio and select New project as Console application. (I assume that you are familiar with Visual Studio 2005))
-
转到添加参考并添加(Go to ADD reference and add)**WATiN.core.dll(WATiN.core.dll)**和(and)**Nunitframework.dll(Nunitframework.dll)**在您的项目中.(in your project.)
-
在代码文件中的名称空间下添加以访问WATiN类和方法.(ADD below namespace in your code file to access WATiN classes and method.)
-
我正在使用XML文件存储登录Emailid,密码和生日愿望.最初,我想到将APPconfig用于数据信息,但我改变了主意,因为XML非常易于维护且易于阅读代码,而且最好的部分是任何人都可以轻松使用它.(I’m using XML file to store login Emailid, Password and birthday wish. At first I thought of using APPconfig for Data information but I changed my mind to XML because XML is very easy to maintain and easy to read through the code and the best part is that anybody can easily use this.)
-
因此,首先我们将编写代码以读取登录Emailid,密码和生日愿望.(So first we will write code to read login Emailid, Password and Birthday wish.)读取UserEmailId,密码和愿望报废的XML文件的代码(Code to Read XML File for UserEmailId, Password and wish Scrap)
-
现在我们的实际工作/代码将开始.在本部分中,我们将通过登录Orkut使用WATiN派生Internet Explorer.我们将以隐形模式创建Internet Explorer的新实例.该段代码如下所示:(Now our actual work/code will start. In this section, we will derive Internet Explorer using WATiN through logging in to Orkut. We will create a new instance of Internet Explorer in invisible mode. The piece of code would look like:)
-
通过代码,我们将通过键入以下内容来强制浏览器实例访问Orkut网站(Through the code, we will force the instance of browser to go to Orkut website by typing) http://www.orkut.com/(http://www.orkut.com/) 在地址栏中,然后执行操作.(in the address bar and do the action of go.)
-
现在,在Orkut主页上,我们将为相应的emailid字段和password字段提供Emailid和密码.这些值已经从XML中读取.我认为代码的其余部分很容易理解,因为我包括了注释,以便您可以清晰地看到代码.(Now on Orkut Home page, we will provide Emailid and password to corresponding emailid field and password field. These values are already read from XML. I think the rest of the code is self explanatory to understand as I have included comments so that you can get a clear picture of the code.)
兴趣点(Points of Interest)
连续单击EXE将打开多个浏览器和命令窗口(稍后会发生超时异常).(Successive clicks of EXE open multiple browsers and command windows (Timeout exception occurs later).)为了避免这个问题(To avoid this issue):我用过的概念(: I have used the concept of)互斥体(Mutex).跨进程Mutex的常见用法是确保一次只能运行程序实例. Mutex提供与C#相同的功能(. A common use for a cross-process Mutex is to ensure that only instance of a program can run at a time. Mutex provides the same functionality as C#’s) lock
声明,使得Mutex大部分都是多余的.(statement, making Mutex mostly redundant.)
我学到了什么?(What Did I Learn?)
我从本文中学到的是WATiN不仅仅用于自动化目的.我们也可以将其用于驱动程序/API接口.更重要的是,从现在开始,此应用程序将满足我们的Orkut需求.(My learning from this article was that WATiN is not just for automation purposes. We can use this for Driver/API interface also. And more important is that now onwards this application is going to take care of our Orkut needs.)
结论(Conclusion)
阅读本文之后,我希望我们应该知道如何使用WATiN框架来测试Web应用程序以及如何将其用于API.我认为我们可以使用它进行大量的UI和功能测试,当然也可以使用API或作为驱动程序使用,最好的部分是通过使用此应用程序,我们可以避免登录Orkut发送生日祝福.(After reading this article, I hope that we should know how we can use WATiN framework to test web applications as well as how we can utilize it for API purposes. I think that we can do intensive UI and functional testing with it and of course for API use or as Driver and the best part is that by using this application, we can avoid logging in to Orkut for sending birthday wishes.)
即将到来的申请(Upcoming Application)
- 如何使用WATiN从DIGITE获取/生成缺陷状态,记录的项目以及更多内容,并通过电子邮件将这些生成的报告发送给一群人.(How to use WATiN to get/generate defects status, logged items and many more from DIGITE and send those generated reports through email to a group of people.)
- 我自己使用WATiN开发了一个自动化应用程序,并将该应用程序称为(I have developed an Application for Automation using WATiN myself and called that application as)“使用WATiN的自动化功能图形用户界面测试应用程序”(“An Automated functional graphical user interface testing application using WATiN”).目前,我正在使用此应用程序进行项目自动化.(. Currently I am using this application for automation in my project.) 注意:(Note:)我也包括了自述文件(I have included ReadMe file also with this)**OrkutBirthdayScrap.zip(OrkutBirthdayScrap.zip)**指导您如何使用此应用程序的文件.(file which guides you on how to use this application.)
您可以使用WATiN @访问我的博客以获取更多和最新开发的应用程序(You can visit my blog for more and recent developed applications using WATiN @) http://jawedm.blogspot.com(http://jawedm.blogspot.com) .(.)
历史(History)
- 29(29)日(th)2009年8月:初始职位(August, 2009: Initial post)
- 31(31)圣(st)2009年8月:上传了设置文件并修改了源代码(August, 2009: Uploaded setup file and modified source code)
- 1个(1)圣(st)2009年9月:上传了具有隐形模式功能的设置文件(September, 2009: Uploaded setup file with invisible mode functionality)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C#3.0 C# C#2.0 WinXP Win2003 .NET2.0 Visual-Studio VS2005 Dev Architect 新闻 翻译