Not able to ignore ssl certificate using capability (CapabilityType.ACCEPT_SSL_CERTS)

699 views Asked by At

Trying to run below code by disbaling ssl ccertificate using capability (capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true) via IE.

 import org.openqa.selenium.WebDriver;

    import org.openqa.selenium.ie.InternetExplorerDriver;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import org.openqa.selenium.By;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    import org.openqa.selenium.support.ui.WebDriverWait;
    import org.apache.jmeter.samplers.SampleResult;
    
io.github.bonigarcia.wdm.WebDriverManager.iedriver().setup()
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true); 
capabilities.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
WebDriver driver = new InternetExplorerDriver(capabilities)
    def wait = new WebDriverWait(driver, 20);
    driver.get('https://google.com/');
    WDS.sampleResult.sampleStart();
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(".//input[@name='q']")));
    WDS.sampleResult.sampleEnd();

ended up getting below error.

2020-10-11 09:43:21,585 ERROR o.a.j.p.j.s.JSR223Sampler: Problem in JSR223 script iecONFIG, message: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: CapabilityType for class: Script63
javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: CapabilityType for class: Script63

Does anyone know how to handle SSL certificated? and run IE with headless mode?

1

There are 1 answers

0
Dmitri T On

I fail to see where do you declare the import for the CapabilityType class, you either need to add the next line:

import org.openqa.selenium.remote.CapabilityType

to the beginning of your script

or replace

capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true)

with

capabilities.setCapability(org.openqa.selenium.remote.CapabilityType.ACCEPT_SSL_CERTS, true)

and I don't think you will be able to run Internet Explorer in headless mode, the only option would be running JMeter as the system service so the browser won't show up on your desktop, see Headless Execution of Selenium Tests in Jenkins article for more information if needed