TB14
TB14

Reputation: 307

Is it possible to use monotouch uikit in xamarin ui tests

I am currently writing ui tests and I would like to be able to check things like if the TableViewCell has been selected or not. I see in the monotouch uikit there is a Selected method listed. I have tried to use it but got no results(see code below). Does anyone know how this can be used for UI testing?:

app.Query(e => e.Class("UITableViewCell.Selected"));
app.Query(e => e.Class("UITableViewCell").Selected);

Upvotes: 1

Views: 63

Answers (1)

SushiHangover
SushiHangover

Reputation: 74134

You need to invoke the ObjC name instead of the C# one.

So for UITableViewCell, the selected method is isSelected with zero parameters.

re: https://developer.apple.com/documentation/uikit/uitableviewcell/1623263-isselected

In your test, you can use Invoke something like:

app.Query(e => e.Id("IdTestCell").Class("UITableViewCell").Invoke("isSelected", 0).Value<bool>());

Results in:

Query for Id("IdTestCell").Class("UITableViewCell").Invoke("isSelected", 0).Value<Boolean>() gave 1 results.
[                                                                                                                                
   [0] true                                                                                                             
]                                                                                                                                      

Upvotes: 2

Related Questions