我希望能够访问一些不受我的控制的页面。这些页面可能会执行一些缓慢的GET请求,但主要的HTML已经完全加载并显示。我尝试了很多选项,但都无法解决。在某些网站上,firefoxWebDriver.get(...)
在现实时间内无法终止。
为了重现问题,我编写了这个小的单元测试来展示问题:
public class Timeout {
private FirefoxDriver driver;
@Before
public void setup() {
final FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("dom.max_script_run_time", 0);
profile.setPreference("webdriver.load.strategy", "fast");
this.driver = new FirefoxDriver(profile);
// this.driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
// this.driver.manage().timeouts().setScriptTimeout(10, TimeUnit.SECONDS);
}
@Test(timeout = 15000)
public void shouldRetriveREDCAFEPageQuiteFast() {
this.driver.get("http://redcafe.vn/Home/su-kien-binh-luan/kagawa-tu-choi-mac-ao-so-7");
}
@Test(timeout = 15000)
public void shouldRetriveMUFCPageQuiteFast() {
this.driver.get("http://news.mufc.vn/detail/172-hoan-tat-giay-phep-lao-dong-m-u-chinh-thuc-so-huu-kagawa.html");
}
@After
public void tearDown() {
this.driver.close();
}
}
感谢您的帮助。