擅长:python、mysql、java
<p>就我个人而言,我使用类来定义PageObjects(借鉴cumber/selenium的思想),
包装器来定义小部件的功能
和decorators,用于登录和加载要测试的模块。
这样可以最大限度地重用代码,并将维护开销降至最低。在</p>
<p>这也意味着测试可以在编写任何代码之前创建,只要开发人员理解合理地命名小部件并预先定义它们。在</p>
<pre><code>from globals.widgets.QPushButton import QPushButtonWrapper # simple click functions
from globals.toolbars.sometoolbar import SomeToolBar
class SomeFormPO(PageObject): #PageObject has some "lazy ok and cancel methods"
def __init__(self):
name = <symbolic name>
PageObject.__init__(self, name)
self.some_tool_bar = SomeToolBar() # contains defines for toolbar e.g.
# self.some_button = QPushButtonWrapper(<symbolic name of button>)
</code></pre>
<p>那么在你的测试中:</p>
^{pr2}$
<p>这里不是详细描述方法的地方,但是如果您阅读:</p>
<p><code>UI Tests with Cucumber (5 part blob series) <http://www.cheezyworld.com/2010/11/09/ui-tests-not-brittle/></code>\u<em>(Ruby)</em>
<code>Selenium on PageObjects <http://code.google.com/p/selenium/wiki/PageObjects></code>(Java)</em></p>
<p>你将了解所使用的原则。在</p>