XCTest为UILabel文本存在的文本

时间:2018-03-17 16:39:48

标签: ios swift xcode-ui-testing

我有一个简单的界面,有3个标签。我希望能够确定分配给特定标签的实际文本。在IB内部设置的文本是"我有标签文本"。此标签的IB标识符为" lastLabel"。

    func testDetermineLabelText(){
         let app = XCUIApplication()
         let allLabels = app.staticTexts
         let labelPredicate = NSPredicate(format: "identifier contains[cd] 'lastLabel'") //i set the identifier in IB to be 'lastLabel'
         let foundLabel = allLabels.containing(labelPredicate)
         XCTAssert(foundLabel["lastLabel"].title == "I have label text")
    }

1 个答案:

答案 0 :(得分:1)

对于$file = __DIR__ . "/jsonfile.json"; $lines= file( $file );/* read file into an array - use a foreach to process each item separately */ foreach( $lines as $line ){ $json=json_decode( $line ); $sql ="insert into `mysqltable` ( `nurl`, `nid`, `sort` ) values('{$json->url}','{$json->id}','{$json->asc}')"; printf('%s<br />',$sql); mysql_query($dbconnect,$insql); } ,该文本可从UILabel属性中获取。

label