Reputation: 3426
I have a very simple script for selenium to try and debug an issue I'm having. All I do is fill in the username, then fill in the password, then check that the password I typed is in the password field. The reason I'm doing this is that I can't get it to authenticate in general, consistently getting 'password incorrect issue' when it's the correct password.
The form 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" />
And the Java created from my Selenium script:
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", "cw@qa.com");
selenium.type("password", "qqqqqqqq");
verifyEquals("qqqqqqqq", selenium.getValue("password"));
}
@After
public void tearDown() throws Exception {
selenium.stop();
}
}
This throws a expected "" to match glob "qqqqqqqq" (had transformed the glob into regexp "qqqqqqqq")
suggesting the the password field is filled in. I also watched the test complete on slow mode, the script fills in the username, but not the password field.
Upvotes: 3
Views: 5354
Reputation: 3426
Very strange, never really found out why this method won't work for this particular field, it works everywhere else on the page.
The way I solved this was
char[] password = {'p','a','s','s','w','o','r','d'};
for(int i = 0; i < 8; i++){
selenium.keyPress("password", password[i]);
}
Upvotes: 2