Java Code Examples for org.openqa.selenium.WebDriver#manage()

The following examples show how to use org.openqa.selenium.WebDriver#manage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IDriverPool.java    From carina with Apache License 2.0 6 votes vote down vote up
/**
 * Get driver logs by type. 
 * Android: logcat, bugreport, server, client; 
 * iOS: syslog, crashlog, performance, server, safariConsole, safariNetwork, client
 * 
 * @param driver WebDriver
 * @param logType String
 * 
 * @return LogEntries entries
 */
default LogEntries getDriverLogs(WebDriver driver, String logType) {
    //TODO: make it async in parallel thread
    LogEntries logEntries = new LogEntries(Collections.emptyList());
    POOL_LOGGER.debug("start getting driver logs: " + logType);
    try {
        if (driver.manage() != null) {
            Timer.start(ACTION_NAME.GET_LOGS);
            POOL_LOGGER.debug("Getting log artifact: " + logType);
            logEntries = driver.manage().logs().get(logType);
            POOL_LOGGER.debug("Got log artifact: " + logType);
            Timer.stop(ACTION_NAME.GET_LOGS);
        } else {
            POOL_LOGGER.error("driver.manage() is null!");
        }
    } catch (Exception e) {
        POOL_LOGGER.error("Unrecorgnized error durig driver log populating!", e);
    }
    POOL_LOGGER.debug("finish getting driver logs");
    return logEntries;
}
 
Example 2
Source File: KaptchaInvoker.java    From phoenix.webui.framework with Apache License 2.0 5 votes vote down vote up
/**
 * 获取验证码
 * @param engine 引擎
 * @param param 例如:data,http://localhost:8080/G2/captcha!getLastCode.do
 * @return 验证码
 */
public static String execute(SeleniumEngine engine, String param)
{
	WebDriver driver = engine.getDriver();
	Options manage = driver.manage();
	
	String[] paramArray = param.split(",", 2);
	
	if(paramArray.length != 2)
	{
		throw new RuntimeException("Param format is error, should be 'data,url'");
	}
	
	String key = paramArray[0];
	String url = paramArray[1];
	
	Set<Cookie> cookies = manage.getCookies();
	List<AtCookie> atCookieList = new ArrayList<AtCookie>();
	for(Cookie cookie : cookies)
	{
		String name = cookie.getName();
		String value = cookie.getValue();
		
		AtCookie atCookie = new AtCookie();
		atCookie.setName(name);
		atCookie.setValue(value);
		atCookie.setPath(cookie.getPath());
		atCookie.setDomain(cookie.getDomain());
		
		atCookieList.add(atCookie);
	}
	
	String code = HttpApiUtil.getJsonValue(url, atCookieList, key);
	
	return code;
}
 
Example 3
Source File: AbstractJavascriptTest.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public void assertLocaleCookie(String locale, WebDriver driver1, Object output, WebElement events) {
    waitForPageToLoad();
    Options ops = driver1.manage();
    Cookie cookie = ops.getCookieNamed("KEYCLOAK_LOCALE");
    Assert.assertNotNull(cookie);
    Assert.assertEquals(locale, cookie.getValue());
}
 
Example 4
Source File: IDriverPool.java    From carina with Apache License 2.0 5 votes vote down vote up
default Set<String> getAvailableDriverLogTypes(WebDriver driver) {
    Set<String> logTypes = Collections.<String>emptySet();
    if (driver.manage() != null) {
        try {
            logTypes = driver.manage().logs().getAvailableLogTypes();
        } catch (Exception e) {
            POOL_LOGGER.debug("Unrecognized failure while getAvailableLogTypes()", e);
        }
    }
    // logTypes: logcat, bugreport, server, client
    POOL_LOGGER.debug("logTypes: " + Arrays.toString(logTypes.toArray()));
    return logTypes;
}