private void forceWebViewToReloadManually ( int retry ) { boolean ok = false ; setMode ( WorkingMode . Native ) ; for ( int i = 0 ; i < retry ; i ++ ) { try { // to get Safari out of his home page and become responsive we need to click // on one of the home icons, click on the "about:blank" we added in prefs WebElement b = getNativeDriver ( ) . findElement ( By . xpath ( "//UIAWindow/UIAScrollView/UIAButton" ) ) ; b . click ( ) ; // // click on the Go! button on the keyboard // log.fine("clicking on about:blank button: " + i); // Criteria c = new AndCriteria(new NameCriteria("Go"), new TypeCriteria(UIAButton.class)); // UIAButton go = getNativeDriver().findElement(c); // go.click(); ok = true ; } catch ( WebDriverException e ) { sleep ( 2000 ) ; // allow some time to take effect // else keep trying as sometimes the click doesn't take effect on slow machines log . fine ( "about:blank button gone, proceeding" ) ; break ; } } if ( ! ok ) { log . warning ( "Couldn't find button after " + retry + "retries." ) ; throw new RecoverableCrashException ( "coudln't find the about:blank button after " + retry + " retries." ) ; } setMode ( WorkingMode . Web ) ; }
the webview doesn t refresh correctly if it hasn t been loaded at lease once .