MonkeyTalk:验证自定义的UITableViewCell标签的文本,而不选择该单元格(Mon

2019-09-29 13:33发布

I have an iPhone application that has a search box and UITableView with custom UITableViewCells. This Table Loaded with search results after user enter a search word and tap search. I need to test the search results with MonkeyTalk. (using MonkeyTalk script or JavaScript version of it). I want to retrieve/verify that 2nd Label of first CustomUITableViewCell contains the search text without selecting the cell.

So far I'm able to get number of items of the each table section using

var count = app.table().get("count", "size(sectionNo)"); //java script version

and I'm able to retrieve title or detail text of default UITableViewCells successfully with

var data = app.table().get("data","item(CellNo)"); //java script version

Table * Verify "searchTerm" item(CellNo)   #monkey script version

I want to Know How I do the same with custom UITableViewCell ?

MonkeyTalk Table properties reference:

Answer 1:

我发现了一个办法做到这一点。

首先打开Xcode项目源代码,在侧面的UITableViewDelegate法“的cellForRowAtIndexPath”(这是我们配置的每个细胞)配置属性“accessibilityLabel”为要验证通过自动化测试/访问的标签。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
........
........
cell.searchItemTitle.text = item.title;
cell.searchItemDescription.text = item.description;
cell.searchItemTitle.accessibilityLabel = @"cellTitleLabel";
........
........
return cell;
}

清洁与测试目标建设。 monkeytalk脚本里面,你可以使用accessibilityLabel名称访问属性

Label "cellTitleLabel" Verify "apple" ".text" #monkeytalk script

app.label("cellTitleLabel").verify("apple", ".text"); //java script version

注:没有必要去想表或部分信息。 它会认同monkeyId“cellTitleLabel”一个标签,如果你想访问你可以使用monkeyId同一个表的第二个单元格的titleLabel“cellTitleLabel(2)”和第三单元monkeyId“cellTitleLabel(3)”这样的..

如果你们有更好的解决方案,请在这里添加它谢谢.. Chathura



文章来源: MonkeyTalk : Verify custom UITableViewCell Label text without select the cell