robot framework web自动化-登录

之前写过通过文字定位元素的方法,却没有走一个完整的流程,本文简述博客园的登录-下翻-退出,登录的拼图验证码暂时跳过

可以把登录的部分抽出来当做登录关键字

脚本如下:

 1     sleep    2    #预防 chromedriver 未启动
 2     Selenium2Library.Open Browser    https://home.cnblogs.com    Chrome    #打开浏览器
 3     sleep    3
 4     Selenium2Library.Maximize Browser Window    #浏览器最大化
 5     sleep    2
 6     Selenium2Library.Click Element    (//a[contains(text(),'登录')])[1]    #点击左侧登录按钮
 7     sleep    2
 8     Selenium2Library.Input Text    //input[@placeholder='登录用户名 / 邮箱']    1xxxxxxxxx    #输入用户名
 9     Selenium2Library.Input Text    //input[@placeholder='密码']    *********    #输入密码
10     sleep    1
11     Selenium2Library.Click Element    //label[contains(text(),'记住我')]    #点击记住我
12     sleep    1
13     Selenium2Library.Click Element    (//span[contains(text(),'登录')])[2]    #点击登录
14     sleep    10
15     #拼图验证码暂时手动操作,本次跳过
16     AutoITLibrary.send    {PGDN}    #按键 page down 下翻
17     sleep    2
18     AutoITLibrary.send    {PGDN}    #按键 page down 下翻
19     sleep    2
20     Selenium2Library.Click Element    //a[contains(text(),'退出')]    #退出
21     Selenium2Library.Close Browser

猜你喜欢

转载自www.cnblogs.com/whycai/p/12234551.html