Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AYS-448 | Login Functionality Automation #48

Merged
merged 9 commits into from
Dec 22, 2024
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
<logback-classic.version>1.5.8</logback-classic.version>
<commons-compress.version>1.27.1</commons-compress.version>
<pdfbox.version>3.0.3</pdfbox.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -113,10 +112,6 @@
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
Expand Down
15 changes: 14 additions & 1 deletion src/test/java/org/ays/browser/AysPageActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
import org.openqa.selenium.support.ui.WebDriverWait;

import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

@Slf4j
public class AysPageActions {
Expand Down Expand Up @@ -58,7 +60,7 @@ public void clickMethod(WebElement element) {
}

public boolean isPresent(WebElement element) {
this.waitUntilClickable(element);
this.waitUntilVisible(element);
return element.isDisplayed();
}

Expand Down Expand Up @@ -90,4 +92,15 @@ public void waitFor(int seconds) {
}
}

public void openANewTab(String url) {
JavascriptExecutor javascriptExecutor = (JavascriptExecutor) webDriver;
javascriptExecutor.executeScript("window.open(arguments[0], '_blank');", url);
}

public void switchToWindow() {
Set<String> windowHandles = webDriver.getWindowHandles();
List<String> tabs = new ArrayList<>(windowHandles);
webDriver.switchTo().window(tabs.get(1));
}

}
120 changes: 115 additions & 5 deletions src/test/java/org/ays/feature/Login.feature
Original file line number Diff line number Diff line change
@@ -1,8 +1,118 @@
@Regression @Smoke
@Regression
Feature: Login Functionality

Scenario: Login with a valid username and password
Background:
Given Open the institution login page
When Enter the username and password
And Click the Login button
Then The user should be able to successfully log in

@Smoke
Scenario: Login with valid email address and password
When Enter the email address and password
And Click on the Login button
Then The username should be displayed on the homepage after successful login
And accessToken and refreshToken should be stored in localStorage

Scenario Outline: Login with unauthorized user
When Enter unauthorized "<emailAddress>" and "<password>"
And Click on the Login button
Then Error pop-up message should be displayed
Examples:
| emailAddress | password |
| [email protected] | password |

Scenario Outline: Login with invalid emailAddress
When Sets the page language
When Enter invalid "<emailAddress>" and "<password>"
And Click on the Login button
Then User should be able to see invalid email error message
Examples:
| emailAddress | password |
| user | password |
| 123 | password |
| ..... | password |
| !'^+%&/*# | password |
| [email protected] | password |
| user@aysorg | password |
| userays.org | password |

Scenario: Login with a blank email address
When Sets the page language
When Sets the email address to " " and enters "password"
And Click on the Login button
Then User should be able to see invalid email error message

Scenario Outline: Login with invalid password
When Sets the page language
When Enter invalid "<emailAddress>" and "<password>"
And Click on the Login button
Then User should be able to see password errorMessage
Examples:
| emailAddress | password |
| [email protected] | pass |

Scenario: Login with valid email address invalid password
When Sets the page language
When Enter valid emailAddress and invalid password
And Click on the Login button
Then Error pop-up message should be displayed

Scenario: Login with invalid email address valid password
When Sets the page language
When Enter invalid emailAddress and valid password
And Click on the Login button
Then Error pop-up message should be displayed

Scenario: Login with blank email address and password
When Sets the page language
And Click on the Login button
Then User should be able to see errorMessage under email and password input box

@Smoke
Scenario: Password hiding checking
When Enter hiding password
And Click on the eye icon
Then The password should be displayed without being hidden
And Click on the eye icon
Then The password should be displayed hidden

@Smoke
Scenario: Theme checking
When Click on the theme icon
Then User should be able to see dark theme
And Click on the theme icon
Then User should be able to see light theme

@Smoke
Scenario: Language selection checking
When Click on the language button
And Select the Turkish option
Then User should be able to see the Turkish page
And Click on the language button
And Select the English option
Then User should be able to see the English page

Scenario: Logged-in user visits login URL

As a logged-in user, I should not see the login page again when I navigate to the login URL
Instead, I should be redirected to the dashboard page.

When Enter the email address and password
And Click on the Login button
Then The username should be displayed on the homepage after successful login
And The user navigates to the login URL in a new tab
Then The user should be able to see dashboard page

Scenario: Dashboard page access without login

As a user, I should not be able to access the dashboard page without logging in
Instead, I should be redirected to the login page.

When The user navigates to the dashboard page
Then The user should see the login page

Scenario: Refresh Token expiration triggers logout
When Enter the email address and password
And Click on the Login button
And accessToken and refreshToken should be stored in localStorage
And The "refreshToken" expires using mock expiration
Then The user should see the login page

5 changes: 2 additions & 3 deletions src/test/java/org/ays/feature/Logout.feature
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
@Regression @Smoke
Feature: Testing Logout

Background:
Given Open the institution login page
When Enter the username and password
And Click the Login button
When Enter the email address and password
And Click on the Login button

Scenario: Validating logout functionality
cagla88 marked this conversation as resolved.
Show resolved Hide resolved
When Click on the profile button
Expand Down
44 changes: 39 additions & 5 deletions src/test/java/org/ays/pages/LoginPOM.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,50 @@ public LoginPOM() {
PageFactory.initElements(AysBrowser.getWebDriver(), this);
}

@FindBy(xpath = "//input[@id='username']")
private WebElement loginUsername;
@FindBy(name = "emailAddress")
private WebElement loginEmailAddress;

@FindBy(xpath = "//input[@id='password']")
@FindBy(name = "password")
private WebElement loginPassword;

@FindBy(xpath = "//button[@type='submit']")
private WebElement loginButton;

@FindBy(xpath = "//a[.='Admins']")
private WebElement adminsHeader;
@FindBy(xpath = "//div[contains(@class, 'ml-3')]")
private WebElement username;

@FindBy(id = ":r1:-form-item-message")
private WebElement emailAddressErrorMessage;

@FindBy(id = ":r2:-form-item-message")
private WebElement passwordErrorMessage;

@FindBy(xpath = "//div[contains(@class, 'gap-1')]")
private WebElement popupErrorMessage;

@FindBy(xpath = "//div[@class= 'relative']/button")
private WebElement hiddenPasswordIcon;

@FindBy(css = "button")
private WebElement themeIcon;

@FindBy(css = "html.light")
private WebElement lightTheme;

@FindBy(css = "html.dark")
private WebElement darkTheme;

@FindBy(css = "button[role='combobox']")
private WebElement languageButton;

@FindBy(xpath = "//span[text()='Turkish']")
private WebElement turkishOption;

@FindBy(xpath = "//span[text()='İngilizce']")
private WebElement englishOption;

@FindBy(xpath = "//h3")
private WebElement welcomeHeader;


}
5 changes: 4 additions & 1 deletion src/test/java/org/ays/runners/RunnerForSmokeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import io.cucumber.testng.CucumberOptions;

@CucumberOptions(tags = "@Smoke")
@CucumberOptions(
plugin = {"pretty"},
tags = "@Smoke", publish = true
)
public class RunnerForSmokeTest extends AysAbstractTestNGCucumberTests {
}
Loading
Loading