页面的HTML看起来像:
<DIV class=sso-desktop>
<FORM id=frmDefault method=post action=SSOlogin.fcc autocomplete="OFF"><INPUT value=ISO-8859-1 type=hidden name=SMENC> <INPUT value=US-EN type=hidden name=SMLOCALE> <INPUT id=location type=hidden name=location> <INPUT id=txtTargetDefault value=HTTP://mits-uat.jpmchase.net/ type=hidden name=target> <INPUT value=0 type=hidden name=smauthreason> <INPUT value=CjQJusV3p15WVSKSkff2KzsgkSCcupPBGl/3DhkXK+PbaIZJ3n0AINwJ6jfCCuYg type=hidden name=smagentname> <INPUT type=hidden name=postpreservationdata>
<DIV class=container>
<DIV class=headerbox>
<DIV class=headertitle>
<H2>SSO Login
<SCRIPT>
document.write(' ' + config.server.region);
if (config.server.env !== "PROD") {
document.write('<font color="red"> - ' + config.server.env + '</font>');
}
</SCRIPT>
AMERICAS<FONT color=red> - QA</FONT> </H2></DIV></DIV>
<DIV class=infobox>
<DIV class=infotitle><SPAN><A href="https://smlogin-qa.jpmchase.net/siteminderagent/sso/about_blue.htm"><IMG alt="Single Sign-On" src="images/signon_logo_transparent.gif" width=118 height=22></A></SPAN> </DIV>
<DIV class=infobody>
<DIV class=infocenter>
<TABLE class=center>
<TBODY>
<TR>
<TD align=right><B>Standard ID:</B></TD>
<TD align=left><INPUT id=txtUserDefault class=logininput tabIndex=1 type=text name=USER></TD>
<TD align=left><A href="https://idserv-qa.jpmchase.net/stdid_search.asp" target=_self>Standard ID Look-up</A></TD></TR>
<TR>
<TD> </TD></TR>
<TR>
<TD align=right><B>Password:</B></TD>
<TD align=left><INPUT id=txtPassDefault class=logininput tabIndex=2 value="" type=password name=PASSWORD></TD>
<TD align=left><A href="https://mytechub.jpmchase.net/SSO/Reset/Qa/" target=_self>Reset/Forgot Password</A></TD></TR></TBODY></TABLE></DIV>
<DIV class=infobtn><INPUT tabIndex=3 onclick="return submitForm();" value=Login type=submit> </DIV></DIV>
<DIV class=infofooter>
<DIV><A href="https://idserv-qa.jpmchase.net/vettingpasswordreset.asp">Reset Vetting Information</A></DIV>
<DIV><A href="javascript:window.open('./sso/help2.htm','helpWindow','width=640,height=380,scrollbars=yes');void(0);">Single Sign-On Help</A></DIV></DIV></DIV></DIV>
<DIV class=tipbox><SPAN><B>Tip:</B> You are able to use the same Standard ID and password on all sites that bear the Single Sign-On logo.</SPAN> </DIV>
<DIV class=alerttext><SPAN>DO NOT BOOKMARK THIS PAGE. DO NOT ADD TO FAVORITES.</SPAN> </DIV></FORM></DIV><!--HTML5 FORM-->
<TABLE style="POSITION: absolute; WIDTH: 100%; HEIGHT: 100%; TOP: 0px; LEFT: 0px" class=sso-html5>
<TBODY>
<TR>
<TD style="HEIGHT: 43px">
<DIV style="HEIGHT: 43px" class="sso-toolbar sso-toolbar-top"><SPAN class=sso-help-icon onclick="document.location='sso/help2.htm';"></SPAN>
<DIV class=sso-toolbar-title>Single Sign-On
<SCRIPT>
if (config.server.env !== "PROD") {
document.write('<span class="sso-toolbar-env"> - ' + config.server.env + '</span>');
}
</SCRIPT>
<SPAN class=sso-toolbar-env>- QA</SPAN> </DIV></DIV></TD></TR>
<TR>
<TD vAlign=top>
<FORM style="WIDTH: 100%" id=frmHTML5 method=post action=SSOlogin.fcc autocomplete="OFF"><INPUT value=ISO-8859-1 type=hidden name=SMENC> <INPUT value=US-EN type=hidden name=SMLOCALE> <INPUT id=location type=hidden name=location> <INPUT id=txtTargetHTML5 value=HTTP://mits-uat.jpmchase.net/ type=hidden name=target> <INPUT value=0 type=hidden name=smauthreason> <INPUT value=CjQJusV3p15WVSKSkff2KzsgkSCcupPBGl/3DhkXK+PbaIZJ3n0AINwJ6jfCCuYg type=hidden name=smagentname> <INPUT type=hidden name=postpreservationdata>
<DIV class=sso-body>
<DIV class=sso-fieldset>
<DIV class=sso-field>
<DIV class=sso-field-label><SPAN>Standard ID</SPAN></DIV>
<DIV class=sso-field-container><INPUT id=txtUserHTML5 class=sso-input-text type=text name=USER></DIV></DIV>
<DIV class=sso-field>
<DIV class=sso-field-label><SPAN>Password</SPAN></DIV>
<DIV class=sso-field-container><INPUT id=txtPassHTML5 class=sso-input-password value="" type=password name=PASSWORD autocapitalize="off"></DIV></DIV></DIV>
<DIV class=sso-box-center><INPUT onclick="return submitForm();" value=Login type=submit> </DIV></DIV></FORM></TD></TR>
<TR>
<TD style="HEIGHT: 17px">
<DIV style="HEIGHT: 17px" class="sso-toolbar sso-toolbar-bottom">
<DIV class=sso-corporate-logo></DIV></DIV></TD></TR></TBODY></TABLE>
我使用Selenium的课程如下:
class mits
{
void mits1() throws BiffException, IOException
{
//WebDriver driver = new FirefoxDriver();
File file = new File("C:\\Users\\V443938\\Downloads\\IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
DesiredCapabilities dc = DesiredCapabilities.internetExplorer();
dc.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
WebDriver driver = new InternetExplorerDriver(dc);
driver.manage().window().maximize();
driver.get("https://mits-uat.jpmchase.net/");
driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
//Enter username
driver.findElement(By.xpath("//INPUT[@id='txtUserDefault']")).sendKeys(new String []{"R277025"});
//Enter Password
driver.findElement(By.xpath("//INPUT[@id='txtPassDefault']")).sendKeys("CTcbb314");
//Click on button
driver.findElement(By.xpath("//INPUT[@value='Login']")).click();
}
}
问题:
现在,我为xpath或ID或名称的用户名获取了No Such Element Exception。当我在FF中运行代码时。它工作正常。我不确定Internet Explorer中的xpath,name,ID是否发生了变化。如果是这样,请帮助我。
来自FF的xpath和来自IE的xpath是否不同?
注意:该应用程序是安全的,在正常情况下不会打开。