我有一个非常简单的硒脚本来尝试调试我遇到的问题。我所做的就是填写用户名,然后填写密码,然后检查我输入的密码是否在密码字段中。我这样做的原因是我无法让它进行一般身份验证,当密码正确时始终会出现“密码不正确问题”。
表单 html:
<input class="inp" id="userName" name="userName" type="text" />
<input class="inp" id="password" name="password" type="password" />
<label for="rememberMe">remember</label>
<input class="rem" id="rememberMe" name="rememberMe" type="checkbox" value="true" />
<input name="submit" id="loginSubmit" value="go" type="image" src="http://terra/wp-content/themes/ecobee/images/arrow-right_16x16.gif" />
以及从我的 Selenium 脚本创建的 Java:
package com.example.tests;
import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.regex.Pattern;
public class toso extends SeleneseTestCase {
@Before
public void setUp() throws Exception {
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://terra/");
selenium.start();
}
@Test
public void testToso() throws Exception {
selenium.open("/");
selenium.type("userName", "[email protected] /cdn-cgi/l/email-protection");
selenium.type("password", "qqqqqqqq");
verifyEquals("qqqqqqqq", selenium.getValue("password"));
}
@After
public void tearDown() throws Exception {
selenium.stop();
}
}
这会抛出一个expected "" to match glob "qqqqqqqq" (had transformed the glob into regexp "qqqqqqqq")
建议填写密码字段。我还观看了在慢速模式下完成的测试,脚本填写了用户名,但没有填写密码字段。
很奇怪,从来没有真正发现为什么这个方法不适用于这个特定的字段,它适用于页面上的其他任何地方。
我解决这个问题的方法是
char[] password = {'p','a','s','s','w','o','r','d'};
for(int i = 0; i < 8; i++){
selenium.keyPress("password", password[i]);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)