Skip to main content

Selenium/appium-based Page Objects test library.

Project description

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

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

Installation

pip install:

> pip install poium

If you want to keep up with the latest version, you can install with github repository url:

> pip install -U git+https://github.com/SeldomQA/poium.git@master

说明

0.6.0 版本提供了NewPageElement类,用新的方式重新实现了PageElement类的大部分功能。 推荐使用NewPageElement 类。

Sample

Selenium的使用(selenium API)

from poium import Page, NewPageElement
from selenium import webdriver


class BaiduIndexPage(Page):
    search_input = NewPageElement(name='wd')
    search_button = NewPageElement(id_='su')


driver = webdriver.Chrome()

page = BaiduIndexPage(driver)
page.get("https://www.baidu.com")

page.search_input = "poium"
page.search_button.click()

driver.quit()

Selenium的使用(JavaScript API)

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

from poium import Page, CSSElement
from selenium import webdriver


class BaiduIndexPage(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()
  • 只支持 css 定位,所以不需要指定定位方式。
  • 更多的元素操作,例如:remove_attribute()clear_style() ... 等。

appium的使用

支持appium的例子。

from poium import Page, NewPageElement
from appium import webdriver

class CalculatorPage(Page):
    number_1 = NewPageElement(id_="com.android.calculator2:id/digit_1")
    number_2 = NewPageElement(id_="com.android.calculator2:id/digit_2")
    add = NewPageElement(id_="com.android.calculator2:id/op_add")
    eq = NewPageElement(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()

Documentation

请阅读 wiki

  • 在基于pytest的自动化项目中的应用,请点击这里

  • 在基于seldom自动化测试框架的应用,请点击这里

Project History

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

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

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

poium-0.6.4.tar.gz (14.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

poium-0.6.4-py3.7.egg (41.0 kB view details)

Uploaded Egg

poium-0.6.4-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file poium-0.6.4.tar.gz.

File metadata

  • Download URL: poium-0.6.4.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.20.1 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.4

File hashes

Hashes for poium-0.6.4.tar.gz
Algorithm Hash digest
SHA256 3a1cb9ca6b8ab6f0de0c854c6b0a22aa6366dce6cfaa195b4d41847c94f84f45
MD5 bf6e4e7944c619e3f37d22618079dda9
BLAKE2b-256 23f997af0ebd7b32cc7b4320a0f1f56cee5364540204d9a25866c75f36bfd45b

See more details on using hashes here.

File details

Details for the file poium-0.6.4-py3.7.egg.

File metadata

  • Download URL: poium-0.6.4-py3.7.egg
  • Upload date:
  • Size: 41.0 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.7

File hashes

Hashes for poium-0.6.4-py3.7.egg
Algorithm Hash digest
SHA256 d006c28717c501f19371cd9d34c06e62e804383368bcb92c7bd05f2fb1db324b
MD5 1d2527e64bfa93b9c60e8cd6ace5328a
BLAKE2b-256 29bcc783a37bc103bba22750fde91e11d69287caf6fe14755f983993812fcb57

See more details on using hashes here.

File details

Details for the file poium-0.6.4-py3-none-any.whl.

File metadata

  • Download URL: poium-0.6.4-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.20.1 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.4

File hashes

Hashes for poium-0.6.4-py3-none-any.whl
Algorithm Hash digest
SHA256 88467a43c6365e4949cdfbe8ec922fd1cfba7a3e35ee46a956ad6e138b51f836
MD5 fee9f6f42ecfa11031fbedd5d4602d8c
BLAKE2b-256 2118b90ace9cf8e6d1e9830055a0e5259277a158d08607acdb3352294dfb51f0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page