簡體   English   中英

如何從網頁復制數據並將其粘貼到文件中以便與ruby,watir和cucumber一起使用?

[英]How do I copy data from web page and paste it in file for further use with ruby, watir and cucumber?

第一個場景作為特征文件registration.feature(feature1)的一部分運行,並具有以下內容:

 Scenario: User can register as a Free account Given I am on the home page When I navigate to the Register page And set all required fields for "Free" on the page And check that info about successful registration is shown And activate account Then I copy the Free user information in a data file 

然后我想在upgrade_accounts.feature(feature2)下運行以下功能

 Feature: Upgrade accounts As an QA Engineer I would like to upgrade my accounts to other types So I can make sure upgrade functionality is working properly Scenario: Existing free account is upgraded to premium Given I navigate to the login page When Sign in as free account retrieved from file And I navigate to updgrade accounts And I select premium account and submit Then Verify premium package is active 

我關心的是如何使用適用於步驟的內容實現這兩個功能之間的連接: Then I copy the Free user information in a data file feature 1中Then I copy the Free user information in a data file到feature1中, When Sign in as free account retrieved from file從feature2上的When Sign in as free account retrieved from file ,將其復制。

所以我想問題是: 最好使用哪種方法(gem)將數據從網頁復制到文件中並讀取並再次使用它?

謝謝!

通常,不鼓勵在功能文件之間創建依賴關系。 您希望能夠使用確定性結果獨立運行要素,因此通過狀態耦合要素可能會產生脆弱(且易碎)的特征。 例如,如果不執行registration.feature ,就不可能成功執行upgrade_accounts.feature

如果你沒有拿起黃瓜書 ,這是很好的指導和資源。 它建議在/support/hooks.rb之前設置應用程序狀態

像Orde所說,每個場景都是獨一無二的:

Scenario: User can register as a Free account
Given I am on the home page
When I register for a free account
Then I get a message that registration is successful
And my account is active

Scenario: Existing free account is upgraded to premium
Given I have a free account
When I updgrade my account to a premium account
Then my premium package is active

兩個功能,兩個完全獨立的測試。 如果您只有一個步驟可以將免費帳戶注入系統如果我有一個免費帳戶 ,您最終將無法升級,因為注冊免費帳戶的步驟失敗。

此外,我冒昧地減少了創建和驗證帳戶的步驟。 在場景中不需要所有導航等。 這是在步驟定義中完成的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM