2012-06-06 74 views
0

显然,我用Selenium Webdriver进行自动化测试的网站上存在过期证书。我已经尝试在Internet设置中禁用证书撤销,并重新启动IE(以及Windows,以确保安全),但无济于事。无法在Internet Explorer上禁用证书吊销(过期证书)

我也尝试使用Webdriver浏览警告页面,但没有成功。出于某种原因,它无法使用xpath或内置的“By.id”定位机制检测页面上的“继续”按钮。我对这个问题的WebDriver解决方案是开放的,但我更喜欢一个允许我禁用证书撤销的解决方案。我不使用IE来进行虚拟机上的自动化测试,所以我不担心安全问题。

以防万一的webdriver是唯一的选择,这里是页面的源代码

<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 class=securityError onload="BodyLoad(); initMoreInfo('infoBlockID');"> 
<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=center width=* 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>&nbsp; 
<DIV class=divider></DIV></TD></TR><!-- Error Body --> 
<TR> 
<TD></TD> 
<TD> 
<H3> 
<DIV style="DISPLAY: none" id=CertUnknownCA name="CertUnknownCA"></DIV> 
<DIV style="DISPLAY: block" id=CertExpired name="CertExpired">The security certificate presented by this website has expired or is not yet valid.</DIV> 
<DIV style="DISPLAY: block" id=CertCNMismatch name="CertCNMismatch">The security certificate presented by this website was issued for a different website's address.</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>&nbsp;</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>&nbsp;</TD> 
<TD id=closeWebpageAlign vAlign=center 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>&nbsp;</TD> 
<TD id=continueToSiteAlign vAlign=center align=left> 
<H4 id=continueToSite><IMG id=ImgOverride class=actionIcon border=0 alt="Not recommended icon" src="red_shield.png"><A id=overridelink href="<href>" name=overridelink>Continue to this website (not recommended).</A> </H4></TD></TR><!-- InfoBlock --> 
<TR> 
<TD id=infoBlockAlign vAlign=top align=right>&nbsp; </TD> 
<TD id=moreInformationAlign vAlign=center 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. 
<LI id=errorExpl3>If you choose to ignore this error and continue, do not enter private information into the website. 
<P></P> 
<P id=moreInfoSeeHelpPF>For more information, see "Certificate Errors" in Internet Explorer Help.</P></LI></DIV></TD></TR></TBODY></TABLE></BODY></HTML> 

这里是我的尝试(在Java中):

ieDriver.findElement(By.id("overridelink")).click();  
ieDriver.findElement(By.xpath("//a[@id='overridelink']")).click(); 
ieDriver.findElement(By.xpath("//A[@id='overridelink']")).click(); 

我敢猜测不起作用,因为属性值没有在引号中指定,所以它是不正确的HTML。

我也试过这样:

ieDriver.findElement(By.xpath("//a[@href='<href>']")).click(); 
ieDriver.findElement(By.xpath("//A[@id='<href>']")).click(); 

<href> 

象征着实际的URL。

我也无法使用相同的方法找到周围的标签。

注:这也没有为我工作:Webdriver not finding elements in remote IE

我怀疑,因为它不减轻安全隐患信任过期的证书。

回答

0

嗯,一个解决方案,它的工作原理是刚刚创建一个可接受的结束日期的新证书。这只有在您有权访问服务器,管理员允许时才有效,并且不介意签署自己的证书(至少暂时)。我不太喜欢这个解决方案,但是因为它对我的问题来说似乎是一个有效的答案,所以我会随它去做。我将特别创建一个与WebDriver功能相关的新问题。

0

如果这是一个IE正在创建的提示框,您可以尝试使用.SwitchTo()我将其用于提醒框。

WebDriver.SwitchTo().Alert().Accept(); 

希望帮助

+0

谢谢AJ,不幸的是它是一个实际的页面。如果它是一个警报,那肯定会让它更容易! –