dalekjs / dalek

[unmaintained] DalekJS Base framework
MIT License
695 stars 63 forks source link

Invalid SSL on IE causing the test to fail #91

Open ghguy opened 10 years ago

ghguy commented 10 years ago

Hi, we tested with ie10, and dalekjs just paused againt our dev server which has a ssl cert that is invalid. Is there any known workaround, dalekjs or webdriver, to suppress the warning and allow the test to continue?

asciidisco commented 10 years ago

Yes, this is a problem, one thing could imagine that could work as a workaround is adding a call to the execute method, right after the open method:

test.open('https://my.invalidce.rt')
      .execute(function () {
          var IE = (function () {
              var ret, isTheBrowser,
                  actualVersion,
                  jscriptMap, jscriptVersion;

              isTheBrowser = false;
              jscriptMap = {
                  "5.6": 6,
                  "5.7": 7,
                  "5.8": 8,
                  "9": 9,
                  "10": 10
              };
              jscriptVersion = new Function("/*@cc_on return @_jscript_version; @*/")();

              if (jscriptVersion !== undefined) {
                  isTheBrowser = true;
                  actualVersion = jscriptMap[jscriptVersion];
              }

              ret = {
                  isTheBrowser: isTheBrowser,
                  actualVersion: actualVersion
              };

              return ret;
          }());

          if (IE.actualVersion === 10 && document.title.search("Certificate") !== -1) {
              var $link = document.getElementById('overridelink');
              var doc;

              if (node.ownerDocument) {
                  doc = $link.ownerDocument;
              } else {
                 doc = $link;
             }

            var event = doc.createEventObject();
            node.fireEvent("onclick", event);
          }
})
// add a 1sec wait
.wait(1000)
.done();

Haven't tested this yet (there might be a little syntax error in there or so), but please try & report if it works or not.

ghguy commented 10 years ago

Can we "externalized" the function so that it can be called from more than one test? Thanks!

asciidisco commented 10 years ago

Sure. Thanks to the power of Node.js this isn't a problem:

Just create one JavaScript file in a folder close to your test (let's assume your tests are in a folder called test, we will add another folder called utils in the same level of the hierarchy). It only contains or certificate bypass function (wrapped by a module.exports statement) and has the filename iecert.js:

// contents of iecert.js

module.exports = function ieCert() {
          var IE = (function () {
              var ret, isTheBrowser,
                  actualVersion,
                  jscriptMap, jscriptVersion;

              isTheBrowser = false;
              jscriptMap = {
                  "5.6": 6,
                  "5.7": 7,
                  "5.8": 8,
                  "9": 9,
                  "10": 10
              };
              jscriptVersion = new Function("/*@cc_on return @_jscript_version; @*/")();

              if (jscriptVersion !== undefined) {
                  isTheBrowser = true;
                  actualVersion = jscriptMap[jscriptVersion];
              }

              ret = {
                  isTheBrowser: isTheBrowser,
                  actualVersion: actualVersion
              };

              return ret;
          }());

          if (IE.actualVersion === 10 && document.title.search("Certificate") !== -1) {
              var $link = document.getElementById('overridelink');
              var doc;

              if (node.ownerDocument) {
                  doc = $link.ownerDocument;
              } else {
                 doc = $link;
             }

            var event = doc.createEventObject();
            node.fireEvent("onclick", event);
          }
};

We can now require the function in our test function:

var ieCert = require('../utils/iecert.js');

module.exports = {
  'my test': function (test) {
    test.open('https://my.invalidce.rt')
          .execute(ieCert)
          .wait(1000)
          .done();
  }
};

You can load & execute the function in as many files & how often you like. Hope that helps.

ghguy commented 10 years ago

Unfortunately, it does not work with IE10 on Windows 7. See attached? :( Thanks!

2014-05-23 10_35_24-daleks-invalid-ssl-ie-issue

asciidisco commented 10 years ago

That is no invalid cert page. That seems like a different bug.

Can you please start dalek like this: dalek mytes.js -b ie -l 5 & post the output? Also the contents of your test file might be of interest for mw to track the issue down.

asciidisco commented 10 years ago

Okay. I probably need some time to check this (reproduce the environment etc.); please ping me again, if I'm not coming back to you until Monday (I probably simple have forgotten to post my results then).

ghguy commented 10 years ago

Any luck?

asciidisco commented 10 years ago

Yep. More or less; I believe your issue (at least the one we see here) has nothing to do with an invalid certificate (which might be an other issue that probably pops up later in the chain), but with some settings not set correctly in IE.

Please check this thread, if that doesn't apply to your situation, we might need to investigate further.

ghguy commented 10 years ago

We tried as suggested, with no luck. We use CasperJS and it has the same issue. But we figured out a away by creating a separate command file/batch file to launch CasperJS against an invalid SSL (yes it works but as you know CasperJS is not as powerful as DalekJS :)):

@ECHO OFF set CASPER_PATH=%USERPROFILE%\AppData\Roaming\npm\node_modules\casperjs set CASPER_BIN=%CASPER_PATH%\bin\ set ARGV=%* call phantomjs --ignore-ssl-errors=yes "%CASPER_BIN%bootstrap.js" --casper-path="%CASPER_PATH%" --cli %ARGV%

Thanks to nickwallen @ https://github.com/n1k0/casperjs/issues/49. Apologized for cross-posting, but we hope it will help to resolve this issue or find a working workaround on a restricted Windows 7 laptop :(

Could we try the same? If so, would you mind send the batch file so that we can test?