Quality Testing

Quality is delighting customers

How to resolve this Selenium Website certificate issue

Hi all, 

I am working on Selenium 2 & C#. I have a  certificate problem in IE9. I am executing my Selenium Test script and get to the page: "There is a problem with this website's security certificate".

When I tried to click the link "Continue to this website (not recommended)" using: driver.FindElement(By.Id("override link"));, Selenium didn't recognize it, it couldn't click the link.

Would you please let me know if someone knows how to fix this issue?

This is my code:

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability(CapabilityType.AcceptSslCertificates, true);
WebDriverObj = new InternetExplorerDriver(capabilities);
MyBrowser = new WebDriverBackedSelenium(WebDriverObj, "http://www.google.com");
WebDriverObj.Navigate().GoToUrl("https://mywebsiteUrl");

WebDriverObj.Navigate().GoToUrl("javascript:document.getElementById('overridelink').click()");

IWebElement uname = WebDriverObj.FindElement(By.Id("ctl00_uxContentPlaceHolder_uxUsername"));
uname.SendKeys("username");
IWebElement pwd = WebDriverObj.FindElement(By.Id("ctl00_uxContentPlaceHolder_uxPassword"));
pwd.SendKeys("pass*");

Thanks.

Views: 97

Reply to This

Replies to This Discussion

In software testing company, We follow a couple of solutions depending on how your particular company is set up. The simplest way is if the machine that you're running the tests from is on the same domain as the server where the site is hosted. Have the team that manages the server to create a self-signed certificate and has the cert added to your machine.
Other than this, i tried this code with IE9 using C# and its working for me code:

IWebDriver driver = new InternetExploreDriver();
driver.Url("Site");
driver.Navigate().GoToUrl("javascript:document.getElementById('overridelink').click()");

For Chrome:
capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--start-maximized", "--ignore-certificate-errors",
"--disable-popup-blocking", "--disable-default-apps", "--auto-launch-at-startup", "--always-authorize-plugins"));

And now it will go to the real page.

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2019   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service