質問

To explain the title.. Selenium RC keeps insisting that

A system shutdown has already been scheduled

and refusing to conduct automated tests because of this.. I can understand the logic here, I mean you're not going to do your homework if you thought the world would end with a nuclear holocaust...

However.. this is not the Cold War and when I inspect several basic things (such as using shutdown \a, completing a full restart) I find that this is actually not the case!

enter image description here

How can I convince selenium that the world is not going to end and that it should probably do the work I'm telling it to?

N.B. Here, selenium has "refused" to initialise any instance of IE, and will continue to hang until it times out, regardless of clicking Yes or No. I'm using NUnit, c#/.net4.0 to control the tests.

役に立ちましたか?

解決

To fix this I replaced the default "runSeleniumTest" function with the below patched version as a 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();
}

I found that the "a system shutdown has already been scheduled" error occurred inside of "openSeparateApplicationWindow". I also found that refreshing the selenium test runner window after the error occurred would "restart" the test without the error. Therefore, I patched the "runSeleniumTest" with the following try catch statement so the test runner window reloads if there's an error in "openSeparateApplicationWindow":

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

I also used my blog post for a more specific example of selenium user extensions

他のヒント

Selenium isn't doing anything in this case. That's the IE HTA agent (a built-in Windows process) that's preventing you from doing anything. Perhaps rebooting the machine will do the trick? It looks like you may just have a pending Windows update that's scheduled a future reboot.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top