Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是自动化新手,我已经开始使用 Watir Webdriver 来自动化网站。但是,有些代码可以重复用于多个测试用例。如何将可重用的代码组合成一个可以在每个测试用例中调用的方法?您能否提供参考或示例?
你对方法感兴趣。
这是一个例子:
def automation_snippet @browser.text_field(:id => 'field_id').set 'foo' end
稍后您可能会对类、页面对象和模块感兴趣。
这是基本的红宝石材料。您需要确保您要使用的任何方法也在范围内。
因此,开始的关键字是方法和范围。如果您使用的是 Cucumber,那么您可以在任何步骤定义文件中定义方法,并且它们将在您的所有其他 Cucumber 测试中可用。