在这篇 StackOverflow 帖子中, Bryan Oakley 建议对 AppiumLibrary 进行子类化,并举了一个这样做的例子。我正在尝试这样做,但我似乎无法让它发挥作用。例如:
ActivePython 2.7.2.5 (ActiveState Software Inc.) based on
Python 2.7.2 (default, Jun 24 2011, 12:20:15)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.
>>> from AppiumLibrary import AppiumLibrary
>>> class foo(AppiumLibrary):
… pass
…
>>> f = foo()
>>> print f
<__main__.foo object at 0x102097bd0>
>>> print f.__dict__
{‘_running_on_failure_routine’: False, ‘_screenshot_index’: 0, ‘_run_on_failure_keyword’: ‘Capture Page Screenshot’, ‘_element_finder’: <AppiumLibrary.locators.elementfinder.ElementFinder object at 0x1036f7e50>, ‘_timeout_in_secs’: 5.0, ‘_bi’: <robot.libraries.BuiltIn.BuiltIn object at 0x1036f7d50>, ‘_cache’: <AppiumLibrary.utils.applicationcache.ApplicationCache object at 0x1036f7d90>}
>>> f.OpenApplication()
Traceback (most recent call last):
File “<stdin>”, line 1, in <module>
AttributeError: ‘foo’ object has no attribute ‘OpenApplication’
为什么这对 Bryan 和 AronS 有效,而现在对我无效?
谢谢,马丁