我目前正在开发一项功能,我在编辑帖子时自动保存内容。即使在浏览器崩溃时,该功能也可以使用。我的问题是有一种方法可以自动化(selenium或类似)并测试浏览器崩溃。
答案 0 :(得分:1)
我会注入一个异常来崩溃窗口并在新窗口中工作以检查恢复。这不是一个浏览器崩溃,而是关闭:
WebDriver driver = new FirefoxDriver();
driver.get("https://www.google.co.uk");
// crash the window
((JavascriptExecutor)driver).executeScript(
"window.open();" +
"window.stop();" +
"setTimeout(function(){" +
"document.open();" +
"document.write('<script>throw new Error();</script>');" +
"document.close();},0);");
// close the window
Object[] handles = driver.getWindowHandles().toArray();
driver.close();
// switch to the new window and reload the page
driver.switchTo().window(handles[1].toString());
driver.get("https://www.google.co.uk");
答案 1 :(得分:0)
Few ways are:
1. Reload browser for multiple times or indefinitely.
2. Paste very big texts (text bigger than the size of input text fields) in input texts.
3. Click submit button multiple times in a quick succession.
4. Open many instances of same browser, reduce the available memory to be used by browser.
etc..
Hope this helps !!