- protected void get(String url, int actionCount) {
- boolean inited = false;
- int index = 0, timeout = 10;
- while (!inited && index < actionCount){
- timeout = (index == actionCount - 1) ? maxLoadTime : 10;
- inited = navigateAndLoad(url, timeout);
- index ++;
- }
- if (!inited && index == actionCount){
- throw new RuntimeException("can not get the url [" + url + "] after retry " + actionCount + "times!");
- }
- }
-
- protected void get(String url) {
- get(url, 2);
- }
-
- private boolean navigateAndLoad(String url, int timeout){
- try {
- driver.manage().timeouts().pageLoadTimeout(timeout, TimeUnit.SECONDS);
- driver.get(url);
- return true;
- } catch (TimeoutException e) {
- return false;
- } catch (Exception e) {
- failValidation();
- LOG.error(e);
- throw new RuntimeException(e);
- }finally{
- driver.manage().timeouts().pageLoadTimeout(maxLoadTime, TimeUnit.SECONDS);
- }
- }
【Selenium】跳转问题
原文:http://www.cnblogs.com/baoyu7yi/p/7137679.html