百度页面的搜索验证 则试步骤 1. 打开百度页面 2. 登录一个已有的百度帐号,并验证登录成功 3. 修订搜索设置(登录按钮旁边的设置按钮),并验证设置结果 a.不显示天气预报 b.搜索结果在新窗口打开 4.搜索内容 [福州天气,,验证正确搜索到相关内容 5. 打开福州天气页面,并在log中打印出当前时间的具体天气以及温度 却本要求: 1. 用robotframework 脚本开发 2.每个测试步骤要有具体的测试说明,测试过程,测试结果验证 3. 测试结果验证需要有截图可以查看(截图在生成的r 1og,具体实现方案可查找资料) 4. 脚本至少需要卦装2个以上关键字,并调用
时间: 2023-03-04 10:57:31 浏览: 132
仿百度登录页面验证效果
5星 · 资源好评率100%
好的,以下是使用robotframework编写的测试脚本,满足要求1-4:
```
*** Settings ***
Documentation Baidu search verification test
Library SeleniumLibrary
*** Variables ***
${BROWSER} chrome
${Baidu_URL} https://www.baidu.com/
${Baidu_username} your_username # 替换为你的百度账号
${Baidu_password} your_password # 替换为你的百度密码
*** Test Cases ***
Baidu Search Verification Test
Open Browser ${Baidu_URL} ${BROWSER}
Maximize Browser Window
[Documentation] 打开百度页面
[Tags] search_verification
Wait Until Page Contains Element xpath://input[@name='wd']
${title}= Get Title
Should Contain ${title} 百度一下,你就知道
[Documentation] 验证百度页面已打开
[Documentation] 登录百度账号
[Tags] search_verification
Click Element linktext=登录
Wait Until Page Contains Element xpath://input[@name='userName']
Input Text xpath://input[@name='userName'] ${Baidu_username}
Input Text xpath://input[@name='password'] ${Baidu_password}
Click Element id=loginBtn
Wait Until Page Contains Element linktext=退出
${username}= Get Text css=.user-name
Should Contain ${username} ${Baidu_username}
[Documentation] 验证登录成功
[Documentation] 修订搜索设置
[Tags] search_verification
Click Element css=.s-usersetting-top
Wait Until Page Contains Element xpath://div[text()='高级搜索']
Click Element xpath=//a[text()='高级搜索']
Wait Until Page Contains Element xpath://input[@name='ft']
Click Element xpath=//label[text()='不显示天气预报']/preceding-sibling::input
Click Element xpath=//label[text()='搜索结果在新窗口打开']/preceding-sibling::input
Click Element xpath=//a[text()='保存设置']
Wait Until Page Contains Element css=.s-msgbox-content
${msg}= Get Text css=.s-msgbox-content
Should Contain ${msg} 设置已保存
[Documentation] 验证搜索设置修改成功
[Documentation] 搜索内容
[Tags] search_verification
Input Text xpath://input[@name='wd'] 福州天气
Click Element xpath://input[@value='百度一下']
Wait Until Page Contains Element xpath://div[@class='result-op c-container xpath-log']
${search_results}= Get Element Count xpath=//div[@class='result-op c-container xpath-log']
Should Be Greater Than ${search_results} 0
[Documentation] 验证正确搜索到相关内容
[Documentation] 打开福州天气页面,并获取天气和温度
[Tags] search_verification
Click Element xpath=//a[text()='福州天气预报']
Wait Until Page Contains Element xpath=//div[@class='weather-wrapper']
${temperature}= Get Text xpath=//span[@class='temp
阅读全文