Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -17,6 +19,8 @@

public class AADSeleniumITHelper extends SeleniumITHelper {

private static final Logger LOGGER = LoggerFactory.getLogger(AADSeleniumITHelper.class);

private String username;
private String password;

Expand All @@ -43,7 +47,23 @@ public AADSeleniumITHelper(Class<?> appClass, Map<String, String> properties, St
public void logIn() {
driver.get(app.root() + "oauth2/authorization/azure");
wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("loginfmt"))).sendKeys(username + Keys.ENTER);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("passwd"))).sendKeys(password + Keys.ENTER);
try {
try {
wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("passwd"))).sendKeys(password + Keys.ENTER);
} catch (Exception exception) {
// Sometimes AAD cannot locate the user account and will ask to select it's a work account or personal account.
// Here select work accout.
// https://docs.microsoft.com/azure/devops/organizations/accounts/faq-azure-access?view=azure-devops#q-why-do-i-have-to-choose-between-a-work-or-school-account-and-my-personal-account
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("aadTileTitle"))).click();
wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("passwd"))).sendKeys(password + Keys.ENTER);
}
} catch (Exception exception) {
String passwdUrl = driver.getCurrentUrl();
LOGGER.info(passwdUrl);
String pageSource = driver.getPageSource();
LOGGER.info(pageSource);
throw exception;
}
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("input[type='submit']"))).click();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<configuration>
<logger name="org.apache.hc" level="INFO" />
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>