Skip to content

Commit

Permalink
new changes
Browse files Browse the repository at this point in the history
  • Loading branch information
abhaybharti committed Jun 24, 2024
1 parent 4d2d8df commit f9cf93c
Show file tree
Hide file tree
Showing 12 changed files with 3,311 additions and 96 deletions.
Binary file added Notes/EventLoop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3,067 changes: 3,067 additions & 0 deletions Notes/JavaScript_CheatSheet.md

Large diffs are not rendered by default.

75 changes: 75 additions & 0 deletions Notes/playwright_cheatsheet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Playwright

## Setup & Installation

- NodeJs
- Aqua/IntelliJ/Visual Studio Code
- @playwright/test package (`npm init playwright@latest`)

- What is installed

- playwright.config.ts
- package.json
- package-lock.json
- tests/
- example.spec.ts
- tests-examples/
- demo-todo-app.spec.ts

> ![NOTES] The `playwright.config.js/ts` is where you can add configuration for Playwright including modifying which browsers you would like to run Playwright on.
## Updating Playwright version

To update Playwright to the latest version run the following command:

```
npm install -D @playwright/test@latest
npx playwright install --with-deps
```

Check version of Playwright:

```
npx playwright --version
```

## How to run Example Test

`npx playwright test`

## How to run Example Test in UI mode

`npx playwright test --ui`

## How to see report

`npx playwright show-report`

## npm vs npx - what's the difference

## Why playwright

- supports JS/TS/Java/C#/Python
- Built by Microsoft
- Fast
- Parallel Execution
- Trace Viewer, Inspector, codegen, video

## npx playwright codegen

## run playwright test

## execution command

`npx playwright test` Runs the end-to-end tests.

`npx playwright test --ui` Starts the interactive UI mode.

`npx playwright test --project=chromium` Runs the tests only on Desktop Chrome.

`npx playwright test example` Runs the tests in a specific file.

`npx playwright test --debug` Runs the tests in debug mode.

`npx playwright codegen` Auto generate tests with Codegen.
Binary file added Notes/promise.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 13 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@playwright/test": "^1.40.1",
"@playwright/test": "^1.44.1",
"@types/node": "^20.11.5",
"@typescript-eslint/eslint-plugin": "^6.18.1",
"@typescript-eslint/parser": "^6.18.1",
Expand All @@ -32,6 +32,7 @@
"appium": "^2.4.1",
"dotenv": "^16.3.1",
"mocha": "^10.2.0",
"moment": "^2.30.1",
"nodejs-nodemailer-outlook": "^1.2.4",
"ts-node": "^10.9.2",
"webdriverio": "^8.28.0",
Expand Down
3 changes: 2 additions & 1 deletion src/helper/api/apiHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import exp from "constants";
import { Helper } from "helper/Helper";
import { StringLiteral } from "typescript";

