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 

 

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

转载于:https://www.cnblogs.com/odbc/archive/2009/05/11/watirsendemail.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值