我正在尝试用来selenium-webdriver
测试使用自签名证书的站点。
要通过 Firefox 下的测试,需要使用配置文件告诉 Firefox 接受自签名证书。
我能够使用使用创建的配置文件firefox -ProfileManager
。但是,我无法使用以编程方式创建的配置文件。
谁能告诉我这里缺少什么?
这是javascript
使用由创建的配置文件的程序firefox -ProfileManager
:
var webdriver = require('selenium-webdriver');
var firefox = require('selenium-webdriver/firefox');
var profile = new firefox.Profile('/path/to/firefox/profile');
var browser = new firefox.Driver(new firefox.Options().setProfile(profile));
browser.get('https://self-signed.badssl.com/');
browser.quit();
这是javascript
使用由代码创建的配置文件的程序:
var webdriver = require('selenium-webdriver');
var firefox = require('selenium-webdriver/firefox');
var profile = new firefox.Profile();
profile.setAcceptUntrustedCerts(true);
profile.setAssumeUntrustedCertIssuer(false); // `true` didn't work too
var browser = new firefox.Driver(new firefox.Options().setProfile(profile));
browser.get('https://self-signed.badssl.com/');
browser.quit();
我在第二个程序中遇到的错误如下:
$ node test-firefox-profile.js
/user/ws/node_modules/selenium-webdriver/lib/promise.js:654
throw error;
^
WebDriverError: Error loading page
at WebDriverError (/user/ws/node_modules/selenium-webdriver/lib/error.js:27:10)
at Object.throwDecodedError (/user/ws/node_modules/selenium-webdriver/lib/error.js:477:11)
at parseHttpResponse (/user/ws/node_modules/selenium-webdriver/lib/http.js:386:15)
at /user/ws/node_modules/selenium-webdriver/lib/http.js:328:11
at process._tickCallback (node.js:369:9)
From: Task: WebDriver.navigate().to(https://self-signed.badssl.com/)
at Driver.schedule (/user/ws/node_modules/selenium-webdriver/lib/webdriver.js:414:17)
at Navigation.to (/user/ws/node_modules/selenium-webdriver/lib/webdriver.js:1042:25)
at Driver.get (/user/ws/node_modules/selenium-webdriver/lib/webdriver.js:832:28)
at Object.<anonymous> (/user/ws/test-firefox-profile.js:9:9)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)