Sha256: daeb47eb27af7604c5f942a11b8e2e112a2addeed7c4b8b7d92532b27c2c82bd

Contents?: true

Size: 1.92 KB

Versions: 4

Compression:

Stored size: 1.92 KB

Contents

//
//  Extensions.swift
//  Created by XCFit Framework
//  Copyright © 2016 XCFit Framework. All rights reserved.
//
//

/*
 
 This is sample code created by XCFit Framework and can be edited/Removed as per your project need. You can also re-arrange Xcode Groups and directories as per your need.
 
 This file can take all the Swift extensions build around XCUI Test Frameworks which can be directly used in the tests, page objects. Here are sample extensions on XCUIElement and XCTestCase.
 
 */

import Foundation
import XCTest

extension XCUIElement {
    
    public func tapOnceVisible(testCase: XCTestCase,
                               file: String = #file, line: UInt = #line) {
        let existsPredicate = NSPredicate(format: "exists == true")
        
        
        testCase.expectation(for: existsPredicate,
                             evaluatedWith: self, handler: nil)
        
        testCase.waitForExpectations(timeout: 20) { (error) -> Void in
            if (error != nil) {
                let message = "Failed to find \(self) after 20 seconds."
                testCase.recordFailure(withDescription: message,
                                       inFile: file, atLine: line, expected: true)
            }
        }
        
        self.tap()
    }
    
    
}

extension XCTestCase {
    func waitForElementToAppear(element: XCUIElement,
                                file: String = #file, line: UInt = #line) {
        let existsPredicate = NSPredicate(format: "exists == true")
        expectation(for: existsPredicate,
                    evaluatedWith: element, handler: nil)
        
        waitForExpectations(timeout: 20) { (error) -> Void in
            if (error != nil) {
                let message = "Failed to find \(element) after 5 seconds."
                self.recordFailure(withDescription: message,
                                   inFile: file, atLine: line, expected: true)
            }
        }
    }
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
xcfit-2.0.6 XCFit_Templates/XCFit/Cucumberish UI Test Bundle Base.xctemplate/Extensions.swift
xcfit-2.0.4 XCFit_Templates/XCFit/Cucumberish UI Test Bundle Base.xctemplate/Extensions.swift
xcfit-2.0.3 XCFit_Templates/XCFit/Cucumberish UI Test Bundle Base.xctemplate/Extensions.swift
xcfit-2.0.2 XCFit_Templates/XCFit/Cucumberish UI Test Bundle Base.xctemplate/Extensions.swift