参考资料
- https://docs.python.org/3/library/typing.html
- https://www.python.org/dev/peps/pep-0484/
- 演练代码地址 https://github.com/seveniruby/HogwartsSDET11
几个关键的技巧
- return self来实现链式调用
- 类型提示 Type Hints
- 导入正确的appium的实现类 from appium.webdriver.webdriver import WebDriver
from appium import webdriver
class WebDriver(
AppiumSearchContext,
ActionHelpers,
Activities,
Applications,
Clipboard,
Context,
Common,
DeviceTime,
Display,
ExecuteDriver,
ExecuteMobileCommand,
Gsm,
HardwareActions,
ImagesComparison,
IME,
Keyboard,
Location,
LogEvent,
Network,
Performance,
Power,
RemoteFS,
ScreenRecord,
Session,
Settings,
Sms,
SystemBars
):
def __init__(self, command_executor='http://127.0.0.1:4444/wd/hub',
desired_capabilities=None, browser_profile=None, proxy=None, keep_alive=True, direct_connection=False):
class Activities(webdriver.Remote):
webdriver.Remote继承自selenium的remote webdriver
appium的webdriver多继承了Activities等多种移动端的扩展实现
appium driver ← Activities ← selenium remote webdriver
PO概念
PO实战
BasePage封装
find封装
作业1
进入行情页,搜索股票并添加自选,然后重新回到行情页。