Java 类org.openqa.selenium.security.UserAndPassword 实例源码

项目:Cognizant-Intelligent-Test-Scripter    文件:BrowserUtility.java   
private void authenticateIE() {
    if (Data != null) {
        try {
            String userName = Data.split("##")[0];
            String password = Data.split("##")[1];
            Driver.switchTo().alert().authenticateUsing(new UserAndPassword(userName, password));
            Report.updateTestLog(Action, "Authenticated using " + Data, Status.DONE);
        } catch (Exception ex) {
            Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
            Report.updateTestLog(Action, "Couldn't Authenticate" + ex.getMessage(), Status.FAIL);
        }
    } else {
        Report.updateTestLog(Action, "Invalid Credentials " + Data, Status.DEBUG);
    }
}
项目:webtester2-core    文件:AlertHandlerTest.java   
@Test
public void canAuthenticateWithUsernameAndPassword() {

    Alert alert = alertIsPresent("please sign in");
    cut.authenticateWith("foo", "bar");
    verify(alert).authenticateUsing(credentialsCaptor.capture());

    Credentials credentials = credentialsCaptor.getValue();
    assertThat(credentials).isInstanceOf(UserAndPassword.class);
    assertThat((( UserAndPassword ) credentials).getUsername()).isEqualTo("foo");
    assertThat((( UserAndPassword ) credentials).getPassword()).isEqualTo("bar");

}
项目:xframium-java    文件:KWSAlert.java   
@Override
public boolean _executeStep( Page pageObject, WebDriver webDriver, Map<String, Object> contextMap, Map<String, PageData> dataMap, Map<String, Page> pageMap, SuiteContainer sC, ExecutionContextTest executionContext )
{
    try
    {
        WebDriverWait alertWait = new WebDriverWait( webDriver, 5 );
        Alert currentAlert = alertWait.until( new Function<WebDriver,Alert>(){
            @Override
            public Alert apply( WebDriver t )
            {
                return ExpectedConditions.alertIsPresent().apply( t );

            }
        } );

        if ( getContext() != null && !getContext().isEmpty() )
            contextMap.put( getContext(), currentAlert.getText() );

        switch( ALERT_TYPE.valueOf( getName() ) )
        {
            case ACCEPT:
                currentAlert.accept();
                break;

            case DISMISS:
                currentAlert.dismiss();
                break;

            case SEND_KEYS:
                currentAlert.sendKeys( getParameterValue( getParameterList().get( 0 ), contextMap, dataMap, executionContext.getxFID() ) + "" );
                currentAlert.accept();
                break;

            case AUTHENTICATE:
                currentAlert.authenticateUsing( new UserAndPassword(  getParameterValue( getParameterList().get( 0 ), contextMap, dataMap, executionContext.getxFID() ) + "",  getParameterValue( getParameterList().get( 1 ), contextMap, dataMap, executionContext.getxFID() ) + "" ) );
                   break;

            default:
                log.warn( "Unhandled Alert Type: " + getName() );

        }
    }
    catch( NoAlertPresentException e )
    {
        return false;
    }


    return true;
}
项目:webtester2-core    文件:AlertHandlerTest.java   
@Test
public void canAuthenticateWithCredentials() {

    Alert alert = alertIsPresent("please sign in");
    Credentials credentials = new UserAndPassword("foo", "bar");
    cut.authenticateWith(credentials);

    verify(alert).authenticateUsing(credentials);

}
项目:selenium-on-steroids    文件:WebDriverHelper.java   
/**
 * Authenticates the user using the given username and password. This will
 * work only if the credentials are requested through an alert window.
 * 
 * @param username
 *            the user name
 * @param password
 *            the password
 */
public void authenticateOnNextAlert(String username, String password) {
    Credentials credentials = new UserAndPassword(username, password);
    Alert alert = driver.switchTo().alert();

    alert.authenticateUsing(credentials);
}
项目:Java-Testing-Toolbox    文件:LoginPageObjects.java   
/**
 * Performs an authentication on the page.
 * 
 * @param userAndPassword
 *            The authentication credentials for a user with username and password.
 */
public void loginAs(UserAndPassword userAndPassword);
项目:Java-Testing-Toolbox    文件:LoginPageObjects.java   
/**
 * Indicates if you are logged in.
 * 
 * @param userAndPassword
 *            The authentication credentials for a user with username and password.
 * 
 * @return {@code true} if you are logged in. Otherwise, {@code false}.
 */
public boolean isLogged(UserAndPassword userAndPassword);
项目:webtester2-core    文件:AlertHandler.java   
/**
 * Authenticate a Basic-Auth popup using the given username and password.
 * <p>
 * This operation is declared as "BETA" by the Selenium developers and might break in the future in case it changes.
 *
 * @param username the username to use
 * @param password the password to use
 * @see Alert#authenticateUsing(Credentials)
 * @since 2.0
 */
@Beta
public void authenticateWith(String username, String password) {
    authenticateWith(new UserAndPassword(username, password));
}