簡體   English   中英

Calabash-Android IF ELSE

[英]Calabash-Android IF ELSE

我目前正在使用calabash-android為我的Android應用程序編寫測試腳本。 我面臨的一個問題是我並不總是知道應用程序應該關閉的路線。

例如,如果我打開一個作業,該作業可能會發出警告,以確認您要在顯示下一個“作業”活動之前打開該作業,但是其他作業可能不會顯示此警告。

我需要的是一種在黃瓜代碼中使用if / else語句分析特定視圖的方法。 有人以前能做到嗎?

以下是我所追求的示例:

Scenario: As a valid user I can log into my app and view my jobs list
When I see "Log In"
Then I enter text "JoeBloggs" into field with id "txtUsername"
Then I enter text "Password123" into field with id "txtPassword"
Then I press "Log In"
And I wait
Then I see "Welcome To The Your Application"
Then I press "Jobs"
And I wait
Then I see "Back"
Then I see "Job Number"
Then I press list item number 2
And I wait
Then I see "Amey Reference"
Then I press view with id "btnStartJob"
And I wait
If I see "Warning" then press "Okay" else I should see "Job Detail"

我剛剛對此進行了適當的思考,並意識到我可以在這里做一個“給定”。 下面是一個示例:

Given that I see "Wrong Device Detected!"
Then I press "Yes"

在葫蘆步驟中,我定義了以下步驟:

Given /^that I see "([^\"]*)"$/ do |text|
    query("* text:'#{text}'")[0]
end

暫無
暫無

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

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