seldomqa / seldom Goto Github PK
View Code? Open in Web Editor NEWSeldom automation testing framework based on unittest
Home Page: https://seldomqa.github.io/
License: Apache License 2.0
Seldom automation testing framework based on unittest
Home Page: https://seldomqa.github.io/
License: Apache License 2.0
你好,虫师, , 在你的封装基础上如何运用 POM 。
请赐教!
def assertTitle(self, title, second=3):
'''
Asserts whether the current title is in line with expectations.
The default is 3 seconds.
Usage:
driver.assertTitle("title")
'''
if title == None:
raise NameError("'title' can't be empty.")
for s in range(second):
try:
self.assertIn(title, self.driver.get_title())
break
except AssertionError:
sleep(1)
else:
self.assertIn(title, self.driver.get_title())
上面的else语句是否必要,for循环迭代完为空才执行else语句,但是else语句的执行内容跟for语句里的执行内容是一样的,我的理解再次执行还是没找到,是不是多余了?
{
"url": "https://www.baidu.com",
"elemet":[
["id_=’kw‘","id_='su'"]],
"testdata": [
["seldom", "seldom_搜索结果"],
["poium", "poium_搜索结果"] ]
}
上述json格式的参数,在用例中如何调用?
背景:希望一个页面的url和元素定位参数,输入测试数据统一在一个文件维护
按照文档运行demo有这个问题
OSX,Python2.7
实现点击一个button按住不松,移动到另一个位置,这个功能,先调用click_and_hold函数,再调用move_to_element函数,但是这时候鼠标没有释放,查了下seldom的API,貌似没有封装release函数,click_and_hold+move_to_element+release=selinium中的drag_and_drop函数,seldom中没有对这个函数进行封装
selinium中的drag_and_drop函数有release操作,而seldom中无替代方法,最终通过在move_to_element函数中添加self.w3c_actions.pointer_action.release() 问题解决了。
建议seldom中也提供鼠标释放的方法
https://user-images.githubusercontent.com/77383326/105152671-7000c580-5b42-11eb-9678-b02147df6484.png
�[32m2021-01-20 16:59:19 [INFO] ✅ Find element: xpath=//*[@Class='close-dlg-btn fv__icon-layer-close-white'] �[0m
如图:生成的log中,有多余字符串
1)是因为log中进行了输出设置,不同等级的日志,用不同的颜色区别
这个测试文件parameterized ,在项目里没有找到
我的测试类很多,一个测试类就会开启关闭一个浏览器,怎么改成整个测试过程只开启关闭一次?
RT
一点小建议
1、要是能根据标签分组运行就更好了
2、用例中的业务逻辑和数据如何分离,页面元素发生变化后,如何以最小的代码修改量维护用例
运行报错:cannot import name 'TestCase',望尽快修复哈
File "c:\program files (x86)\python36-32\Lib\subprocess.py", line 997, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
我查找了一下,说是webdriver的路径不对,但我已经在项目目录下使用了seldom -install chrome
,在lib目录下已经有chromedriver,还需要指定chromedriver 的绝对路径吗? 谢谢
import time
import seldom
from seldom import Seldom
from promo_test.PG.login import Login, Reg
class RegTest(seldom.TestCase):
"""Promotion Test"""
def test_promotion(self):
"""
promotion test
"""
page_login = Login(Seldom.driver)
page_reg = Reg(Seldom.driver)
page_login.get("https://promo.stratifyd.cn")
page_reg.register()
time.sleep(600)
def test_login(self):
"""
promotion test
"""
page_login = Login(Seldom.driver)
page_login.get("https://promo.stratifyd.cn")
if __name__ == '__main__':
seldom.main()
如果想只执行test_login, 该怎么执行呀
from seldom.webdriver import WebDriver
class FirstTest(seldom.TestCase):
def test_case(self):
self.open("https://www.baidu.com")
if name == 'main':
webdriver = WebDriver()
webdriver.max_window()
seldom.main(browser="chrome")
请增加断言方法,目前相对元素文本的断言方式好像没有,是否可以增加方面的断言
系统demo:
每页显示10条
每页显示20条
每页显示50条
self.select(css="#nr", value='20')
self.select(css="#nr", text='每页显示20条')
self.select(css="#nr", index=2)
笔者实际用例:
请选择
电话
微信
邮箱
# self.select(css='#ddlSource',text='电话' ) list indices must be integers or slices, not NoneType
# self.select(css="#ddlSource",value='0') list indices must be integers or slices, not NoneType
# self.select(css="#ddlSource",index=2) list index out of range
跪求大佬看看
想问下是否可加入用例运行次数的参数,使某一个用例不管pass与否都能可多次执行
使用assertText断言报错,提示driver找不到
et1.1.2: Traceback (most recent call last):
File "/Users/sleeli/Desktop/programfile/PycharmProjects/testBSC/CRC2.3/test_dir/test_login.py", line 43, in test_login_case
self.assertText("lizhen")
File "/Users/sleeli/.pyenv/versions/3.7.4/lib/python3.7/site-packages/seldom/case.py", line 102, in assertText
elem = self.driver.find_element_by_tag_name("html")
AttributeError: 'LoginPageTest' object has no attribute 'driver'
如题
针对日志记录是否有必要:
A:针对每一个测试用例文件如test1.py 生成对应的专门日志文件吗?
B:还是说日志生成的时候,就会告诉你执行的那一个 *.py文件,执行那个类,执行了那个测试方法?
再引入两个小问题:如何保证以下日志的易用性和整体性!
1、若分布式怎么记录日志?
2、若需要多线程的时候,这个日志又怎么记录?
self.exectue_script(return 元素位置.元素属性)
返回的全是None
页面
<div>
<button onclick="ok()">
<span>确定</span>
</button>
</div>
<div>
<button onclick="cancel()">
<span>取消</span>
</button>
</div>
实现:
import seldom
class Test(seldom.TestCase):
def test_case2(self):
self.get("file:///Users/tech/klpro/github/seldom/test.html")
elems = self.get_elements(xpath="//div/button/span")
i = 0
for elem in elems:
if elem.text == "确定":
i = i
break
else:
i = i + 1
self.click(xpath="//div/button", index=i)
目前使用seldom的实现,比较麻烦,而且也不可靠,提供更加简单可靠的方法。
没有看到检查元素是否存在的api; 使用场景,选择了不同的Type时,之前的页面元素会消失。然后再检查新的元素是否存在
我单独拿取demo、pyse这两个文件夹的代码去运行正常没报错,不知框架里其他的文件是干嘛用的?
The backslash () is a typographical mark (glyph) used mainly in computing and is the mirror image of the common slash (/). --from Wikipedia
显示等待和隐示等待的api建议加载文档内
run.py:
seldom.main(".\dvm\test_open.py",debug=False)
通过run.py运行无法执行case,但是单独运行test_open.pycase可以执行成功,浏览器驱动的路径已在环境变量中配置,因此main()没有传入此参数,但是查看seldom源码的test_runner.py和driver.py感觉当没有参数传入时并没有像webdriver.py中那样通过Seldom.driver.current_url获取driver path.请各位同学帮我看下这个问题。
报错如下
usage: seldom [-h] [-V] [--startproject STARTPROJECT] [-r R]
seldom: error: unrecognized arguments: -install chrome
目前一个class中有多个tests时,执行时顺序是按照19,az运行,帮忙提供用户可以自定义顺序方法
比如,登录(loginPage)后需要做下单(orderPage)操作?
比如:driver.find_element_by_css_selector('.new-tj2.active').click()
写成:type(css=".new-tj2.active")
定位不到
有获取请求响应信息的API吗?
您好虫师,请问怎么完成Chrome浏览器用手机模式打开网页的操作呢?
class LoginPage(Page):
la="English"
la_selected=Element(xpath="//span[text()='{}']".format(la),describe=la)
背景:
1.被测页面是有中英韩日四种语言的。。但是测试用例是一样的。只是页面词条不一样
2.同时有些元素定位是需要用到text().所以跟语言有点关系
现在是想在page也面元素够早的时候支持配置这几个参数。英文页面写一个完整的用例
其他中文、日文、韩文,调用英文页面的方法。
要怎么弄比较好?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.