javascript - How do I get selenium-webdriver to ignore SSL errors in Firefox and PhantomJS? -


given these node dependencies:

{     "chromedriver": "^2.24.1",     "cucumber": "^1.3.0",     "geckodriver": "^1.1.2",     "phantomjs-prebuilt": "^2.1.12",     "selenium-webdriver": "^3.0.0-beta-2" }  

i phantomjs , firefox ignore ssl certificates. here how browser.js looks:

require('geckodriver');  // main browser object var browserhandle;  // load selenium webdriver , rules var webdriver = require('selenium-webdriver'),      = webdriver.by,      until = webdriver.until;  // load phantomjs webdriver capabilities var phantomjs_exe = require('phantomjs-prebuilt').path; var customphantom = webdriver.capabilities.phantomjs(); customphantom.set("phantomjs.binary.path", phantomjs_exe);  webdriver.builder()     //.forbrowser('firefox')     //.forbrowser('phantomjs')     .withcapabilities(customphantom)     .build(); 

any suggestions --ignore-ssl-errors=yes? how can implement in code? want use javascript, rather java.

this javascript / node.js selenium webdriverjs case, macos solution.

  1. firefox case:

    a. setup new profile using profile manager firefox.

    • open profile manager /applications/firefox.app/contents/macos/firefox-bin -p (-profilemanager, works well)
    • click "create profile"
    • in second step of creation, path profile file displayed. copy it!

    b. add ffprofile file

    • go features/support
    • add new file "ffprofile.json"
    • add { "ffprofile": "<profilepath>"} file, <profilepath> path copied in a.

    c. add local system profile

    • open profile manager again /applications/firefox.app/contents/macos/firefox-bin -p
    • select new profile, click "start firefox"
    • in browser, go https://.... should see page telling there problem certificate
    • click on "advanced" -> "add exception" -> "confirm security exception"

    d. add browser.js or call browser programmatically:

    var webdriver = require('selenium-webdriver'),  firefox = require('selenium-webdriver/firefox'),  var ffprofilefile = require('./ffprofile'); var ffprofile = new firefox.profile(ffprofilefile['ffprofile']); var ffoptions = new firefox.options().setprofile(ffprofile);  return browserhandle = new firefox.driver(ffoptions); 
  2. phantomjs case ( have got 2 solutions here, pick 1 better you):

    solution 1:

    var webdriver = require('selenium-webdriver'),  phantom = require('phantomjs-prebuilt');  var capabilities = webdriver.capabilities.phantomjs(); capabilities.set(webdriver.capability.accept_ssl_certs, true); capabilities.set(webdriver.capability.secure_ssl, false); capabilities.set("phantomjs.cli.args",                  ["--web-security=no",                   "--ssl-protocol=any",                    "--ignore-ssl-errors=yes"]                 ); return browserhandle = new webdriver .builder() .withcapabilities(capabilities) .build(); 

    solution 2:

    var webdriver = require('selenium-webdriver'),  phantom = require('phantomjs-prebuilt');  var capabilities = {     'browsername' : 'phantomjs',     'phantomjs.cli.args': ['--ignore-ssl-errors=true',         '--ssl-protocol=any', '--web-security=false'] } return browserhandle = new webdriver .builder() .withcapabilities(capabilities) .build(); 

    for 1 'phantomjs.cli.args': ['--ignore-ssl-errors=true'] did job me.

hope useful you.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -