这是从webdriver ui测试模拟后端的简单方法
bemo的Python项目详细描述
bemo(后端模拟)-这是模拟后端的简单方法 webdriver用户界面测试。
安装
使用pip:
安装bemo。$ pip install bemo
…如果要使用python,请安装下面的bemorunning命令 2.7:
$ pip install bemo[py2x]
享受吧!
用法
from selenium import webdriver from selene.conditions import text from selene.tools import set_driver, visit, s import bemo wd = webdriver.Firefox() set_driver(wd) visit('https://accounts.google.com/SignUp') with bemo.Session(wd=wd) as session: handler = session.handle('InputValidator', body={ 'input01': { 'Valid': 'false', 'ErrorMessage': 'Error!', 'Errors': { 'GmailAddress': 'It work.', }, 'ErrorData': [], }, 'Locale': 'ru', }) session.inject() s('#GmailAddress').set('John Snow') s('#submitbutton').click() s('#errormsg_0_GmailAddress').should_have(text('It work.')) handler.assert_called_once_with({ 'method': 'POST', 'url': 'InputValidator?resource=SignUp', })
测试
只需运行tox即可测试包。
许可证
bemo根据mit许可证获得许可。请参阅的许可文件 细节。