当前位置: 首页>>代码示例>>Java>>正文


Java UserAndPassword类代码示例

本文整理汇总了Java中org.openqa.selenium.security.UserAndPassword的典型用法代码示例。如果您正苦于以下问题:Java UserAndPassword类的具体用法?Java UserAndPassword怎么用?Java UserAndPassword使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UserAndPassword类属于org.openqa.selenium.security包,在下文中一共展示了UserAndPassword类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: authenticateIE

import org.openqa.selenium.security.UserAndPassword; //导入依赖的package包/类
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);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:16,代码来源:BrowserUtility.java

示例2: canAuthenticateWithUsernameAndPassword

import org.openqa.selenium.security.UserAndPassword; //导入依赖的package包/类
@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");

}
 
开发者ID:testIT-WebTester,项目名称:webtester2-core,代码行数:14,代码来源:AlertHandlerTest.java

示例3: _executeStep

import org.openqa.selenium.security.UserAndPassword; //导入依赖的package包/类
@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;
}
 
开发者ID:xframium,项目名称:xframium-java,代码行数:51,代码来源:KWSAlert.java

示例4: canAuthenticateWithCredentials

import org.openqa.selenium.security.UserAndPassword; //导入依赖的package包/类
@Test
public void canAuthenticateWithCredentials() {

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

    verify(alert).authenticateUsing(credentials);

}
 
开发者ID:testIT-WebTester,项目名称:webtester2-core,代码行数:11,代码来源:AlertHandlerTest.java

示例5: authenticateOnNextAlert

import org.openqa.selenium.security.UserAndPassword; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:ludovicianul,项目名称:selenium-on-steroids,代码行数:16,代码来源:WebDriverHelper.java

示例6: loginAs

import org.openqa.selenium.security.UserAndPassword; //导入依赖的package包/类
/**
 * Performs an authentication on the page.
 * 
 * @param userAndPassword
 *            The authentication credentials for a user with username and password.
 */
public void loginAs(UserAndPassword userAndPassword);
 
开发者ID:QACore,项目名称:Java-Testing-Toolbox,代码行数:8,代码来源:LoginPageObjects.java

示例7: isLogged

import org.openqa.selenium.security.UserAndPassword; //导入依赖的package包/类
/**
 * 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);
 
开发者ID:QACore,项目名称:Java-Testing-Toolbox,代码行数:10,代码来源:LoginPageObjects.java

示例8: authenticateWith

import org.openqa.selenium.security.UserAndPassword; //导入依赖的package包/类
/**
 * 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));
}
 
开发者ID:testIT-WebTester,项目名称:webtester2-core,代码行数:15,代码来源:AlertHandler.java


注:本文中的org.openqa.selenium.security.UserAndPassword类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。