Calabash-Android IF ELSE

时间:2015-06-25 11:51:35

标签: android cucumber calabash

我目前正在使用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"

1 个答案:

答案 0 :(得分:0)

我只是对此有了正确的思考,并意识到我可以做一个"给予"这里。以下是一个例子:

-(BOOL)isConnectedTointernet{
BOOL status = NO;
Reachability *reachability = [Reachability reachabilityForInternetConnection];
int networkStatus = reachability.currentReachabilityStatus;
status = (networkStatus != NotReachable)? YES:NO;
return status;}

在我的葫芦步骤中,我定义了这一步:

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