diff --git a/tmail_selenium/src/main/java/com/tmail/robots/BasicAuthLoginRobot.java b/tmail_selenium/src/main/java/com/tmail/robots/BasicAuthLoginRobot.java new file mode 100644 index 0000000000..5657d81f14 --- /dev/null +++ b/tmail_selenium/src/main/java/com/tmail/robots/BasicAuthLoginRobot.java @@ -0,0 +1,26 @@ +package com.tmail.robots; + +import com.microsoft.playwright.Page; +import com.tmail.base.CoreRobot; + +public class BasicAuthLoginRobot extends CoreRobot { + + public BasicAuthLoginRobot(Page page) { + super(page); + } + + public void enterUsername(String username) { + page.locator("#email").fill(username); + } + + public void enterPassword(String password) { + page.locator("input[aria-label='password']").click(); + page.waitForTimeout(1000); + page.locator("input[aria-label='password']").fill(password); + } + + public void clickLogin() { + page.getByText("Sign in").last().click(); + } + +} diff --git a/tmail_selenium/src/main/java/com/tmail/robots/LoginRobot.java b/tmail_selenium/src/main/java/com/tmail/robots/OidcLoginRobot.java similarity index 82% rename from tmail_selenium/src/main/java/com/tmail/robots/LoginRobot.java rename to tmail_selenium/src/main/java/com/tmail/robots/OidcLoginRobot.java index 287f848675..3cb34e7377 100644 --- a/tmail_selenium/src/main/java/com/tmail/robots/LoginRobot.java +++ b/tmail_selenium/src/main/java/com/tmail/robots/OidcLoginRobot.java @@ -3,9 +3,9 @@ import com.microsoft.playwright.Page; import com.tmail.base.CoreRobot; -public class LoginRobot extends CoreRobot { +public class OidcLoginRobot extends CoreRobot { - public LoginRobot(Page page) { + public OidcLoginRobot(Page page) { super(page); } diff --git a/tmail_selenium/src/main/java/com/tmail/scenarios/BasicAuthLoginScenario.java b/tmail_selenium/src/main/java/com/tmail/scenarios/BasicAuthLoginScenario.java new file mode 100644 index 0000000000..36d90ea62c --- /dev/null +++ b/tmail_selenium/src/main/java/com/tmail/scenarios/BasicAuthLoginScenario.java @@ -0,0 +1,35 @@ +package com.tmail.scenarios; + +import com.microsoft.playwright.Page; +import com.tmail.base.BaseScenario; +import com.tmail.robots.BasicAuthLoginRobot; +import com.tmail.robots.HomeRobot; +import com.tmail.robots.MailboxDashboardRobot; + +public class BasicAuthLoginScenario extends BaseScenario { + String testUrl; + String username; + String password; + + public BasicAuthLoginScenario(String testUrl, String username, String password) { + this.testUrl = testUrl; + this.username = username; + this.password = password; + } + + @Override + public void execute(Page page) { + HomeRobot homeRobot = new HomeRobot(page); + BasicAuthLoginRobot loginRobot = new BasicAuthLoginRobot(page); + MailboxDashboardRobot mailboxDashboardRobot = new MailboxDashboardRobot(page); + + homeRobot.navigateToTestSite(testUrl); + + loginRobot.enterUsername(username); + loginRobot.enterPassword(password); + loginRobot.clickLogin(); + + mailboxDashboardRobot.waitUntilExactLabelIsVisible("Compose"); + } + +} diff --git a/tmail_selenium/src/main/java/com/tmail/scenarios/ComposeEmailScenario.java b/tmail_selenium/src/main/java/com/tmail/scenarios/ComposeEmailScenario.java index c55d410af4..fc1dc01b99 100644 --- a/tmail_selenium/src/main/java/com/tmail/scenarios/ComposeEmailScenario.java +++ b/tmail_selenium/src/main/java/com/tmail/scenarios/ComposeEmailScenario.java @@ -26,7 +26,7 @@ public void execute(Page page) { MailboxDashboardRobot mailboxDashboardRobot = new MailboxDashboardRobot(page); ComposerRobot composerRobot = new ComposerRobot(page); - LoginScenario loginUseCase = new LoginScenario(testUrl, username, password); + OidcLoginScenario loginUseCase = new OidcLoginScenario(testUrl, username, password); loginUseCase.execute(page); mailboxDashboardRobot.openComposer(); diff --git a/tmail_selenium/src/main/java/com/tmail/scenarios/LoginScenario.java b/tmail_selenium/src/main/java/com/tmail/scenarios/OidcLoginScenario.java similarity index 77% rename from tmail_selenium/src/main/java/com/tmail/scenarios/LoginScenario.java rename to tmail_selenium/src/main/java/com/tmail/scenarios/OidcLoginScenario.java index cb8312ee38..f79217d85e 100644 --- a/tmail_selenium/src/main/java/com/tmail/scenarios/LoginScenario.java +++ b/tmail_selenium/src/main/java/com/tmail/scenarios/OidcLoginScenario.java @@ -3,15 +3,15 @@ import com.microsoft.playwright.Page; import com.tmail.base.BaseScenario; import com.tmail.robots.HomeRobot; -import com.tmail.robots.LoginRobot; import com.tmail.robots.MailboxDashboardRobot; +import com.tmail.robots.OidcLoginRobot; -public class LoginScenario extends BaseScenario { +public class OidcLoginScenario extends BaseScenario { String testUrl; String username; String password; - public LoginScenario(String testUrl, String username, String password) { + public OidcLoginScenario(String testUrl, String username, String password) { this.testUrl = testUrl; this.username = username; this.password = password; @@ -20,7 +20,7 @@ public LoginScenario(String testUrl, String username, String password) { @Override public void execute(Page page) { HomeRobot homeRobot = new HomeRobot(page); - LoginRobot loginRobot = new LoginRobot(page); + OidcLoginRobot loginRobot = new OidcLoginRobot(page); MailboxDashboardRobot mailboxDashboardRobot = new MailboxDashboardRobot(page); homeRobot.navigateToTestSite(testUrl); diff --git a/tmail_selenium/src/test/java/com/tmail/preprod/basic_auth/login/BasicAuthLoginTest.java b/tmail_selenium/src/test/java/com/tmail/preprod/basic_auth/login/BasicAuthLoginTest.java new file mode 100644 index 0000000000..c04d3de2c5 --- /dev/null +++ b/tmail_selenium/src/test/java/com/tmail/preprod/basic_auth/login/BasicAuthLoginTest.java @@ -0,0 +1,13 @@ +package com.tmail.preprod.basic_auth.login; + +import com.tmail.base.TestBase; +import com.tmail.scenarios.BasicAuthLoginScenario; + +public class BasicAuthLoginTest extends TestBase { + BasicAuthLoginTest() { + scenario = new BasicAuthLoginScenario( + properties.getProperty("app.basicAuthUrl"), + properties.getProperty("user.name"), + properties.getProperty("user.password")); + } +} diff --git a/tmail_selenium/src/test/java/com/tmail/preprod/oidc/login/LoginTest.java b/tmail_selenium/src/test/java/com/tmail/preprod/oidc/login/OidcLoginTest.java similarity index 61% rename from tmail_selenium/src/test/java/com/tmail/preprod/oidc/login/LoginTest.java rename to tmail_selenium/src/test/java/com/tmail/preprod/oidc/login/OidcLoginTest.java index d00e215e99..200e64982c 100644 --- a/tmail_selenium/src/test/java/com/tmail/preprod/oidc/login/LoginTest.java +++ b/tmail_selenium/src/test/java/com/tmail/preprod/oidc/login/OidcLoginTest.java @@ -1,12 +1,12 @@ package com.tmail.preprod.oidc.login; import com.tmail.base.TestBase; -import com.tmail.scenarios.LoginScenario; +import com.tmail.scenarios.OidcLoginScenario; -public class LoginTest extends TestBase { +public class OidcLoginTest extends TestBase { - LoginTest() { - scenario = new LoginScenario( + OidcLoginTest() { + scenario = new OidcLoginScenario( properties.getProperty("app.hostUrl"), properties.getProperty("user.name"), properties.getProperty("user.password"));