use of org.openqa.selenium.WebDriver in project geode by apache.
the class WebDriverRule method login.
private void login() {
WebElement userNameElement = waitForElementById("user_name", 60);
WebElement passwordElement = waitForElementById("user_password");
userNameElement.sendKeys(username);
passwordElement.sendKeys(password);
passwordElement.submit();
driver.get(getPulseURL() + "clusterDetail.html");
WebElement userNameOnPulsePage = (new WebDriverWait(driver, 30)).until(new ExpectedCondition<WebElement>() {
@Override
public WebElement apply(WebDriver d) {
return d.findElement(By.id("userName"));
}
});
assertNotNull(userNameOnPulsePage);
}
use of org.openqa.selenium.WebDriver in project oxAuth by GluuFederation.
the class BaseTest method authenticateResourceOwnerAndDenyAccess.
public AuthorizationResponse authenticateResourceOwnerAndDenyAccess(String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret) {
String authorizationRequestUrl = authorizeUrl + "?" + authorizationRequest.getQueryString();
AuthorizeClient authorizeClient = new AuthorizeClient(authorizeUrl);
authorizeClient.setRequest(authorizationRequest);
System.out.println("authenticateResourceOwnerAndDenyAccess: authorizationRequestUrl:" + authorizationRequestUrl);
startSelenium();
driver.navigate().to(authorizationRequestUrl);
WebElement usernameElement = driver.findElement(By.name(loginFormUsername));
WebElement passwordElement = driver.findElement(By.name(loginFormPassword));
WebElement loginButton = driver.findElement(By.name(loginFormLoginButton));
if (userId != null) {
usernameElement.sendKeys(userId);
}
passwordElement.sendKeys(userSecret);
loginButton.click();
String authorizationResponseStr = driver.getCurrentUrl();
WebElement doNotAllowButton = driver.findElement(By.name(authorizeFormDoNotAllowButton));
final String previousURL = driver.getCurrentUrl();
doNotAllowButton.click();
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return (d.getCurrentUrl() != previousURL);
}
});
authorizationResponseStr = driver.getCurrentUrl();
Cookie sessionStateCookie = driver.manage().getCookieNamed("session_state");
String sessionState = null;
if (sessionStateCookie != null) {
sessionState = sessionStateCookie.getValue();
}
System.out.println("authenticateResourceOwnerAndDenyAccess: sessionState:" + sessionState);
stopSelenium();
AuthorizationResponse authorizationResponse = new AuthorizationResponse(authorizationResponseStr);
if (authorizationRequest.getRedirectUri() != null && authorizationRequest.getRedirectUri().equals(authorizationResponseStr)) {
authorizationResponse.setResponseMode(ResponseMode.FORM_POST);
}
authorizationResponse.setSessionState(sessionState);
authorizeClient.setResponse(authorizationResponse);
showClientUserAgent(authorizeClient);
return authorizationResponse;
}
use of org.openqa.selenium.WebDriver in project oxAuth by GluuFederation.
the class BaseTest method authorizationRequestAndDenyAccess.
public AuthorizationResponse authorizationRequestAndDenyAccess(String authorizeUrl, AuthorizationRequest authorizationRequest) {
String authorizationRequestUrl = authorizeUrl + "?" + authorizationRequest.getQueryString();
AuthorizeClient authorizeClient = new AuthorizeClient(authorizeUrl);
authorizeClient.setRequest(authorizationRequest);
System.out.println("authorizationRequestAndDenyAccess: authorizationRequestUrl:" + authorizationRequestUrl);
startSelenium();
driver.navigate().to(authorizationRequestUrl);
WebElement doNotAllowButton = driver.findElement(By.name(authorizeFormDoNotAllowButton));
final String previousURL = driver.getCurrentUrl();
doNotAllowButton.click();
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return (d.getCurrentUrl() != previousURL);
}
});
String authorizationResponseStr = driver.getCurrentUrl();
Cookie sessionStateCookie = driver.manage().getCookieNamed("session_state");
String sessionState = null;
if (sessionStateCookie != null) {
sessionState = sessionStateCookie.getValue();
}
System.out.println("authorizationRequestAndDenyAccess: sessionState:" + sessionState);
stopSelenium();
AuthorizationResponse authorizationResponse = new AuthorizationResponse(authorizationResponseStr);
if (authorizationRequest.getRedirectUri() != null && authorizationRequest.getRedirectUri().equals(authorizationResponseStr)) {
authorizationResponse.setResponseMode(ResponseMode.FORM_POST);
}
authorizeClient.setResponse(authorizationResponse);
showClientUserAgent(authorizeClient);
return authorizationResponse;
}
use of org.openqa.selenium.WebDriver in project oxAuth by GluuFederation.
the class BaseTest method authorizationRequestAndGrantAccess.
public AuthorizationResponse authorizationRequestAndGrantAccess(String authorizeUrl, AuthorizationRequest authorizationRequest) {
String authorizationRequestUrl = authorizeUrl + "?" + authorizationRequest.getQueryString();
AuthorizeClient authorizeClient = new AuthorizeClient(authorizeUrl);
authorizeClient.setRequest(authorizationRequest);
System.out.println("authorizationRequestAndGrantAccess: authorizationRequestUrl:" + authorizationRequestUrl);
startSelenium();
driver.navigate().to(authorizationRequestUrl);
String authorizationResponseStr = driver.getCurrentUrl();
WebElement allowButton = driver.findElement(By.name(authorizeFormAllowButton));
final String previousURL = driver.getCurrentUrl();
allowButton.click();
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return (d.getCurrentUrl() != previousURL);
}
});
authorizationResponseStr = driver.getCurrentUrl();
Cookie sessionStateCookie = driver.manage().getCookieNamed("session_state");
String sessionState = null;
if (sessionStateCookie != null) {
sessionState = sessionStateCookie.getValue();
}
System.out.println("authorizationRequestAndGrantAccess: sessionState:" + sessionState);
stopSelenium();
AuthorizationResponse authorizationResponse = new AuthorizationResponse(authorizationResponseStr);
if (authorizationRequest.getRedirectUri() != null && authorizationRequest.getRedirectUri().equals(authorizationResponseStr)) {
authorizationResponse.setResponseMode(ResponseMode.FORM_POST);
}
authorizeClient.setResponse(authorizationResponse);
showClientUserAgent(authorizeClient);
return authorizationResponse;
}
use of org.openqa.selenium.WebDriver in project zeppelin by apache.
the class WebDriverManager method getWebDriver.
public static WebDriver getWebDriver() {
WebDriver driver = null;
if (driver == null) {
try {
FirefoxBinary ffox = new FirefoxBinary();
if ("true".equals(System.getenv("TRAVIS"))) {
// xvfb is supposed to
ffox.setEnvironmentProperty("DISPLAY", ":99");
// run with DISPLAY 99
}
int firefoxVersion = WebDriverManager.getFirefoxVersion();
LOG.info("Firefox version " + firefoxVersion + " detected");
downLoadsDir = FileUtils.getTempDirectory().toString();
String tempPath = downLoadsDir + "/firebug/";
downloadFireBug(firefoxVersion, tempPath);
final String firebugPath = tempPath + "firebug.xpi";
final String firepathPath = tempPath + "firepath.xpi";
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.dir", downLoadsDir);
profile.setPreference("browser.helperApps.alwaysAsk.force", false);
profile.setPreference("browser.download.manager.showWhenStarting", false);
profile.setPreference("browser.download.manager.showAlertOnComplete", false);
profile.setPreference("browser.download.manager.closeWhenDone", true);
profile.setPreference("app.update.auto", false);
profile.setPreference("app.update.enabled", false);
profile.setPreference("dom.max_script_run_time", 0);
profile.setPreference("dom.max_chrome_script_run_time", 0);
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/x-ustar,application/octet-stream,application/zip,text/csv,text/plain");
profile.setPreference("network.proxy.type", 0);
profile.addExtension(new File(firebugPath));
profile.addExtension(new File(firepathPath));
driver = new FirefoxDriver(ffox, profile);
} catch (Exception e) {
LOG.error("Exception in WebDriverManager while FireFox Driver ", e);
}
}
if (driver == null) {
try {
driver = new ChromeDriver();
} catch (Exception e) {
LOG.error("Exception in WebDriverManager while ChromeDriver ", e);
}
}
if (driver == null) {
try {
driver = new SafariDriver();
} catch (Exception e) {
LOG.error("Exception in WebDriverManager while SafariDriver ", e);
}
}
String url;
if (System.getenv("url") != null) {
url = System.getenv("url");
} else {
url = "http://localhost:8080";
}
long start = System.currentTimeMillis();
boolean loaded = false;
driver.manage().timeouts().implicitlyWait(AbstractZeppelinIT.MAX_IMPLICIT_WAIT, TimeUnit.SECONDS);
driver.get(url);
while (System.currentTimeMillis() - start < 60 * 1000) {
// wait for page load
try {
(new WebDriverWait(driver, 30)).until(new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver d) {
return d.findElement(By.xpath("//i[@tooltip='WebSocket Connected']")).isDisplayed();
}
});
loaded = true;
break;
} catch (TimeoutException e) {
LOG.info("Exception in WebDriverManager while WebDriverWait ", e);
driver.navigate().to(url);
}
}
if (loaded == false) {
fail();
}
return driver;
}
Aggregations