diff --git a/src/test/java/ANALYSIS_TOOLS/ACT24/features/ResearcherPortalPlaywright.feature b/src/test/java/ANALYSIS_TOOLS/ACT24/features/ResearcherPortalPlaywright.feature new file mode 100644 index 000000000..e8f586d82 --- /dev/null +++ b/src/test/java/ANALYSIS_TOOLS/ACT24/features/ResearcherPortalPlaywright.feature @@ -0,0 +1,85 @@ +Feature: These are the scenarios for the Home page on the ACT24 Application + + @Smoke @satya @Regression @playwright @NCIATWP-8536 + Scenario: Verify title of home screen of ACT24 website + Given User navigates to ACT24 website + When User enters "satya.gugulothu@nih.gov" in email and "Satyakotya123@" in password and clicks Login + Then Verify the title of the ACT24 website home page is "Researcher Site" + Then User logout from the ACT24 website + + @Smoke @satya @Regression @playwright @NCIATWP-8537 + Scenario: Verify user is able to click on every menu tabs in the home page + Given User navigates to ACT24 website + When User enters "satya.gugulothu@nih.gov" in email and "Satyakotya123@" in password and clicks Login + Then User clicks on the every menu tabs in the home page + + @Smoke @satya @Regression @playwright @NCIATWP-8538 + Scenario: Verify user is able to click on instructions and export button on the homepage + Given User navigates to ACT24 website + When User enters "satya.gugulothu@nih.gov" in email and "Satyakotya123@" in password and clicks Login + Then User clicks on the instructions to expand details on it and then again click on it + Then User clicks on the export button under my studies menu tab + + @Smoke @satya @Regression @playwright @NCIATWP-8540 + Scenario: Verify user is able to click on instructions and export button on the homepage + Given User navigates to ACT24 website + When User enters "satya.gugulothu@nih.gov" in email and "Satyakotya123@" in password and clicks Login + Then User changes entries visibility to "100" and again to "10" + And Verify columns are clickable in the table displayed + + @Smoke @satya @Regression @playwright @NCIATWP-8537 + Scenario: Verify whether the search is working on the my studies page or not + Given User navigates to ACT24 website + When User enters "satya.gugulothu@nih.gov" in email and "Satyakotya123@" in password and clicks Login + Then User enters text in the search box on the my studies page + Then Verify study abbreviation column contains searched text in the table data + + @Smoke @satya @Regression @playwright @NCIATWP-8541 + Scenario: Verify create new study page is opening on click of the mentioned button + Given User navigates to ACT24 website + When User enters "satya.gugulothu@nih.gov" in email and "Satyakotya123@" in password and clicks Login + Then User clicks on the create new study button on the researcher page + And User verifies that page is opened to create new studies + + @Smoke @satya @Regression @playwright @NCIATWP-8541 + Scenario: Verify study is being created on submitting with the mandatory details + Given User navigates to ACT24 website + When User enters "satya.gugulothu@nih.gov" in email and "Satyakotya123@" in password and clicks Login + Then User clicks on the create new study button on the researcher page + And User enters all the mandatory details for creating the new study + Then User clicks on the submit button to create the study + Then Validate the text "The Study has been created successfully." + + @Smoke @satya @Regression @playwright @NCIATWP-8542 + Scenario: Validate user is on the study staff menu tab in the researcher website + Given User navigates to ACT24 website + When User enters "satya.gugulothu@nih.gov" in email and "Satyakotya123@" in password and clicks Login + And User enters the created study text in the search box on the my studies page + Then User clicks on the study staff button of the searched study + Then Validate user is on the study staff menu tab in the researcher website + + @Smoke @satya @Regression @playwright @NCIATWP-8543 + Scenario: Verify user is able to update the created study details + Given User navigates to ACT24 website + When User enters "satya.gugulothu@nih.gov" in email and "Satyakotya123@" in password and clicks Login + And User enters the created study text in the search box on the my studies page + Then User clicks on the edit study button of the created study + And User edits the entered details of the already created study + Then User clicks on the save changes button and details are getting edited + + @Smoke @satya @Regression @playwright @NCIATWP-8544 + Scenario: Validate search and clear button is working in the analytics data menu tab + Given User navigates to ACT24 website + When User enters "satya.gugulothu@nih.gov" in email and "Satyakotya123@" in password and clicks Login + And User enters the created study text in the search box on the my studies page + Then User clicks on the analytics data for the created study + And User clicks on the clear button + Then User selects the created study from the dropdown again + Then User clicks on the search button on the analytics data menu tab + + @Smoke @satya @Regression @playwright @NCIATWP-8545 + Scenario: Validate the logged in email address is matching with the email address displayed under the my account menu tab + Given User navigates to ACT24 website + When User enters "satya.gugulothu@nih.gov" in email and "Satyakotya123@" in password and clicks Login + And User clicks on the my account menu tab in the act24 researcher website + Then Validate the email field value matches with "satya.gugulothu@nih.gov" \ No newline at end of file diff --git a/src/test/java/ANALYSIS_TOOLS/ACT24/pages/ACT24ResearcherPortalPlaywrightPage.java b/src/test/java/ANALYSIS_TOOLS/ACT24/pages/ACT24ResearcherPortalPlaywrightPage.java new file mode 100644 index 000000000..47c64eae1 --- /dev/null +++ b/src/test/java/ANALYSIS_TOOLS/ACT24/pages/ACT24ResearcherPortalPlaywrightPage.java @@ -0,0 +1,69 @@ +package ANALYSIS_TOOLS.ACT24.pages; + +public class ACT24ResearcherPortalPlaywrightPage { + + /*** + * LOGOUT LOCATOR + */ + public static String logoutLocator = "//a[@id='logout']"; + + /*** + * SEARCH BOX LOCATOR + */ + public static String searchBox = "//input[@type='search']"; + + /*** + * CREATE NEW STUDY LOCATOR + */ + public static String createNewStudy = "//a[normalize-space()='Create New Study']"; + + /*** + * SUCCESS ALERT FOR STUDY CREATED + */ + public static String successAlertStudy = "//div[@class='alert alert-success']"; + + /*** + * SUBMIT BUTTON LOCATOR + */ + public static String submitButtonLocator = "//button[@id='submitCreateStudy']"; + + /*** + * STUDY STAFF LOCATOR + */ + public static String studyStaff = "//table[@id='myStudies']//tbody//tr//a[@name='studyStaff']"; + + /*** + * STUDY STAFF MENU TAB LOCATOR + */ + public static String studyStaffMenuTab = "//a[normalize-space()='Study Staff']"; + + /*** + * MY ACCOUNT LOCATOR + */ + public static String myAccount = "//a[normalize-space()='My Account']"; + + /*** + * EDIT STUDY LOCATOR + */ + public static String editStudy = "//table[@id='myStudies']//tbody//tr//a[@name='editStudy']"; + + /*** + * SUBMIT CREATED STUDY LOCATOR + */ + public static String submitCreatedStudy = "//button[@id='submitCreateStudy']"; + + /*** + * SEARCH ANALYTICS BUTTON LOCATOR + */ + public static String searchAnalyticsButton = "//input[@id='searchAnalyticsButton']"; + + /*** + * CLEAR BUTTON LOCATOR + */ + public static String clearButton = "//a[@id='clearSearch']"; + + /*** + * ANALYTICS DATA LOCATOR + */ + public static String analyticsData = "//table[@id='myStudies']//tbody//tr//a[@title='Analytic Data']"; +} \ No newline at end of file diff --git a/src/test/java/ANALYSIS_TOOLS/ACT24/steps/ACT24ResearcherPortalPlaywrightSteps.java b/src/test/java/ANALYSIS_TOOLS/ACT24/steps/ACT24ResearcherPortalPlaywrightSteps.java new file mode 100644 index 000000000..7fb56b3ac --- /dev/null +++ b/src/test/java/ANALYSIS_TOOLS/ACT24/steps/ACT24ResearcherPortalPlaywrightSteps.java @@ -0,0 +1,249 @@ +package ANALYSIS_TOOLS.ACT24.steps; + +import ANALYSIS_TOOLS.ACT24.pages.ACT24ResearcherPortalPlaywrightPage; +import ANALYSIS_TOOLS.ACT24.stepsImpl.ACT24ResearcherPlaywrightStepImpl; +import com.microsoft.playwright.Page; +import com.microsoft.playwright.options.AriaRole; +import com.nci.automation.web.CommonUtils; +import com.nci.automation.web.PlaywrightUtils; +import io.cucumber.java.en.And; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; +import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat; +import static com.nci.automation.web.TestProperties.getACT24Url; + +public class ACT24ResearcherPortalPlaywrightSteps { + + @Given("User navigates to ACT24 website") + public void user_navigates_to_act24_website() { + PlaywrightUtils.page.navigate(getACT24Url()); + CommonUtils.sleep(2000); + } + + /** + * Entering email and password to login + * + * @param email The email to be entered. + * @param password The password to be entered. + */ + @When("User enters {string} in email and {string} in password and clicks Login") + public void user_enters_in_email_and_in_password_and_clicks_login(String email, String password) { + ACT24ResearcherPlaywrightStepImpl.enterLoginDetails(email, password); + } + + /** + * Validating the title for the ACT24 homepage + */ + @Then("Verify the title of the ACT24 website home page is {string}") + public void verify_the_title_of_the_act24_website_home_page_is(String ResearcherPageTitle) { + assertThat(PlaywrightUtils.page).hasTitle(ResearcherPageTitle); + } + + /** + * Clicking on logout button to check logout functionality + */ + @Then("User logout from the ACT24 website") + public void user_logout_from_the_act24_website() { + PlaywrightUtils.page.locator(ACT24ResearcherPortalPlaywrightPage.logoutLocator).click(); + } + + /** + * Clicking every menu tabs + */ + @Then("User clicks on the every menu tabs in the home page") + public void user_clicks_on_the_every_menu_tabs_in_the_home_page() { + ACT24ResearcherPlaywrightStepImpl.clickOnEveryMenuTabs(); + } + + /** + * Clicking on instruction + */ + @Then("User clicks on the instructions to expand details on it and then again click on it") + public void user_clicks_on_the_instructions_to_expand_details_on_it_and_then_again_click_on_it() { + ACT24ResearcherPlaywrightStepImpl.clickInstructions(); + } + + /** + * Clicking on export button + */ + @Then("User clicks on the export button under my studies menu tab") + public void user_clicks_on_the_export_button_under_my_studies_menu_tab() { + ACT24ResearcherPlaywrightStepImpl.clickExportButton(); + } + + /** + * Selecting different entries on show entries dropdown + * + * @param entry1 The entry1 to be selected. + * @param entry2 The entry2 to be selected. + */ + @Then("User changes entries visibility to {string} and again to {string}") + public void user_changes_entries_visibility_to_and_again_to(String entry1, String entry2) { + ACT24ResearcherPlaywrightStepImpl.changesEntriesVisibility(entry1, entry2); + } + + /** + * Checking column is clickable and clicking on it + */ + @Then("Verify columns are clickable in the table displayed") + public void verify_columns_are_clickable_in_the_table_displayed() { + ACT24ResearcherPlaywrightStepImpl.checkColumnClickable(); + } + + /** + * Entering text in the search box + */ + @Then("User enters text in the search box on the my studies page") + public void user_enters_text_in_the_search_box_on_the_my_studies_page() { + PlaywrightUtils.page.locator(ACT24ResearcherPortalPlaywrightPage.searchBox).fill("KSA146"); + } + + /** + * Verifying the searched text in abbreviation column of the table data + */ + @Then("Verify study abbreviation column contains searched text in the table data") + public void verify_study_abbreviation_column_contains_searched_text_in_the_table_data() { + assertThat(PlaywrightUtils.page.getByRole(AriaRole.CELL, new Page.GetByRoleOptions().setName("KSA146"))).containsText("KS"); + } + + /** + * Clicking on th Create New Study button + */ + @Then("User clicks on the create new study button on the researcher page") + public void user_clicks_on_the_create_new_study_button_on_the_researcher_page() { + PlaywrightUtils.page.locator(ACT24ResearcherPortalPlaywrightPage.createNewStudy).click(); + } + + /** + * Checking user is on the create new study page + */ + @Given("User verifies that page is opened to create new studies") + public void user_verifies_that_page_is_opened_to_create_new_studies() { + ACT24ResearcherPlaywrightStepImpl.checkCreateStudyPageOpened(); + } + + /** + * Entering all the mandatory details to create an study + */ + @Then("User enters all the mandatory details for creating the new study") + public void user_enters_all_the_mandatory_details_for_creating_the_new_study() { + ACT24ResearcherPlaywrightStepImpl.enterMandatoryDetailsToCreateStudy(); + } + + /** + * Clicking on the Submit button + */ + @Then("User clicks on the submit button to create the study") + public void user_clicks_on_the_submit_button_to_create_the_study() { + PlaywrightUtils.page.locator(ACT24ResearcherPortalPlaywrightPage.submitButtonLocator).click(); + } + + /** + * Validating the text which is displayed on the creation of the study + * + * @param studyCreationText The mentioned text to be verified. + */ + @Then("Validate the text {string}") + public void validate_the_text(String studyCreationText) { + assertThat(PlaywrightUtils.page.locator(ACT24ResearcherPortalPlaywrightPage.successAlertStudy)).containsText(studyCreationText); + } + + /** + * Searching the created study + */ + @Given("User enters the created study text in the search box on the my studies page") + public void user_enters_the_created_study_text_in_the_search_box_on_the_my_studies_page() { + ACT24ResearcherPlaywrightStepImpl.searchCreatedStudy(); + } + + /** + * Clicking on the Study Staff button + */ + @Then("User clicks on the study staff button of the searched study") + public void user_clicks_on_the_study_staff_button_of_the_searched_study() { + PlaywrightUtils.page.locator(ACT24ResearcherPortalPlaywrightPage.studyStaff).click(); + } + + /** + * Validating that user is on the Study Staff manu tab + */ + @Then("Validate user is on the study staff menu tab in the researcher website") + public void validate_user_is_on_the_study_staff_menu_tab_in_the_researcher_website() { + assertThat(PlaywrightUtils.page.locator(ACT24ResearcherPortalPlaywrightPage.studyStaffMenuTab)).containsText("Study Staff"); + } + + /** + * User clicks on the my account menu tab + */ + @Given("User clicks on the my account menu tab in the act24 researcher website") + public void user_clicks_on_the_my_account_menu_tab_in_the_act24_researcher_website() { + PlaywrightUtils.page.locator(ACT24ResearcherPortalPlaywrightPage.myAccount).click(); + } + + /** + * Validating the displayed email in my account with the login email address + * + * @param emailInMyAccount The mentioned email to be verified. + */ + @Then("Validate the email field value matches with {string}") + public void validate_the_email_field_value_matches_with(String emailInMyAccount) { + ACT24ResearcherPlaywrightStepImpl.verifyEmailAddress(emailInMyAccount); + } + + /** + * Clicking on the edit study button of the created study + */ + @Then("User clicks on the edit study button of the created study") + public void user_clicks_on_the_edit_study_button_of_the_created_study() { + PlaywrightUtils.page.locator(ACT24ResearcherPortalPlaywrightPage.editStudy).click(); + } + + /** + * Updating the details of the created study + */ + @Then("User edits the entered details of the already created study") + public void user_edits_the_entered_details_of_the_already_created_study() { + ACT24ResearcherPlaywrightStepImpl.updateCreatedStudyDetails(); + } + + /** + * Clicking on the save changes button to edit the study details + */ + @Then("User clicks on the save changes button and details are getting edited") + public void user_clicks_on_the_save_changes_button_and_details_are_getting_edited() { + PlaywrightUtils.page.locator(ACT24ResearcherPortalPlaywrightPage.submitCreatedStudy).click(); + } + + /** + * Clicking on the analytics data for the created study + */ + @Then("User clicks on the analytics data for the created study") + public void user_clicks_on_the_analytics_data_for_the_created_study() { + PlaywrightUtils.page.locator(ACT24ResearcherPortalPlaywrightPage.analyticsData).click(); + } + + /** + * Clicking on the clear button + */ + @And("User clicks on the clear button") + public void user_clicks_on_the_clear_button() { + PlaywrightUtils.page.locator(ACT24ResearcherPortalPlaywrightPage.clearButton).click(); + } + + /** + * Selecting the created study from the dropdown + */ + @Then("User selects the created study from the dropdown again") + public void user_selects_the_created_study_from_the_dropdown_again() { + ACT24ResearcherPlaywrightStepImpl.selectCreatedStudy(); + } + + /** + * Clicking on the search button on the analytics data menu tab + */ + @Then("User clicks on the search button on the analytics data menu tab") + public void user_clicks_on_the_search_button_on_the_analytics_data_menu_tab() { + PlaywrightUtils.page.locator(ACT24ResearcherPortalPlaywrightPage.searchAnalyticsButton).click(); + } +} \ No newline at end of file diff --git a/src/test/java/ANALYSIS_TOOLS/ACT24/stepsImpl/ACT24ResearcherPlaywrightStepImpl.java b/src/test/java/ANALYSIS_TOOLS/ACT24/stepsImpl/ACT24ResearcherPlaywrightStepImpl.java new file mode 100644 index 000000000..0f7bac661 --- /dev/null +++ b/src/test/java/ANALYSIS_TOOLS/ACT24/stepsImpl/ACT24ResearcherPlaywrightStepImpl.java @@ -0,0 +1,157 @@ +package ANALYSIS_TOOLS.ACT24.stepsImpl; + +import ANALYSIS_TOOLS.ACT24.pages.ACT24ResearcherPortalPlaywrightPage; +import com.microsoft.playwright.ElementHandle; +import com.microsoft.playwright.Locator; +import com.nci.automation.web.CommonUtils; +import com.nci.automation.web.PlaywrightUtils; +import org.testng.Assert; +import java.util.ArrayList; +import java.util.concurrent.ThreadLocalRandom; + +public class ACT24ResearcherPlaywrightStepImpl { + + public static int uniqueNumber = ThreadLocalRandom.current().nextInt(100, 1000); + public static String studyName = "KGA" + uniqueNumber; + + /** + * Entering email and password to login + * + * @param email The email to be entered. + * @param password The password to be entered. + */ + public static void enterLoginDetails(String email, String password) { + PlaywrightUtils.page.locator("//input[@id='email']").fill(email); + CommonUtils.sleep(2000); + PlaywrightUtils.page.locator("//input[@id='password']").fill(password); + CommonUtils.sleep(2000); + PlaywrightUtils.page.locator("//button[@id='login']").click(); + CommonUtils.sleep(4000); + } + + /** + * Clicking every menu tabs + */ + public static void clickOnEveryMenuTabs() { + Locator menuTabs = PlaywrightUtils.page.locator("//li[@role='presentation']"); + ArrayList arr = new ArrayList<>(); + String actualText = "[MY STUDIES, STUDY STAFF, PARTICIPANT ACCOUNTS, TRACK RECALLS, ANALYTIC DATA, MY ACCOUNT]"; + for(ElementHandle tabs : menuTabs.elementHandles()){ + String str = tabs.innerText(); + arr.add(str); + } + System.out.println(arr); + Assert.assertEquals(actualText, arr.toString()); + } + + /** + * Clicking on instruction + */ + public static void clickInstructions() { + PlaywrightUtils.page.locator("//div[@class='orgchartSelector']").click(); + PlaywrightUtils.page.locator("//div[@class='orgchartSelector active']").click(); + } + + /** + * Clicking on export button + */ + public static void clickExportButton() { + CommonUtils.sleep(2000); + PlaywrightUtils.page.locator("//button[@id='exportMyStudies1']").click(); + CommonUtils.sleep(2000); + PlaywrightUtils.page.locator("//button[@id='exportMyStudies2']//span[@class='glyphicon glyphicon-export']").click(); + } + + /** + * Selecting different entries on show entries dropdown + * + * @param entry1 The entry1 to be selected. + * @param entry2 The entry2 to be selected. + */ + public static void changesEntriesVisibility(String entry1, String entry2) { + PlaywrightUtils.page.locator("//select[@name='myStudies_length']").selectOption(entry1); + PlaywrightUtils.page.locator("//select[@name='myStudies_length']").selectOption(entry2); + } + + /** + * Checking column is clickable and clicking on it + */ + public static void checkColumnClickable() { + Locator columnButton = PlaywrightUtils.page.locator("//th[@aria-label='Study Abbreviation: activate to sort column descending: activate to sort column descending']"); + columnButton.isEnabled(); + columnButton.click(); + } + + /** + * Checking user is on the create new study page + */ + public static void checkCreateStudyPageOpened() { + String createStudy = PlaywrightUtils.page.locator("//h4[normalize-space()='Create New Study']").innerText(); + Assert.assertEquals("Create New Study", createStudy); + } + + /** + * Entering all the mandatory details to create an study + */ + public static void enterMandatoryDetailsToCreateStudy() { + PlaywrightUtils.page.locator("//input[@id='studyActual']").click(); + System.out.println(studyName); + PlaywrightUtils.page.locator("//input[@id='name']").fill(studyName); + CommonUtils.sleep(2000); + PlaywrightUtils.page.locator("//textarea[@id='description']").fill(studyName); + PlaywrightUtils.page.locator("//input[@id='abbreviation']").fill(studyName); + CommonUtils.sleep(2000); + Locator participantCount = PlaywrightUtils.page.locator("//input[@id='participantCount']"); + participantCount.clear(); + participantCount.fill("5"); + Locator recallCount = PlaywrightUtils.page.locator("//input[@id='recallCount']"); + recallCount.clear(); + recallCount.fill("5"); + PlaywrightUtils.page.locator("//input[@id='startDate']").type("12/12/2024"); + CommonUtils.sleep(2000); + PlaywrightUtils.page.locator("//input[@id='endDate']").type("02/02/2025"); + CommonUtils.sleep(2000); + PlaywrightUtils.page.locator("//input[@id='hasFunds2']").click(); + PlaywrightUtils.page.locator("//input[@id='loginAccessRequired1']").click(); + PlaywrightUtils.page.locator("//input[@id='accessAcknowledgement']").click(); + PlaywrightUtils.page.locator("//label[normalize-space()='Accept']//input[@id='acceptBtn']").click(); + CommonUtils.sleep(2000); + } + + /** + * Searching the created study + */ + public static void searchCreatedStudy() { + PlaywrightUtils.page.locator(ACT24ResearcherPortalPlaywrightPage.searchBox).fill(studyName); + CommonUtils.sleep(2000); + } + + /** + * Validating the displayed email in my account with the login email address + * + * @param emailInMyAccount The mentioned email to be verified. + */ + public static void verifyEmailAddress(String emailInMyAccount) { + String emailAddress = PlaywrightUtils.page.locator("//input[@id='email']").inputValue(); + Assert.assertEquals(emailInMyAccount, emailAddress); + } + + /** + * Updating the details of the created study + */ + public static void updateCreatedStudyDetails() { + Locator participantCount = PlaywrightUtils.page.locator("//input[@id='participantCount']"); + participantCount.clear(); + participantCount.fill("8"); + Locator recallCount = PlaywrightUtils.page.locator("//input[@id='recallCount']"); + recallCount.clear(); + recallCount.fill("5"); + } + + /** + * Selecting the created study from the dropdown + */ + public static void selectCreatedStudy() { + PlaywrightUtils.page.locator("//select[@id='studyId']").selectOption(studyName+" - "+studyName); + } +} \ No newline at end of file