基于selenium/appium的页面对象测试库。

poium的Python项目详细描述


poium

基于 selenium/appium 的 Page Objects 设计模式测试库。

  • 极大的简化了Page层的元素定义。
  • 同时支持selenium和appium
  • 通过JavaScript扩展了selenium API
  • 对原生 API 无损

Installation

download install:

> python setup.py install

pip install:

> pip install poium

Sample

支持Selenium的例子。

frompoiumimportPage,PageElementfromseleniumimportwebdriverclassBaiduIndexPage(Page):search_input=PageElement(name='wd')search_button=PageElement(id_='su')driver=webdriver.Chrome()page=BaiduIndexPage(driver)page.get("https://www.baidu.com")page.search_input="poium"page.search_button.click()driver.quit()

还提供了一套JavaScript封装的API。

frompoiumimportPage,CSSElementfromseleniumimportwebdriverclassBaiduIndexPage(Page):search_input=CSSElement('#kw')search_button=CSSElement('#su')driver=webdriver.Chrome()page=BaiduIndexPage(driver)page.get("https://www.baidu.com")page.search_input.set_text("poium")page.search_button.click()driver.quit()

支持appium的例子。

frompoiumimportPage,PageElementfromappiumimportwebdriverclassCalculatorPage(Page):number_1=PageElement(id_="com.android.calculator2:id/digit_1")number_2=PageElement(id_="com.android.calculator2:id/digit_2")add=PageElement(id_="com.android.calculator2:id/op_add")eq=PageElement(id_="com.android.calculator2:id/eq")# APP定义运行环境desired_caps={'deviceName':'Android Emulator','automationName':'appium','platformName':'Android','platformVersion':'7.0','appPackage':'com.android.calculator2','appActivity':'.Calculator',}driver=webdriver.Remote('http://localhost:4723/wd/hub',desired_caps)page=CalculatorPage(driver)page.number_1.click()page.add.click()page.number_2.click()page.eq.click()driver.quit()

使用poium将元素 定位操作 分离,这将会非常有助于规模化自动化测试用例的编写与维护。

Documentation

请阅读 wiki

Project History

参考项目:https://github.com/eeaston/page-objects

参考项目已经不再维护,我阅读了原项目代码,虽然只有100多行,但设计非常精妙。本项目在此基础上进行开发。

原项目名:https://pypi.org/project/selenium-page-objects/

本项目的核心是 Page Objects设计模式, 于是取了 PO,同时支持selenium/appium,于是取了 ium,那么新的项目命名为:poium

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Kafka producer大量内存使用(泄漏?)   java NullPointerException。。。正在插入数据但无法检索数据[Mysql DB]   java spring+jpa+hibernate=没有可用于当前线程的实际事务的EntityManager无法可靠地处理“persist”调用   getelementbyid在没有ID的情况下如何在java中使用GetElementsById   java有没有一种使用WatchService强制轮询的方法?   java将值从jframe传递给另一个jframe并使用它   Java/Groovy中带重试的反应式事件处理   具有两个包装器元素的java Jackson XML ArrayList输出   java总是在范围内使用不同的随机元素   取消选择java下拉列表值   多线程如何在Java中为对象的不同成员拥有不同的同步块   java如何使用多线程从文本文件中读取输入   java Spring启动附加崩溃命令   java使用公共或单独的actionPerfomed方法有什么区别   java用Spring3.0中的SpEL替换JSP中的EL   java作为windows服务运行应用程序时无法访问共享文件夹   java xml 1.1规范中的“解析数据”是什么意思?   以编程方式设置JComboBox索引时java触发ItemListener   java Android WebView:只加载HTML,不加载JS或CSS(在某些设备中)   Java:计算do/while循环的数量