0

I have html code for button like below I Understand the Risks

I want to click on the button and it will expand and click another button which will be visible after it will expand.

I have a requirement when user suppose enter this page "https://cacert.org/" , it will ask for SSL certificate , then i will click on "I Understand the Risk" link then click on "Add Exception" Button then it will open "Add Security Exception" pop up then click on "Confirm security Exception" button. I don't want to over ride SSL certificate error

Refer my code snipet::

public class main_script {

public static WebDriver driver;


@Test

public void test() throws Exception{

    ProfilesIni profile = new ProfilesIni();

    FirefoxProfile myprofile = profile.getProfile("work");
    myprofile.setAcceptUntrustedCertificates(false);
    WebDriver driver = new FirefoxDriver(myprofile);



    driver.manage().window().maximize();

    driver.get("https://cacert.org/");

   driver.findElement(By.id("expertContent")).click();


   driver.findElement(By.id("exceptionDialogButton")).click();



}

So i am not able to click on "I Understand the Risks" link

srinivas
  • 1
  • 2

2 Answers2

0

The site (https://cacert.org/) has an invalid certificate (or rather it's "using an obsolete cipher suite"). But the warning is NOT coming from the site, it's coming from your browser (and each browser will show a different warning). So I think what fails here, is driver.get, since it never navigates to the site, but is rather stuck on browser's "security" dialog, which is coming from "chrome://browser" space.

Usually certificates are handled not by clicking those UI options, but rather either by creating special profile for selenium, where certificate is accepted once and forever (as explained here) or setting up the browser to accept untrusted certificates, as explained here

Community
  • 1
  • 1
timbre timbre
  • 12,648
  • 10
  • 46
  • 77
  • Accepted i can override the certificate through above code, but i manually want to click I Understand the Risk" link then click on "Add Exception" Button then it will open "Add Security Exception" pop up then click on "Confirm security Exception" button. But the problem is when i click the " I Understand the Risk" link it is not getting expanded so i am not able to click the "Add exception button". I used the highlighter it shows my driver clicked the I Understand the Risk" link but it is not getting expanded. – srinivas Dec 11 '15 at 06:59
  • I look at my firefox, and see the structure like this: `

    ` which means that I should not be clicking on `div`, rather on button: `driver.findElement(By.xpath("//div[@id='expertContent']/button")).click();`
    – timbre timbre Dec 11 '15 at 16:13
0

I agree with @kiril-s

To piggy back, you can create a driver with arguments. You just have to define them before you create your driver.

DesiredCapabilities capability = DesiredCapabilities.chrome(); capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); driver = new ChromeDriver(capability);

http://www.abodeqa.com/2013/05/03/ssl-certificate-in-selenium-webdriver-for-chrome-and-firefox-browser/

Making a driver bypass the SSL certificate with its settings is probably your best approach, although I've seen this done with Window Handles too