'How to operate app and browser combined per test automation

I am searching for a test automation tool that supports the following test case:

  • start an app on the smartphone
  • click on a button; the click on the button starts the browser and opens a web page in the browser, on the smartphone of course
  • enter some data in the browser
  • return to the app: the entered data must be visible now in the app

I have seen many test automation tools, that support app testing and browser testing. But there I have seen only situations where the browser is opened on the computer where the test automation tool runs; or cases where the browser is started separately on a smartphone.

Does anyone know a tool that supports testing the described communication between the app and the browser which was started by the app?



Solution 1:[1]

This can be done in the standard automated UI testing that comes with Xcode, XCUITest (i'm assuming the Android equivalent can do the same). I'm a fan of using the inbuilt stuff as you get full access to Swift/Objective-C and don't have to deal with any additional, buggy dependencies

E.g. I had a settings screen in an app that had multiple links to external resources. I had an automated test that tapped the buttons, waited a few seconds, then verified that safari contained the correct URL, then returned to the app.

Your usecase will obviously be more involved than mine, but here is a sample of navigating from app -> Safari -> interact with safari -> return to app

func test_ExternalLinks() {
    // Hold onto a reference of our app that we are testing, and safari installed on the phone
    let app = XCUIApplication()
    let safari = XCUIApplication(bundleIdentifier: "com.apple.mobilesafari")


    // Query to get safari URL textfield
    let urlTextField = safari.textFields["URL"]

    // Navigate to settings screen
    ...
    ...

    // Tap "About" button in our app
    app.tables.staticTexts["About"].tap()
    sleep(2)
    
    // Tap URL bar so we can examine the full URL
    safari.buttons["URL"].tap()
    urlTextField.tap()

    // Extract URL and compare to known value
    var url = urlTextField.value as! String 
    XCTAssert(url == "https://...../about/", url)
    
    // Return to our app
    app.activate()
    sleep(2)
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Simon McLoughlin