无法通过Jenkins中的Selenium执行登录测试

时间:2019-05-24 13:21:17

标签: selenium internet-explorer jenkins

我正在尝试仅通过硒使Internet Explorer自动化一些功能(仅IMP:仅IE。其他浏览器均未提供)。是IE 11。

这是登录页面的HTML代码

"$w"

以下是我通过Selenium脚本执行的步骤

  1. 点击登录URL时,页面将打开,并显示带有两个锚链接的“安全警告”-'单击此处关闭此网页。 ”和“继续浏览此网站(不推荐)”。单击继续后,我可以通过这里。 Screenshot of what this security warning looks like
  2. 然后加载登录页面,并通过代码自动输入用户名和密码。

-问题在下面-

  1. 单击“提交”按钮后,我仍然停留在同一页面上。用户名和密码字段为空白,URL也没有变化。

这是硒代码<​​/ p>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login page </title>
</head>
<body>

<form name="Login" method="POST" action="/Project/LoginServlet" onsubmit="return validate_form ( );">
 <P ALIGN='center' >
 <br /><br/>
<img src="/Project/images/image1.JPG" width=1300px height=100px />
 </P>
 <p ALIGN='center'>
  <table border="1">
 <tr><td colspan="2" align="Left">* Enter Username and Password</tr>
 <tr>
  <th><b>Username : </b><font size="3" color="red" >*</font></th>
  <th>  <input type="text" name="username" size="50" ></th>
  </tr>
  <tr>
  <th><b>Password : </b><font size="3" color="red">*</font></th>
  <th> <input type="password" name="pwd" size="50" ></th>
  </tr>
  </table>
  <br><table>
   <TR>  <input type="submit" value="Login" name="B1"></TR>
</TABLE>
<br><br>
<br>
</P>
</form>
</body>
</html>

我尝试提供错误的用户名和密码组合,并且可以正常工作,因为我在页面上内联显示了一个错误。 URL也会更改,带有处理登录名的servlet名称。由于某些原因,我无法超越“登录”页面。

此外,我尝试直接运行批处理文件,它运行正常。由于某种原因,当詹金斯(Jenkins)调用它时,它会执行所有操作,但会在“登录”页面上停止!!

我也尝试过增加等待时间,因为Selenium在Jenkins身上工作缓慢。结果还是一样。

所有硒代码都在用@TEST标记注释的JAVA方法中编写,以使其由TestNG执行。 Jenkins通过调用批处理文件来调用TestNG和其他类/库。

0 个答案:

没有答案