"driver.switchTo().alert().Authenticate()"
和"driver.switchTo().alert().setCredentails()"
之间有什么区别?两者都使用Interface Credentials。
答案 0 :(得分:2)
身份验证在设置凭据后调用接受。它可以在消息来源中找到。
public void setCredentials(Credentials credentials) {
if(!(credentials instanceof UserAndPassword)) {
throw new RuntimeException("Unsupported credentials: " + credentials);
} else {
UserAndPassword userAndPassword = (UserAndPassword)credentials;
RemoteWebDriver.this.execute("setAlertCredentials", ImmutableMap.of("username", userAndPassword.getUsername(), "password", userAndPassword.getPassword()));
}
}
public void authenticateUsing(Credentials credentials) {
this.setCredentials(credentials);
this.accept();
}