const BASE_URL = "https://restful-booker.herokuapp.com";
// const BASE_URL = "https://restful-booker.herokuapp.com";
const BASE_URL = "https://www.rabstract.com";
export class ApiHelper extends Helper {
private apiContext: any;

Expand Down
56 changes: 56 additions & 0 deletions src/tests/api/example/dashboard.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { expect, test, APIRequestContext } from "@playwright/test";
import moment from "moment";
import { ApiHelper } from "../../../helper/api/apiHelper";

let token: string;
let bookingId: string;

test.beforeAll(async ({ request }) => {
//1. Hit /Auth Api and provide username/password as body
//2. fetch token value from JSON response
//3. save in token variable

const apiHelper = await new ApiHelper(request);
});

const testSuiteTestScriptObject = {
Product_Buy_Flow:
"Verify_that_on_the_product_page,_the_user_can_select_the_desired_attribute_of_the_product_eg_size_color_etc,Verify_that_the_user_can_add_to_the_cart_one_or_more_products,Verify_that_users_can_add_products_to_the_wishlist,Verify_that_the_user_can_see_the_previously_added_products_on_the_cart_page_after_signing_in_to_the_application,Verify_that_the_user_can_successfully_buy_more_than_one_products_that_were_added_to_his/her_cart,Verify_that_the_user_cannot_add_more_than_the_available_inventory_of_the_product,Verify_that_the_limit_to_the_number_of_products_a_user_can_buy_is_working_correctly_Also_an_error_message_gets_displayed_preventing_the_user_from_buying_more_than_the_limit,Verify_that_the_delivery_can_be_declined_during_checkout_for_the_places_where_shipping_is_not_available,Verify_that_the_Cash_on_Delivery_option_of_payment_is_working_fine,Verify_that_the_different_prepaid_methods_of_payments_are_working_fine,Verify_that_product_return_functionality_works_correctly",
User_Registration:
"Verify_that_all_the_required_fields__username,_email,_password,_confirm_password,_etc_are_present_on_the_registration_page,Verify_that_on_passing_valid_values,_a_user_should_get_registered_and_the_same_should_be_allowed_to_log_in_to_the_application,Verify_that_if_a_user_tries_to_register_an_existing_username_then_an_error_message_should_get_displayed,Verify_that_the_required/mandatory_fields_are_marked_with_the_‘*’_symbol,Verify_that_for_a_better_user_interface__dropdowns,_radio_buttons,_checkboxes,_etc_fields_are_displayed_wherever_possible_instead_of_just_text_boxes,Verify_the_page_has_both_submit_and_cancel/reset_buttons_at_the_end,Verify_that_clicking_submits_button_after_entering_all_the_required_fields,_submits_the_data_to_the_server,Verify_that_clicking_the_cancel/reset_button_after_entering_all_the_required_fields,_cancels_the_submit_request,_and_reset_all_the_fields,Verify_that_if_no_value_is_passed_to_the_mandatory_fields_and_submit_button_is_clicked_then_it_leads_to_a_validation_error,Verify_that_the_user_can_leave_the_optional_fields_blank_and_on_clicking_the_submit_button_no_validation_error_appears,Verify_that_whenever_possible_validation_should_take_place_on_the_client_side_For_example,_if_a_user_presses_submit_button_without_entering_a_username_and_password_then_this_validation_should_take_place_on_the_client_side_instead_of_sending_blank_entries_to_the_server,Check_the_upper_limit_of_the_different_textbox_fields,Verify_validation_on_the_date_and_email_fields_Only_valid_dates_and_valid_email_Ids_should_be_allowed,Check_validation_on_numeric_fields_by_entering_alphabets_and_special_characters,Check_that_leading_and_trailing_spaces_are_trimmed_ie_in_case,_the_user_appends_space_before_and_after_a_field,_then_the_same_should_get_trimmed_before_getting_stored_on_the_server",
Portal_Validation:
"Verify_that_the_company_logo_and_name_are_clearly_visible,Verify_that_the_user_is_able_to_navigate_through_all_the_products_across_different_categories,Verify_that_all_the_links_and_banners_are_redirecting_to_the_correct_product/category_pages_and_none_of_the_links_are_broken,Verify_that_all_the_information_displayed__product_name,_category_name,_price,_and_product_description_is_clearly_visible,Verify_that_all_the_images__product_and_banner_are_clearly_visible,Verify_that_category_pages_have_a_relevant_product_listed,_specific_to_the_category,Verify_that_the_correct_count_of_total_products_is_displayed_on_the_category_pages,Search__Verify_that_on_searching,_all_the_products_satisfying_the_search_criteria_are_visible_on_the_search_result_page,Search__Verify_that_on_searching,_products_get_displayed_on_the_basis_of_their_relevancy,Search__Verify_that_the_count_of_products_is_correctly_displayed_on_the_search_result_page_for_a_particular_search_term,Filtering__Verify_that_filtering_functionality_correctly_filters_products_based_on_the_filter_applied,Filtering__Verify_that_filtering_works_correctly_on_category_pages,Filtering__Verify_that_filtering_works_correctly_on_the_search_result_page,Filtering__Verify_that_the_correct_count_of_total_products_is_displayed_after_a_filter_is_applied,Filtering__Verify_that_the_correct_count_and_products_get_displayed_on_applying_multiple_filters,Sorting__Verify_that_all_the_sort_options_work_correctly_On_sorting_the_products_based_on_the_sort_option_chosen,Sorting__Verify_that_sorting_works_correctly_on_the_category_pages,Sorting__Verify_that_sorting_works_correctly_on_the_search_result_page,Sorting__Verify_that_sorting_works_correctly_on_the_pages_containing_the_filtered_result_after_applying_filters,Sorting__Verify_that_the_product_count_remains_the_same_irrespective_of_the_sorting_option_applied",
};

// for (const suiteName in testSuiteTestScriptObject) {
// let testCaseList = testSuiteTestScriptObject[suiteName].split(",");
// for (let iLoop = 0; testCaseList[iLoop]; iLoop++) {
// //console.log(testCaseList[iLoop]);
// test(`${testCaseList[iLoop]}`, async ({ request }) => {
// const apiHelper = await new ApiHelper(request); //
// let todayDate = new Date();
// let env = "SIT";
// let runid = `ecom_run_${moment().format("YYYY-MM-DD")}`; //ecom_run_02_17_2024
// let payLoad = {
// runid: runid,
// suite: suiteName,
// testcasename: testCaseList[iLoop],
// status: "PASS",
// env: "SIT",
// failurereason: "",
// duration: 10,
// browser: null,
// timestamp: moment().format("YYYY-MM-DD HH:mm:ss"), //"2024-03-17 16:40:48",
// reportpath: "abc.html",
// subscriptionkey: "clttt86dt0000mxs8a9thes2h",
// testid: `${runid}|${suiteName}|${testCaseList[iLoop]}|${env}`,
// executiondate: `${moment().format("YYYY-MM-DD")}`,
// };
// console.log("payload : ", payLoad);
// const responseMsg = await apiHelper.invokePostApi(
// "/api/testcase/updateTestCaseExecution",
// payLoad
// );
// });
// }
// }
54 changes: 27 additions & 27 deletions src/tests/mobile/example/healthcheckAndroid.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@ const androidCapabilities = {
"appium:language": "en",
};

describe("Healthcheck Android Appium connection", function () {
let app: AppiumHelper;
// describe("Healthcheck Android Appium connection", function () {
// let app: AppiumHelper;

before(async () => {
app = new AppiumHelper();
await app.init(androidCapabilities);
});
// before(async () => {
// app = new AppiumHelper();
// await app.init(androidCapabilities);
// });

after(async () => {
await app.quit();
});
// after(async () => {
// await app.quit();
// });

it("checks battery level on Settings App", async () => {
const imageButton = await app.findElement("android.widget.ImageButton");
await imageButton.click();
const editText = await app.findElement(
"android=new UiSelector().className(android.widget.EditText)"
);
await editText.click();
await editText.setValue("bat");
const linearLayout = await app.findElement(
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout[2]/android.widget.ScrollView/android.widget.LinearLayout/android.widget.ScrollView/android.widget.LinearLayout/android.widget.FrameLayout/android.support.v7.widget.RecyclerView/android.widget.LinearLayout[3]/android.widget.LinearLayout"
);
await linearLayout.click();
const progressBar = await app.findElement(
"android=new UiSelector().className(android.widget.ProgressBar)"
);
await progressBar.isDisplayed();
});
});
// it("checks battery level on Settings App", async () => {
// const imageButton = await app.findElement("android.widget.ImageButton");
// await imageButton.click();
// const editText = await app.findElement(
// "android=new UiSelector().className(android.widget.EditText)"
// );
// await editText.click();
// await editText.setValue("bat");
// const linearLayout = await app.findElement(
// "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout[2]/android.widget.ScrollView/android.widget.LinearLayout/android.widget.ScrollView/android.widget.LinearLayout/android.widget.FrameLayout/android.support.v7.widget.RecyclerView/android.widget.LinearLayout[3]/android.widget.LinearLayout"
// );
// await linearLayout.click();
// const progressBar = await app.findElement(
// "android=new UiSelector().className(android.widget.ProgressBar)"
// );
// await progressBar.isDisplayed();
// });
// });
88 changes: 44 additions & 44 deletions src/tests/mobile/example/healthcheckiOS.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,47 @@ const capabilities = {
"appium:language": "en",
};

describe("Healthcheck iOS Appium connection", function () {
let app: AppiumHelper;

before(async () => {
app = new AppiumHelper();
await app.init(capabilities);
});

after(async () => {
await app.quit();
});

it("checks iOS version number on Settings App", async () => {
// Go the the "General" section
const generalElement = await app.findElement(
'//XCUIElementTypeCell[@name="General"]'
);
await generalElement.click();

// Go the the "About" section
const aboutElement = await app.findElement(
'//XCUIElementTypeCell[@name="About"]'
);
await aboutElement.click();

// Go the the "iOS Version" section
const versionElement = await app.findElement(
'//XCUIElementTypeCell[@name="iOS Version"]'
);
await versionElement.click();

// Check the version is the on expected
const iosVersionElement = await app.findElement(
`//XCUIElementTypeButton[contains(@name, "iOS ${iOSVersion}")]`
);
const isDisplayed = await iosVersionElement.isDisplayed();

if (!isDisplayed) {
throw new Error(
`Could not find iOS version label ${iOSVersion} on the device`
);
}
});
});
// describe("Healthcheck iOS Appium connection", function () {
// let app: AppiumHelper;

// before(async () => {
// app = new AppiumHelper();
// await app.init(capabilities);
// });

// after(async () => {
// await app.quit();
// });

// it("checks iOS version number on Settings App", async () => {
// // Go the the "General" section
// const generalElement = await app.findElement(
// '//XCUIElementTypeCell[@name="General"]'
// );
// await generalElement.click();

// // Go the the "About" section
// const aboutElement = await app.findElement(
// '//XCUIElementTypeCell[@name="About"]'
// );
// await aboutElement.click();

// // Go the the "iOS Version" section
// const versionElement = await app.findElement(
// '//XCUIElementTypeCell[@name="iOS Version"]'
// );
// await versionElement.click();

// // Check the version is the on expected
// const iosVersionElement = await app.findElement(
// `//XCUIElementTypeButton[contains(@name, "iOS ${iOSVersion}")]`
// );
// const isDisplayed = await iosVersionElement.isDisplayed();

// if (!isDisplayed) {
// throw new Error(
// `Could not find iOS version label ${iOSVersion} on the device`
// );
// }
// });
// });
Loading

0 comments on commit f9cf93c

Please sign in to comment.