ruby watir 登陆邮箱

登陆163邮箱:

 1 require "watir" 
 2 test_site = "http://mail.163.com/" 
 3 ie = Watir::IE.new 
 4 ie.goto test_site 
 5 
 6 ie.text_field(:name, "username").clear
 7 ie.text_field(:name, "username").set("test_hi")
 8 ie.text_field(:name, "password").set("*******")
 9 
10 ie.button(:type, "submit").click

本来想写个自动发邮件的脚本,却发现以我现在的水平很有难度

 

登陆gmail并给自己发封邮件: 

 1 require "watir" 
 2 ie = Watir::IE.new 
 3 
 4 username = "zhjmao"
 5 userpass = "******"
 6 
 7 ie.goto "https://www.google.com/accounts" 
 8 #填写登陆信息
 9 ie.text_field(:name, "Email").clear
10 ie.text_field(:name, "Email").set("#{username}")
11 ie.text_field(:name, "Passwd").set("#{userpass}")
12 #点击登陆按钮
13 ie.button(:name, "signIn").click
14 #进入邮箱
15 ie.link(:text , "Gmail").click
16 #打开基本视图
17 ie.goto "https://mail.google.com/mail/h/?v=b&pv=tl&cs=b"
18 #输入收件人,默认为自己
19 ie.text_field(:name, "to").set("#{username}@gmail.com")
20 #输入主题
21 ie.text_field(:name, "subject").set("send email to #{username}@gmail.com")
22 #输入内容
23 ie.text_field(:name, "body").clear
24 ie.text_field(:name, "body").set("send email to #{username}@gmail.com,body")
25 #点击发送按钮
26 ie.button(:name, "nvp_bu_send").click
27 

 

标准视图下撰写邮件那个链接不知道该怎么实现,只好切换成基本视图来发邮件

posted @ 2009-05-11 22:28  Hi,Dan  阅读(446)  评论(0编辑  收藏  举报