Created
June 7, 2017 08:49
-
-
Save fuxx/0c47bf64d093646a64d65ea457755578 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import XCTest | |
enum Safari { | |
static func launch() -> XCUIApplication { | |
// Open safariapp | |
let safariApp = XCUIApplication(privateWithPath: nil, bundleID: "com.apple.mobilesafari") | |
// Launch safari app | |
safariApp.launch() | |
// Wait some seconds for launch | |
sleep(2) | |
// Return application handle | |
return safariApp | |
} | |
static func open(URLString urlString: String, inSafariApp app: XCUIApplication) { | |
// Find URL bar | |
app.otherElements["URL"].tap() | |
// Tap URL bar | |
app.textFields["Suchbegriff oder Website"].exists ? app.textFields["Suchbegriff oder Website"].tap() : app.textFields["Search or enter website name"].tap() | |
// Enter the URL string | |
app.typeText(urlString) | |
// Simulator keyboard is english, on the device we use german | |
app.buttons["Öffnen"].exists ? app.buttons["Öffnen"].tap() : app.buttons["Go"].tap() | |
} | |
} | |
protocol SafariLaunchable { | |
var safariApp: XCUIApplication { get } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment