Skip to content

Instantly share code, notes, and snippets.

@boek
Last active October 12, 2017 19:33
Show Gist options
  • Save boek/435e9927c29c4e5c380ef87559e222dd to your computer and use it in GitHub Desktop.
Save boek/435e9927c29c4e5c380ef87559e222dd to your computer and use it in GitHub Desktop.
func test08PasteAndGo() {
let app = XCUIApplication()
// Inject a string into clipboard
let clipboardString = "Hello world"
UIPasteboard.general.string = clipboardString
// Enter 'mozilla' on the search field
let searchOrEnterAddressTextField = app.textFields["URLBar.urlText"]
searchOrEnterAddressTextField.typeText("mozilla.org\n")
// Check the correct site is reached
waitForValueContains(element: searchOrEnterAddressTextField, value: "https://www.mozilla.org/")
// Tap URL field, check for paste & go menu
searchOrEnterAddressTextField.tap()
searchOrEnterAddressTextField.press(forDuration: 1.5)
expectation(for: NSPredicate(format: "count > 0"), evaluatedWith: app.menuItems, handler: nil)
waitForExpectations(timeout: 10, handler: nil)
app.menuItems.element(boundBy: 3).tap()
snapshot("08PasteAndGo")
}
@5y
Copy link

5y commented Oct 11, 2017

image

@boek
Copy link
Author

boek commented Oct 11, 2017

image

@5y
Copy link

5y commented Oct 11, 2017

image
image

@5y
Copy link

5y commented Oct 11, 2017

 func test08PasteAndGo() {
    let app = XCUIApplication()
    let urlBarTextfield = app.textFields["URLBar.urlText"]
    urlBarTextfield.typeText("mozilla.org\n")
    urlBarTextfield.tap()
    expectation(for: NSPredicate(format: "count > 0"), evaluatedWith: app.menuItems, handler: nil)
    let coord = urlBarTextfield.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5))
    coord.doubleTap()
    app.menuItems.element(boundBy: 4).tap()
    let coord2 = urlBarTextfield.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 1))
    coord2.doubleTap()

// app.textFields["URLBar.urlText"].tap()
snapshot("08PasteAndGo")
}

@5y
Copy link

5y commented Oct 11, 2017

oct-11-2017 23-54-38

@5y
Copy link

5y commented Oct 12, 2017

image

@5y
Copy link

5y commented Oct 12, 2017

image

@5y
Copy link

5y commented Oct 12, 2017

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment