2

IOS アプリケーションをテストするためにひょうたんキュウリを使用しています。問題は、検証やその他の操作を行うためのものです。ソースコードから値を取得する必要があります。出来ますか?もしそうなら、どのように?私を助けてください。さまざまなドキュメントを調べましたが、適切な回答が得られませんでした。前もって感謝します。

4

2 に答える 2

1

カスタム属性を設定したい場合、それを行う 1 つの方法は、UI 要素 (UIButton など) をサブクラス化し、次のようにアクセスできるプロパティを作成することです。

例Button.h:

@interface ExampleButton : UIButton
{
  BOOL doingSomething;
}

@property (nonatomic) BOOL isDoingSomething;

ExampleButton.m

#import "ExampleButton.h"

@implementation ExampleButton

... //code possibly here

- (BOOL)isDoingSomething
{
  return doingSomething;
}

... //more code possibley here

そして、doingSomething を設定する他のコードを作成します。

ちなみに、私は iOS と Calabash のテストを始めたばかりなので、目的の C は錆びていますが、doingSomethingBool を持たず@synthesize isDoingSomething、直接プロパティに取得して設定できるものを持っているだけでもよいと思います (self.isDoingSomething = true;など) .

ひょうたんでは、クエリは次のようになります。

query("view:'ExampleButton' isDoingSomething:1") 

また

query("view:'ExampleButton' isDoingSomething:0")

プロパティがそれぞれ true か false かを確認します。

これはおそらく唯一の方法ではありません (おそらく最も簡単な方法ではありませんが、うまくいきます)。

于 2014-02-27T11:25:29.170 に答える
1

calabash-iosquery言語を使用して、セレクターUIViewとそのサブクラスを呼び出すことができます。

calabash-ios を使用した経験がある場合は、この機能を知らずに使用していることでしょう。

# calls the 'text' selector on the labels that match the query
query("label marked:'product description'", :text)

ボタンが有効になっているかどうかを確認するには、次のようにします。

# NB the property is 'enabled', but the selector is 'isEnabled
query("button marked:'ask for help'", :isEnabled")

これは、calabash-ios wiki で説明されています。

https://github.com/calabash/calabash-ios/wiki/03.5-Calabash-iOS-Ruby-API https://github.com/calabash/calabash-ios/wiki/05-Query-syntax

于 2013-12-12T01:40:51.480 に答える