我注意到 driver.get( 'http://...' ) 似乎在继续之前等待整个页面加载 . 有没有办法不等待页面加载?我宁愿等待DOM上的元素存在,而不是等待加载所有内容 . 由于这个原因,我的一些测试似乎在WebDriver中需要两倍的时间 .
driver.get( 'http://...' )
是的,不是 . 截至Selenium 2.24.1,the support for this is only in Firefox - you have to run it in a special "mode":
FirefoxProfile fp = new FirefoxProfile(); fp.setPreference("webdriver.load.strategy", "unstable"); WebDriver driver = new FirefoxDriver(fp);
你甚至可以设置the timeout if you want to . 此方法在除Firefox之外的任何浏览器中都会失败,并且在没有不稳定策略的情
driver.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS);
1 回答
是的,不是 . 截至Selenium 2.24.1,the support for this is only in Firefox - you have to run it in a special "mode":
你甚至可以设置the timeout if you want to . 此方法在除Firefox之外的任何浏览器中都会失败,并且在没有不稳定策略的情