嗨,我想测试密码字段是否掩盖了密码字段中输入的字符串。我如何通过 webdriver 对其进行测试。我尝试过以下事情:
package unitTest.JUnitTestCases;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class PasswordTest
{
@Test
public void test()
{
WebDriver driver=new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://docs.sencha.com/extjs/4.2.1/extjs-build/examples/form/adv-vtypes.html");
WebElement username=driver.findElement(By.id("textfield-1014-inputEl"));
username.sendKeys("admin");
System.out.println(username.getText());
WebElement password=driver.findElement(By.id("textfield-1015-inputEl"));
password.sendKeys("admin");
System.out.println(password.getAttribute("textContent"));
//WebElement login=driver.findElement(By.id("login"));
}
}
在这里,我在密码字段中输入一些值并尝试获取在该字段中输入的文本,以便我检查它是否被屏蔽。蒂亚!!