forked from mozilla-mobile/focus-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpenInFocusTest.swift
54 lines (43 loc) · 2.29 KB
/
OpenInFocusTest.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import XCTest
class OpenInFocusTest : BaseTestCase {
override func setUp() {
super.setUp()
dismissFirstRunUI()
}
override func tearDown() {
app.terminate()
super.tearDown()
}
func xtestOpenViaSafari() {
waitforHittable(element: app.textFields["URLBar.urlText"]) // wait for app.label
let sharedExtName = app.label.contains("Klar") ? "Firefox Klar" : "Firefox Focus" as String
XCUIDevice.shared.press(.home)
let springboard = XCUIApplication(privateWithPath: nil, bundleID: "com.apple.springboard")!
waitforHittable(element: springboard.scrollViews.otherElements.icons[sharedExtName])
let safariApp = XCUIApplication(privateWithPath: nil, bundleID: "com.apple.mobilesafari")!
safariApp.launchArguments = ["-u", "about:blank"]
safariApp.launch()
// Need to wait for the site to load as well as the share buttn availability
waitforExistence(element: safariApp.buttons["Google Search"])
waitforEnable(element: safariApp.buttons["Share"])
safariApp.buttons["Share"].tap()
waitforEnable(element: safariApp.collectionViews.cells.buttons["More"])
safariApp.collectionViews.cells.buttons["More"].tap()
// in iOS 10.3.1, multiple elements are found with 'Firefox Focus' label
let firefoxFocusSwitch = safariApp.tables.switches.matching(identifier: sharedExtName).element(boundBy: 0)
waitforHittable(element: firefoxFocusSwitch)
firefoxFocusSwitch.tap()
safariApp.navigationBars["Activities"].buttons["Done"].tap()
waitforExistence(element: safariApp.buttons[sharedExtName])
safariApp.buttons[sharedExtName].tap()
let focusApp = XCUIApplication()
let addressBarField = focusApp.textFields["URLBar.urlText"]
waitForWebPageLoad()
waitforExistence(element: focusApp.buttons["Google Search"])
waitForValueContains(element: addressBarField, value: "https://www.google")
waitforExistence(element: focusApp.buttons["ERASE"]) // check site is fully loaded
}
}