gpt4 book ai didi

c# - Selenium RC 记忆 "End of the World"

转载 作者:太空宇宙 更新时间:2023-11-03 13:39:47 25 4
gpt4 key购买 nike

为了解释标题.. Selenium RC keeps insisting that

A system shutdown has already been scheduled

并因此拒绝进行自动化测试。我能理解这里的逻辑,我的意思是,如果你认为世界末日将结束,你就不会做作业核浩劫...

然而..这不是冷战,当我检查几个基本的东西(比如使用shutdown\a,完成完全重启)时,我发现事实并非如此!

enter image description here

我如何才能让 selenium 相信世界不会终结,它应该可以完成我告诉它的工作?

注意在这里,selenium 已“拒绝”初始化任何 IE 实例,并将继续挂起直到超时,无论单击 Yes 还是 No。我正在使用 NUnit、c#/.net4.0 来控制测试。

最佳答案

为了解决这个问题,我用下面的补丁版本替换了默认的“runSeleniumTest”函数作为user extension :

function runSeleniumTest() {
runOptions = new RemoteRunnerOptions();
var testAppWindow;

if (runOptions.isMultiWindowMode()) {
try{
testAppWindow = openSeparateApplicationWindow('Blank.html', true);
}
catch (e) {
window.onunload = function () { };
window.location.reload();
return;
}
} else if (sel$('selenium_myiframe') != null) {
var myiframe = sel$('selenium_myiframe');
if (myiframe) {
testAppWindow = myiframe.contentWindow;
}
}
else {
proxyInjectionMode = true;
testAppWindow = window;
}
selenium = Selenium.createForWindow(testAppWindow, proxyInjectionMode);
if (runOptions.getBaseUrl()) {
selenium.browserbot.baseUrl = runOptions.getBaseUrl();
}
if (!debugMode) {
debugMode = runOptions.isDebugMode();
}
if (proxyInjectionMode) {
LOG.logHook = logToRc;
selenium.browserbot._modifyWindow(testAppWindow);
}
else if (debugMode) {
LOG.logHook = logToRc;
}
window.selenium = selenium;

commandFactory = new CommandHandlerFactory();
commandFactory.registerAll(selenium);

currentTest = new RemoteRunner(commandFactory);

var doContinue = runOptions.getContinue();
if (doContinue != null) postResult = "OK";

currentTest.start();
}

我发现“openSeparateApplicationWindow”内部发生了“系统关闭已安排”错误。我还发现在错误发生后刷新 selenium 测试运行程序窗口将“重新启动”测试而不会出现错误。因此,我用以下 try catch 语句修补了“runSeleniumTest”,以便在“openSeparateApplicationWindow”中出现错误时重新加载测试运行器窗口:

try{
testAppWindow = openSeparateApplicationWindow('Blank.html', true);
}
catch (e) {
window.onunload = function () { };
window.location.reload();
return;
}

我还使用了 my blog post有关 selenium 用户扩展的更具体示例

关于c# - Selenium RC 记忆 "End of the World",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17528097/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com