How to validate TextView value in Xcode iOS9?

I am testing user interface modules. On the picture.
These are UILabels, with the exception of the long description, which is a UITextView.
On the page I want to do, check the value in the response. For an answer in UILabels is good. I can follow the example of Xcode UI Test
This method is pretty easy to execute, just tap an item and change the method from .tap() to .exist() Then .exist() it in assert() .

My UITextView problem UITextView more complicated than UILabel .
How can I get a UITextView value to do an assert check?

 func testG(){ let app = XCUIApplication() app.launch(); app.buttons["Enter"].tap() app.tables.staticTexts["Bee"].tap() assert(app.scrollViews.staticTexts["Name :"].exists); assert(app.scrollViews.staticTexts["Age :"].exists); assert(app.scrollViews.staticTexts["Specialty :"].exists); assert(app.scrollViews.staticTexts["Description :"].exists); assert(app.scrollViews.staticTexts["Bee"].exists); assert(app.scrollViews.staticTexts["11"].exists); assert(app.scrollViews.staticTexts["Sky Diver"].exists); let text = "Bees are flying insects closely related to wasps and ants, known for their role in pollination and, in the case of the best-known bee species, the European honey bee, for producing honey and beeswax. Bees are a monophyletic lineage within the superfamily Apoidea, presently considered as a clade Anthophila. There are nearly 20,000 known species of bees in seven to nine recognized families,[1] though many are undescribed and the actual number is probably higher. They are found on every continent except Antarctica, in every habitat on the planet that contains insect-pollinated flowering plants.EOF"; assert(app.scrollViews.childrenMatchingType(.TextView).element.exists); } 

Scroll bar UI

+5
source share
2 answers

If anyone else finds this question, I can get the UITextView text using

 app.textViews.element.value as? String 

This assumes that there is only one text view on the screen.

+1
source
 XCTAssert(app.scrollViews.staticTexts[text].exists, "Didn't find the text!") 

Do not believe that you can get the value here, so you just need to claim that it is. If it were a text field, then getting value would be a great way to do this.

+1
source

All Articles