Xcode の「Instruments」ツールを使用して iOS アプリケーションの自動化を構築していますが、アプリで作成したエントリのラベルが正しいことを確認する必要があります。
以下にリストされているコードは、何らかの理由で、確実な合格または不合格になりません。むしろ、実行すると、ログに「問題」の警告が表示され、明示的に閉じずにテストが終了します。
自動化の実行後に AccessibilityViewer で確認できるため、作成されていることがわかっているラベル名を確認するようにテストを変更したいと考えています。
ラベルが正しければ、テストを合格として記録したいと思います。
以前UIATarget.localTarget().logElementTree()
は要素ツリーをマッピングし、AccessibilityInspector を使用して、エントリが作成された後にラベルの名前を確認しました。問題は、これが正しいことを確認するための構文を取得できないように見えることです。
My Accessibility Inspector は、ラベル名が MyDogs! であることを確認しました。静的テキストの特性を持ち、{{114, 0},{166,480}} のフレームを提供します
要素ツリーを見ると、ここに貼り付けたいと思いますが、ラベルは次のパスに沿って見つかるようです。
\Target
-+
--\Application
---+
----\Window
-----+
------\TableView
-------+
--------\TableCell: name:MyDogs! rect:{0, 40},{480,166}}
---------|UIAStaticText: name:MyDogs! value:MyDogs! rect:{{0, 40},{480, 166}}
---------|UIAButton: name:story list share rect:{{439, 41},{33, 28}}
このラベルを確認する方法を誰か教えてもらえますか?
私の現在のコードは次のようになります(ただし、ラベルをチェックしていません-方法がわからないため):
var testName = "LoginCreateEntry";
//Start test logging
UIALogger.logStart(testName);
//This is supposed to target the entry that my automation has created.
//The flow goes, run the automation that creates the entry, then verify that the entry
//got created as expected and is visible to the user in the iPhone interface.
var myEntry = target.frontMostApp().mainWindow().scrollViews().staticTexts()["My Dogs!"].value();
var entryName = "My Dogs!";
//Do a bunch of UI automation here to create my entry, which results in the entry
//appearing in the mainWindow with the label: My Dogs!
//If myEntry evaluates to true, then call this test a pass.
if (myEntry === entryName) {
UIALogger.logMessage("My entry was created!");
//Mark the test as a PASS
UIALogger.logPass(testName);
}
else {
UIALogger.logMessage("My entry was not created!");
//Mark the test as a FAIL
UIALogger.logFail(testName);
}
//End test
フィードバックやヘルプをいただければ幸いです!!
- - - - - - - - - - - - - - - - -アップデート - - - - - - - - ----------------------
ご協力ありがとうございました!実際にタイトルの値を取得したので、以下にソリューションを表示します。しかし、何をしても合格/不合格のログ機能を正しく動作させることはできません。また、この問題は他の人にも発生しています。私は激怒を得続けます
Issue: Script ended without explicting closing this test
テスト終了時のメッセージ。これは Instruments のバグだと確信しています。
これが私の更新されたテストです:
var target = UIATarget.localTarget();
var app = UIATarget.localTarget().frontMostApp();
var testName = "LoginCreateEntry";
//Start test logging
UIALogger.logStart( testName );
//Do lots of gui automation stuff here to create the entry which will appear in my app interface.
//I want to verify that the title I gave the entry matches what appears in the app interface
var window = app.mainWindow();
var tableView = window.tableViews()[0];
var tableGroup = tableView.groups()[0];
var entryName = "My Dogs!";
var myEntry = tableView.cells()[0].name(); //<-- This is what I needed!!!
UIALogger.logMessage("My Story Title: " + myEntry); //Print out entry name in log
if (myEntry === entryName) {
UIALogger.logMessage("My entry was created!");
//Mark the test as a PASS
UIALogger.logPass (testName);
} else {
UIALogger.logMessage("My entry was not created!");
//Mark the test as a FAIL
UIALogger.loFails (testName);
}
//End test