简体   繁体   中英

Can't run autotests on Java using remote Selenium WebDriver + Jenkins + FireFox when using self-signed SSL certificate

After spending DAYS for researching and studying documentation and forums I've faced that my problem isn't solved or I isn't qualified enough to understand the solution, so.. please, help. First of all I'm a newbie in autotesting (however I've got good manual testing background), so may be I've just go wrong with existing solutions, or missed some required knowledge, so please, treat my problem with understanding :-)

I've got remote pc with Debian 8 (with GUI) installed, with Jenkins. Also, its critically for my work to use FireFox browser there (50.0.2), so it also present. Also due to different causes I'm using Geckodriver for it.

I've got some autotests which testing some web application on site with self-signed SSL certificate. The main problem - on attempt to open any URL from that site I'm getting different errors, and my tests aren't work.

I've created custom profile at FireFox, then I've added certificate to it, and then added my custom profile to the test itself:

@Before
public void loadPage() throws InterruptedException, IOException {
System.setProperty("webdriver.gecko.driver", "/home/roa/Documents/geckodriver");
FirefoxProfile profile = new FirefoxProfile(new File("/home/rwgndg97.default/")); // path to dir with custom profile with cert installed
this.driver = new FirefoxDriver(profile);
driver.manage().window().maximize();
}

@Test
public void auth_test() throws Exception {
driver.get("url which require certificate");
}

@After
public void closeDriver() {
driver.quit();
}

When I'm attempting to run this code, I'm getting following log:

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 30.694 sec <<< FAILURE! - in TestSuite auth_test on auth_test(Test.New)(Test.New) Time elapsed: 29.822 sec <<< FAILURE! org.openqa.selenium.WebDriverException: Reached error page: about:certerror?e=nssBadCert&u=https%3A//url_that_requires_cerificate/&c=UTF-8&f=regular&d=url_that_requires_cerificate%20uses%20an%20invalid%20security%20certificate.%0A%0AThe%20certificate%20is%20only%20valid%20for%20the%20following%20names%3A%0A%20%20*.a.championat.com%2C%20a.championat.com%20%20%0A%0AError%20code%3A%20%3Ca%20id%3D%22errorCode%22%20title%3D%22SSL_ERROR_BAD_CERT_DOMAIN%22%3ESSL_ERROR_BAD_CERT_DOMAIN%3C/a%3E%0A Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700' System info: host: 'debian', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.16.0-4-amd64', java.version: '1.8.0_111' Driver info: org.openqa.selenium.firefox.FirefoxDriver

Log states I'm trying to use invalid SSL certificate to access server via https, and everything is clear except the fact that same certificate used with FireFox manually lets me open the site successfully without any warnings or notifications.

Adding following code into autotest isn't giving any results: profile.setAcceptUntrustedCertificates(true); profile.setAssumeUntrustedCertificateIssuer(false);

Please, advise on how to make tests run in my conditions.. I'll be glad to receive any useful information on how to solve this. Thanks in advance.

Try to add options to accept SSL certificates,

                profile.setAcceptUntrustedCertificates(true);
                profile.setAssumeUntrustedCertificateIssuer(false);
                driver = new FirefoxDriver(profile);

That error goes away if you use FF 52 (still in beta). See my answer in the posting: Invalid certificate error with Geckodriver on FF 51

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM