Source:
public void setHomePageInBrowser ( ) throws java.lang.Exception { android.app.Instrumentation instrumentation = testFramework.getInstrumentation ( ) ; final android.support.test.uiautomator.UiDevice device = android.support.test.uiautomator.UiDevice.getInstance ( instrumentation ) ; java.lang.String homepage = "espn.com" ; java.lang.String appName = "Browser" ; if ( ( ( testFramework.getApi ( ) ) >= 17 ) && ( ( testFramework.getApi ( ) ) <= 23 ) ) { com.android.devtools.systemimage.uitest.utils.AppLauncher.launch ( instrumentation , appName ) ; setHomePage ( device , "Other" , ( "http://" + homepage ) ) ; device.pressHome ( ) ; com.android.devtools.systemimage.uitest.utils.AppLauncher.launch ( instrumentation , appName ) ; device.findObject ( new android.support.test.uiautomator.UiSelector ( ) . resourceId ( Res.BROWSER_TAB_SWITCHER_RES ) ) . clickAndWaitForNewWindow ( ) ; device.findObject ( new android.support.test.uiautomator.UiSelector ( ) . resourceId ( Res.BROWSER_CLOSE_TAB_RES ) ) . clickAndWaitForNewWindow ( ) ; device.pressHome ( ) ; com.android.devtools.systemimage.uitest.utils.AppLauncher.launch ( instrumentation , appName ) ; android.support.test.uiautomator.UiObject urlField = device.findObject ( new android.support.test.uiautomator.UiSelector ( ) . resourceId ( Res.BROWSER_URL_TEXT_FIELD_RES ) ) ; urlField.waitForExists ( java.util.concurrent.TimeUnit.SECONDS.toMillis ( 5 ) ) ; org.junit.Assert.assertTrue ( "Homepage not set correctly" , ( ( urlField.exists ( ) ) && ( urlField.getText ( ) . contains ( homepage ) ) ) ) ; device.pressHome ( ) ; com.android.devtools.systemimage.uitest.utils.AppLauncher.launch ( instrumentation , appName ) ; setHomePage ( device , "Default page" ) ; } }

Target:
public void setHomePageInBrowser ( ) throws java.lang.Exception { android.app.Instrumentation instrumentation = testFramework.getInstrumentation ( ) ; final android.support.test.uiautomator.UiDevice device = android.support.test.uiautomator.UiDevice.getInstance ( instrumentation ) ; java.lang.String homepage = "espn.com" ; java.lang.String appName = "Browser" ; if ( ( ( api ) >= 17 ) && ( ( api ) <= 23 ) ) { com.android.devtools.systemimage.uitest.utils.AppLauncher.launch ( instrumentation , appName ) ; setHomePage ( device , "Other" , ( "http://" + homepage ) ) ; device.pressHome ( ) ; com.android.devtools.systemimage.uitest.utils.AppLauncher.launch ( instrumentation , appName ) ; device.findObject ( new android.support.test.uiautomator.UiSelector ( ) . resourceId ( Res.BROWSER_TAB_SWITCHER_RES ) ) . clickAndWaitForNewWindow ( ) ; device.findObject ( new android.support.test.uiautomator.UiSelector ( ) . resourceId ( Res.BROWSER_CLOSE_TAB_RES ) ) . clickAndWaitForNewWindow ( ) ; device.pressHome ( ) ; com.android.devtools.systemimage.uitest.utils.AppLauncher.launch ( instrumentation , appName ) ; android.support.test.uiautomator.UiObject urlField = device.findObject ( new android.support.test.uiautomator.UiSelector ( ) . resourceId ( Res.BROWSER_URL_TEXT_FIELD_RES ) ) ; urlField.waitForExists ( java.util.concurrent.TimeUnit.SECONDS.toMillis ( 5 ) ) ; org.junit.Assert.assertTrue ( "Homepage not set correctly" , ( ( urlField.exists ( ) ) && ( urlField.getText ( ) . contains ( homepage ) ) ) ) ; device.pressHome ( ) ; com.android.devtools.systemimage.uitest.utils.AppLauncher.launch ( instrumentation , appName ) ; setHomePage ( device , "Default page" ) ; } }