I'm facing with one problem using UITesting
framework for the xCode that Apple has introduced at WWDC 2015.
I have a UITableView and this table contains a lot of cells. Also I have a NSArray with cells titles - if cell title is contained in NSArray this cell should be tapped.
My problem is that I can't scroll table view for particular cell, because framework doesn't contain method for working with table views, only swipe gestures (down, up).
Maybe somebody knows how I can tap on particular cell in table view? Or how I can scroll table view for particular cell?
Because when I call tap()
method for cell which are not visible at screen - nothing happen.
Thanks in advance!
Go to File > New > Target. Then, search for UI Testing Bundle. Select Unit Testing Bundle and then click Next. As UI tests take time, it is usually best to stop immediately when a failure occurs.
XCUITest is an iOS testing framework developed by Apple in 2015 for its native UI suite. It is developed on top of the XCTest framework which is the main test framework that is integrated within Apple's Xcode. The XCUITest tests can be written on XCode, using Swift or Objective-C.
XCTest / XCUITest is pure iOS and cannot help the team that needs to test both iOS and Android devices. XCUITest was built for the iOS and Xcode Developer in mind and focuses less on the QA Automation Engineer.
This worked for me:
XCUIElementQuery *tablesQuery = self.app.tables;
XCUIElementQuery *cellQuery = [tablesQuery.cells containingType:XCUIElementTypeStaticText
identifier:@"Work"];
XCUIElementQuery* cell = [cellQuery childrenMatchingType:XCUIElementTypeStaticText];
XCUIElement* cellElement = cell.element;
[cellElement tap];
For scrolling the table use:
XCUIElementQuery *tablesQuery = self.app.tables;
XCUIElement* table = tablesQuery.element;
[table swipeUp];
I recently came across a similar problem. An option you can try is to look for a specific title for a cell in the table, and tap on that,
for example:-
XCUIApplication().tables.staticTexts["identifier"].tap()
or
XCUIApplication().tables.cells.staticTexts["identifier"].tap()
Where "identifier" is the title of the cell you are trying to tap.
I hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With