Hello, friends! I began to learn the SWIFT language to test the application using it in XCode and faced with such a task. There is an application. When launching, a page opens on which there is horizontal scrolling. In this scrolling there are interactive themes (10 by default) and their number may vary depending on the config that the user uses. I wanted to automate the process of comparing the names of these topics with a list that is stored on a local disk. Please help me understand how to implement the first part of my task - Search through the text in this scrolling bar and compile a list of this text. Thank.
The beginning of the code is so, but I don’t know how to create the list further ((((.
func testExample() { XCUIDevice.shared().orientation = .faceUp let scrollView = XCUIApplication().children(matching: .window) .element(boundBy: 0) .children(matching: .other) .element.children(matching: .other) .element.children(matching: .other) .element.children(matching: .other) .element.children(matching: .other) .element(boundBy: 0) .children(matching: .other) .element(boundBy: 1) .children(matching: .other) .element(boundBy: 0) .children(matching: .scrollView) .element // var lists = ["Annotate a File","Start from Scratch","Annotate a Webpage","Annotate a Video","Annotate Images","Annotate a Map","Annotate a File","Create a Live Stream","News Studio","Talk Show","Lincoln Memorial","The Not Perfect Hat Club","News Cast","BusinessCast","SportsCast","Here's How","Review It","Loading Theme...","Unable to Load Theme :("] scrollView.swipeRight() /* for text in lists { if text == "Loading Theme..." { repeat { sleep (30) scrollView.swipeRight() scrollView.swipeLeft() } } while text != "Loading Theme..." } scrollView.swipeRight() for text in lists { if text == "Unable to Load Theme :(" { XCUIApplication().buttons[text+" is logged"].tap() XCUIApplication().navigationBars[text].buttons["Settings"].tap() XCUIApplication().tables.buttons["Log Out"].tap() XCUIApplication().buttons["Sign In"].tap() } } */ /* let file = "file.txt" //this is the file. we will write to and read from it let text = "_previewTitle" //just a text if let dir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first { let path = dir.appendingPathComponent(file) //writing do { try text.write(to: path, atomically: false, encoding: String.Encoding.utf8) } catch {/* error handling here */} } func writeToDocumentsFile(fileName:String,value:String) { let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as NSString let path = documentsPath.appendingPathComponent(fileName) do{ try value.write(toFile: path, atomically: true, encoding: String.Encoding.utf8) }catch{ } } */ } } 