We've probably all seen this screen when testing, all you need is a HTTPS site with a self signed cert and you get the "There is a problem with this website's security certificate" screen, which requires you to click a link to continue.
With Watir this is no problem, I automate the screen as I would any other webpage, clicking the link according to its text or ID value.
With Watir-Webdriver it's as if nothing inside the HTML can be recognized. and I'm not alone in this See this question
It's not just trying to click a link, nearly anything you try here will fail on this page Even a simple function such as puts browser.text
will return an error.
Selenium::WebDriver::Error::NoSuchElementError: Unable to find element with tag name == body
You can view source, use developer tools, or have the browser element spit out it's HTML and plainly see the darned body tag right there, but Webdriver is blind to it for some reason.
I don't know if it is a clue or a red-herring, but I know webdriver uses a ton of XPATH under the hood, and I believe XPATH is case sensitive. and in that regard I see something very unusual when I use puts browser.html
against this page, in that every single tag-name is in full upper-case. Somewhat unusual but legal valid HTML in any case. Using browser.html
on other pages shows lower case tags. Could this be what is causing webdriver to have so much of a problem with this page?
Does anyone have any bright ideas as to how I might be able to get webdriver to see the link element so I can click it?
Output from the browser object when I ask it for the page HTML
irb(main):019:0> puts $browser.html #note, indentation is added later for clarity
<HTML dir=ltr>
<HEAD>
<TITLE>Certificate Error: Navigation Blocked</TITLE>
<LINK rel=stylesheet type=text/css href="ErrorPageTemplate.css">
<META name=MS.LOCALE content=EN-US>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<META content=Yes http-equiv=MSThemeCompatible>
<SCRIPT language=javascript type=text/javascript src="errorPageStrings.js">
</SCRIPT>
<SCRIPT language=javascript type=text/javascript src="httpErrorPagesScripts.js">
</SCRIPT>
<SCRIPT language=javascript type=text/javascript src="invalidcert.js">
</SCRIPT>
</HEAD>
<BODY onload="BodyLoad(); initMoreInfo('infoBlockID');" class=securityError>
<TABLE border=0 cellSpacing=0 cellPadding=0 width=730>
<!-- Main title -->
<TBODY>
<TR>
<TD id=shieldIconAlign vAlign=top rowSpan=3 width=60 align=left>
<IMG id=shieldIcon alt="Shield icon" src="red_shield_48.png">
</TD>
<TD id=mainTitleAlign vAlign=middle align=left>
<H1 id=mainTitle>There is a problem with this website's security certificate</H1>
</TD>
</TR>
<TR>
<TD>
<H3>
<DIV id=linkdiv name="linkdiv"></DIV>
</H3>
</TD>
</TR>
<TR>
<!-- This row is for the the divider-->
<TD id=errorCodeAlign class=errorCodeAndDivider align=right>
<DIV class=divider></DIV>
</TD>
</TR>
<!-- Error Body -->
<TR>
<TD></TD>
<TD>
<H3>
<DIV style="DISPLAY: block" id=CertUnknownCA name="CertUnknownCA">
The security certificate presented by this website was not issued by a trusted certificate authority.
</DIV>
<DIV style="DISPLAY: none" id=CertExpired name="CertExpired"></DIV>
<DIV style="DISPLAY: none" id=CertCNMismatch name="CertCNMismatch"></DIV>
<DIV style="DISPLAY: none" id=CertRevoked name="CertRevoked"></DIV>
<NOSCRIPT id=securityCert1></NOSCRIPT><BR>
<ID id=securityCert2>
Security certificate problems may indicate an attempt to fool you or intercept any data you send to the server.
</ID>
</H3>
</TD>
</TR>
<!-- Recommendation-->
<TR>
<TD> </TD>
<TD><H2 id=recommendation><B>We recommend that you close this webpage and do not continue to this website. </B></H2></TD>
</TR>
<!-- close webpage-->
<TR>
<TD> </TD>
<TD id=closeWebpageAlign vAlign=middle align=left>
<H4 id=closeWebpage>
<IMG class=actionIcon border=0 alt="Recommended icon" src="green_shield.png">
<A href="javascript:closePage()">Click here to close this webpage.</A>
</H4>
</TD>
</TR>
<!-- continue to site-->
<TR>
<TD> </TD>
<TD id=continueToSiteAlign vAlign=middle align=left>
<H4 id=continueToSite>
<IMG id=ImgOverride class=actionIcon border=0 alt="Not recommended icon" src="red_shield.png">
<A id=overridelink href="http://admanager.qa-prod.local/signups/lead_form" name=overridelink>Continue to this website (not recommended).</A>
</H4>
</TD>
</TR>
<!-- InfoBlock -->
<TR>
<TD id=infoBlockAlign vAlign=top align=right> </TD>
<TD id=moreInformationAlign vAlign=middle align=left>
<H4>
<TABLE>
<TBODY>
<TR>
<TD vAlign=top>
<A onclick="javascript:expandCollapse('infoBlockID', true); return false;" href="#">
<IMG id=infoBlockIDImage class=actionIcon border=0 alt="More information" src="down.png">
</A>
</TD>
<TD vAlign=top>
<SPAN id=moreInfoContainer>
<A href="javascript:expandCollapse('infoBlockID', true);">More information</A>
</SPAN>
<NOSCRIPT></NOSCRIPT>
</TD>
</TR>
</TBODY>
</TABLE>
</H4>
<DIV style="DISPLAY: none" id=infoBlockID class=infoBlock>
<P>
<LI id=errorExpl1>If you arrived at this page by clicking a link, check the website address in the address bar to be sure that it is the address you were expecting.
<LI id=errorExpl2>When going to a website with an address such as https://example.com, try adding the 'www' to the address, https://www.example.com.
<P></P>
<P id=moreInfoSeeHelpPF>For more information, see "Certificate Errors" in Internet Explorer Help.
</P>
</LI>
</DIV>
</TD>
</TR>
</TBODY>
</TABLE>
</BODY>
</HTML>
=> nil
irb(main):020:0>