├── .DS_Store
├── .circleci
└── config.yml
├── .github
└── workflows
│ └── playwright.yml
├── .gitignore
├── README.md
├── allure-results
├── 09080717-9e2b-4219-b853-6a8312da2546-attachment.txt
├── 0dc9776c-66b9-4ce5-9796-e4b72a40f391-attachment.ZIP
├── 1056a6b8-6d23-4270-876f-cdd50ae9e10c-attachment.webm
├── 1d9e1581-90cd-49c5-bb87-24401eb3da01-attachment.txt
├── 2d3feb83-9bfc-4a4d-b35d-36c7067578df-attachment.txt
├── 336a8b5a-5c33-43b0-ba87-dd77b37b5b0d-attachment.ZIP
├── 3bfbac35-c2e2-4615-99c2-b7cba0a3922f-attachment.ZIP
├── 4e9029a5-14a6-43d2-87f9-f5981c0c4865-attachment.txt
├── 55ddf975-3b56-4c5b-86d0-15b2094713a8-attachment.txt
├── 5983f0ba-20c4-4aa3-a9ad-c4417250df1e-attachment.txt
├── 5dcf7397-5cca-4e14-9c02-0e0a9b98d88b-result.json
├── 6001a293-1434-4be5-8cdc-a119cb156613-container.json
├── 6294aacd-1d49-4ac0-be0d-e5141bec2da3-attachment.txt
├── 645c6a4f-606e-4a6c-b588-893f7c30f8bc-attachment.txt
├── 694da101-5722-48e7-9895-eacc7dc1a0b6-attachment.txt
├── 6fd0eb29-322f-4a13-8ab2-db83cc1ea269-container.json
├── 72e9dc81-83e2-49b1-b671-07a6cba70ef2-attachment.webm
├── 75f5d0b8-a7ba-4c63-83d3-b603ad7549b2-attachment.txt
├── 76acdeb5-4266-4d3c-bcc1-34e33ffab69f-attachment.png
├── 7794a463-a29a-4b17-b8aa-ee1e1a67467b-attachment.txt
├── 7b41064a-9d83-4bd7-979f-8da819ed9bd1-attachment.txt
├── 7c1f10e6-dab2-4119-bd6f-2ded8f4d2cf4-attachment.ZIP
├── 7e30bdc5-0459-45ee-a8ff-41418d22bb0f-attachment.png
├── 7e60137e-2c64-4fc6-bbe8-1b8449fed54e-attachment.webm
├── 836dbe31-1a21-47e2-94fc-c4456d00fda5-result.json
├── 8fce553c-868b-4722-ac60-6b6c66ce46bb-attachment.txt
├── 93d86d6f-c18f-46f7-8984-966d6e03e6f5-container.json
├── 9604978e-e66c-47bf-bf7e-3ec0284e97fd-attachment.txt
├── 9a5cfbda-5207-43b8-bc75-4983db0e6f3d-attachment.txt
├── aac21be1-d88e-4be1-aa67-46b780a50e91-container.json
├── b17eb6e3-6c24-4c6f-bb04-1547691af075-attachment.webm
├── b21b8f9b-344c-47e5-8b9f-5bd5b3d731cd-result.json
├── bb05c060-5ce8-4795-9e57-ea30b11e0f3e-result.json
├── bc222910-103b-4866-af25-9330174c886f-attachment.txt
├── be2f02e5-6ece-4ddb-bcfe-906b9f3e5a51-attachment.txt
├── c9862c3b-52eb-4407-a7a9-50dc151fa9ee-attachment.txt
├── d439824d-48fc-4328-b2cc-b7f2f72bde82-attachment.ZIP
├── d4b15b92-6d3d-47ee-9e6d-aff98f4a1b62-container.json
├── d6834311-42df-491b-8412-a5d98bba2d2b-attachment.png
├── d80b822d-3c14-4136-a9a8-5bcbbf174ee8-container.json
├── e45a4ede-1818-4eaa-a1db-351363647c08-attachment.txt
├── e9225d8b-5e37-4dbd-92c0-d418f426b619-attachment.png
├── ed5c9ee9-a2b8-46c0-b14c-5392485457f3-attachment.png
├── ee1e9630-6b4e-4dc0-b48e-dd8f70291ea9-container.json
├── f5d44336-c3ed-47a2-bb8e-2f4de5bde174-attachment.txt
├── f6b18479-e3e4-474b-b8f1-6987e0b71eb4-result.json
└── faa7fba1-3d6b-4ca2-a973-51f4bd2fb61b-attachment.webm
├── package-lock.json
├── package.json
├── pageObjects
├── CartPage.js
├── CheckoutPage.js
├── DashboardPage.js
├── LoginPage.js
└── POM_Manager.js
├── playwright-report
└── index.html
├── playwright.config-custom.js
├── playwright.config.js
├── screenshots
├── Screenshot_Element.png
├── Screenshot_FullPage.png
└── Screenshot_VisibleScreen.png
├── state.json
├── testData
├── credentials_login.json
└── credentials_login_multipleDataSet.json
├── tests
├── .DS_Store
├── Section_02_RS_UI_Tests
│ ├── 01_NavigateToApplication.spec.js
│ ├── 02_Assert_Title.spec.js
│ └── 03_WaitAndAssertTitle.spec.js
├── Section_03_RS_UI_Tests
│ ├── 04_Type_And_Click.spec.js
│ ├── 05_Assert_ExtractTextOfElement.spec.js
│ ├── 06_Optimized.spec.js
│ ├── 07_Fill_And_SignIn.spec.js
│ ├── 08_SignIn_GetTitleOfFirstProduct.spec.js
│ ├── 09_SignIn_allTextContents.spec.js
│ └── 10_NW_SignIn_WaitForStaticSite.spec.js
├── Section_04_RS_UI_Tests
│ ├── 11_Dropdown_Static.spec.js
│ ├── 12_Dropdown_Static_Pause.spec.js
│ ├── 13_RadioButton.spec.js
│ ├── 14_Checkbox.spec.js
│ ├── 15_Assert_AttributeValue.spec.js
│ ├── 16_Handle_ChildWindows.spec.js
│ ├── 17_NW_ChangeFocusFromChildToParentWin.spec.js
│ └── 18_NW_MoreThanOneChildWindows.spec.js
├── Section_06_RS_UI_Tests_ClientApp
│ ├── 19_Login_Assert_LoginSuccess.spec.js
│ ├── 20_Login_allTextContents.spec.js
│ ├── 21_Login_AddProduct_ToCart.spec.js
│ ├── 22_Login_AssertProductOnCartPage.spec.js
│ ├── 23_NW_Login_Dropdown_AutoSuggestive.spec.js
│ ├── 25_Login_Assert_EmailID.spec.js
│ ├── 26_NW_Login_Assert_Message_OrderPlacedPage.spec.js
│ ├── 27_NW_Login_Assert_OrderID_On_OrderHistoryPage.spec.js
│ └── 28_NW_Login_Assert_OrderID_On_OrderSummaryPage.spec.js
├── Section_07_RS_UI_Tests
│ ├── 29_goBack_Forward.spec.js
│ ├── 30_Element_VisibleOrHidden.spec.js
│ ├── 31_Handle_Alerts_Popup_Dialog.spec.js
│ ├── 32_MouseHover.spec.js
│ └── 33_Handle_Frames.spec.js
├── Section_08_RS_UI_API_Tests
│ ├── 34_Skip_Login_Using_API.spec.js
│ ├── 35_Skip_Login_CreateOrder_AssertOrderHistoryPage.spec.js
│ ├── 36_Optimized_Skip_Login_From_Utils.spec.js
│ └── 37_Optimized_Skip_Login_CreateOrder.spec.js
├── Section_09_RS_UI_API_Tests
│ ├── 38_Use_Browser_StorageState_ToSkip_Login.spec.js
│ ├── 39_NW_Intercept_API_Response_ToSee_NoOrderMessage.spec.js
│ ├── 40_Intercept_API_Request_Message_YouAreNotAuthorized.spec.js
│ ├── 41_Intercept_API_Block_NetworkCalls.spec.js
│ ├── 42_Intercept_API_Block_Images_ToLoad.spec.js
│ └── 43_API_Log_RequestURLs_ResponseStatusCode.spec.js
├── Section_10_RS_UI_Tests
│ ├── 44_Screenshot_Element_VisibleScreen_FullPage.spec.js
│ ├── 45_Screenshots_Comparison.spec.js
│ └── 45_Screenshots_Comparison.spec.js-snapshots
│ │ ├── uk-flightaware-prod-chromium-darwin.png
│ │ └── uk-flightaware-prod-webkit-darwin.png
├── Section_11_RS_UI_Tests_POM
│ ├── 46_POM_Login_Assert_Msg_LoginSuccess.spec.js
│ ├── 47_POM_Login_Assert_Msg_AddToCart.spec.js
│ ├── 48_NW_POM_Login_Assert_ProductName_OnCartPage.spec.js
│ ├── 49_POM_Login_Assert_Email_OnCheckoutPage.spec.js
│ ├── 50_NW_POM_Login_Dropdown_AutoSuggestive.spec.js
│ ├── 51_POM_Optimized_Login_Assert_Email_OnCheckoutPage.spec.js
│ ├── 53_POM_Optimized_Login_TestData_JSON.spec.js
│ ├── 54_POM_Optimized_Login_MultipleDataSet_JSON.spec.js
│ ├── 55_POM_Optimized_Login_TestData_Fixture.spec.js
│ ├── P_52_NW_POM_Optimized_CompleteTillOrderHistory.spec.js
│ └── P_54_POM_Optimized_Login_MultipleDataSet_JSON.spec.js
└── Section_13_RS_UI_Tests
│ ├── 55_RetryFailedTestCase_Assert_Title.spec.js
│ ├── 56_RetryFailedTestCase_Type_And_Click.spec.js
│ ├── 57_Assert_Title_4_TestsInOneSpecFile_Parallel.spec.js
│ ├── 58_Assert_Title_4_TestsInOneSpecFile_Default.spec.js
│ ├── 58_Assert_Title_4_TestsInOneSpecFile_Serial.spec.js
│ └── 59_Tagging.spec.js
└── utils
├── APIUtils.js
├── CommonUtils.js
└── test-base.js
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/Playwright_JS/253a3370309b6d649bed58ef7948cff1be337349/.DS_Store
--------------------------------------------------------------------------------
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | jobs:
3 | build:
4 | docker:
5 | - image: qawolf/playwright-ci:v1.0.0
6 | steps:
7 | - checkout
8 |
9 | - run:
10 | command: npm install
11 |
12 | - run:
13 | command: |
14 | # # Start local server
15 | # npm run start &
16 | # npx wait-on http://localhost:3000
17 | # replace below with command you want to run, example for running a script below
18 | # node myScript.js
19 | # npm test
20 | npx playwright test tests/*/03_WaitAndAssertTitle.spec.js --headed
21 |
22 | # # example for running on a schedule, edit to suit your use case
23 | # # documentation: https://circleci.com/docs/2.0/configuration-reference/#schedule
24 | # workflows:
25 | # version: 2
26 | # on_schedule:
27 | # jobs:
28 | # - build
29 | # triggers:
30 | # - schedule:
31 | # # test on schedule using cron syntax
32 | # cron: "0 * * * *" # every hour
33 | # filters:
34 | # branches:
35 | # only:
36 | # - master
--------------------------------------------------------------------------------
/.github/workflows/playwright.yml:
--------------------------------------------------------------------------------
1 | # name: Playwright Tests
2 | # on:
3 | # push:
4 | # branches: [ main, master ]
5 | # pull_request:
6 | # branches: [ main, master ]
7 | # jobs:
8 | # e2e-tests:
9 | # timeout-minutes: 60
10 | # runs-on: ubuntu-latest
11 | # steps:
12 | # - uses: actions/checkout@v2
13 | # - uses: actions/setup-node@v2
14 | # with:
15 | # node-version: '14.x'
16 | # - name: Install dependencies
17 | # run: npm ci
18 | # - name: Install Playwright
19 | # run: npx playwright install --with-deps
20 | # - name: Run Playwright tests
21 | # run: npx playwright test tests/*/03_WaitAndAssertTitle.spec.js --headed
22 | # - uses: actions/upload-artifact@v2
23 | # if: always()
24 | # with:
25 | # name: playwright-report
26 | # path: playwright-report/
27 | # retention-days: 30
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .vscode
2 | .DS_Store
3 | node_modules
4 | REFERENCE_Learning
5 | playwright-report
6 | test-results
7 | allure-results
8 |
9 |
10 | # cypress/reports/mochawesome-report/
11 | # cypress/screenshots/
12 | # browserstack.json
13 |
14 |
15 | #~/.jenkins
16 | #~/.android
17 | #.jenkins
18 | #.android
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Playwright_JS
2 | Automation Testing | Web+API | Playwright | Javascript | VS Code | Parallel Cross Browser Testing | API Interceptor | Videos | Screenshots | Trace | Retries | Tagging | Viewport | Reports - Playwright, Allure | SSL | Execution - Parallel, Serial, Default | Parameterization using multiple Data sets
3 |
4 | ------------------------------------------------------------------------------------------------------------------------
5 | # Course: Playwright JS Automation Testing from Scratch with Framework
6 |
7 |
8 | # Tutor: Rahul Shetty
9 |
10 | ------------------------------------------------------------------------------------------------------------------------
11 | # Learnings from Course : [Summary_UDEMY_RS_Playwright JS Automation Testing from Scratch with Framework.pdf](https://github.com/rajatt95/Playwright_JS/files/8687148/Summary_UDEMY_RS_Playwright.JS.Automation.Testing.from.Scratch.with.Framework.pdf)
12 | ------------------------------------------------------------------------------------------------------------------------
13 |
14 | 
15 | 
16 | 
17 | 
18 | 
19 | 
20 | 
21 | 
22 |
23 |
24 | 
25 | 
26 |
27 |
28 |
--------------------------------------------------------------------------------
/allure-results/09080717-9e2b-4219-b853-6a8312da2546-attachment.txt:
--------------------------------------------------------------------------------
1 | Clicking on: undefined
2 |
--------------------------------------------------------------------------------
/allure-results/0dc9776c-66b9-4ce5-9796-e4b72a40f391-attachment.ZIP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/Playwright_JS/253a3370309b6d649bed58ef7948cff1be337349/allure-results/0dc9776c-66b9-4ce5-9796-e4b72a40f391-attachment.ZIP
--------------------------------------------------------------------------------
/allure-results/1056a6b8-6d23-4270-876f-cdd50ae9e10c-attachment.webm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/Playwright_JS/253a3370309b6d649bed58ef7948cff1be337349/allure-results/1056a6b8-6d23-4270-876f-cdd50ae9e10c-attachment.webm
--------------------------------------------------------------------------------
/allure-results/1d9e1581-90cd-49c5-bb87-24401eb3da01-attachment.txt:
--------------------------------------------------------------------------------
1 | Go to application: https://rahulshettyacademy.com/AutomationPractice/
2 |
--------------------------------------------------------------------------------
/allure-results/2d3feb83-9bfc-4a4d-b35d-36c7067578df-attachment.txt:
--------------------------------------------------------------------------------
1 | Mouse Hover on: Button Mouse Hover
2 |
--------------------------------------------------------------------------------
/allure-results/336a8b5a-5c33-43b0-ba87-dd77b37b5b0d-attachment.ZIP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/Playwright_JS/253a3370309b6d649bed58ef7948cff1be337349/allure-results/336a8b5a-5c33-43b0-ba87-dd77b37b5b0d-attachment.ZIP
--------------------------------------------------------------------------------
/allure-results/3bfbac35-c2e2-4615-99c2-b7cba0a3922f-attachment.ZIP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/Playwright_JS/253a3370309b6d649bed58ef7948cff1be337349/allure-results/3bfbac35-c2e2-4615-99c2-b7cba0a3922f-attachment.ZIP
--------------------------------------------------------------------------------
/allure-results/4e9029a5-14a6-43d2-87f9-f5981c0c4865-attachment.txt:
--------------------------------------------------------------------------------
1 | Additional Wait for 2 seconds.
2 |
--------------------------------------------------------------------------------
/allure-results/55ddf975-3b56-4c5b-86d0-15b2094713a8-attachment.txt:
--------------------------------------------------------------------------------
1 | Additional Wait for 2 seconds.
2 |
--------------------------------------------------------------------------------
/allure-results/5983f0ba-20c4-4aa3-a9ad-c4417250df1e-attachment.txt:
--------------------------------------------------------------------------------
1 | Mouse Hover on: Button Mouse Hover
2 |
--------------------------------------------------------------------------------
/allure-results/5dcf7397-5cca-4e14-9c02-0e0a9b98d88b-result.json:
--------------------------------------------------------------------------------
1 | {"uuid":"5dcf7397-5cca-4e14-9c02-0e0a9b98d88b","historyId":"firefox 04_RS_UI_Tests_Section_7/32_MouseHover.spec.js RS - Playwright Test - RahulShettyAcademy Automation Practice App - Handle Alerts/Popu/Dialog","status":"passed","statusDetails":{},"stage":"pending","steps":[{"status":"passed","statusDetails":{},"stage":"pending","steps":[{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984346793,"name":"browserContext.newPage","stop":1650984347864}],"attachments":[],"parameters":[],"start":1650984345658,"name":"Before Hooks","stop":1650984347864},{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984347910,"name":"page.goto(https://rahulshettyacademy.com/AutomationPractice/)","stop":1650984353797},{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984353799,"name":"locator.hover(#mousehover)","stop":1650984354384},{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984353801,"name":"expect.toBeVisible","stop":1650984354867},{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984354868,"name":"expect.toHaveText","stop":1650984355162},{"status":"passed","statusDetails":{},"stage":"pending","steps":[{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984357784,"name":"browserContext.close","stop":1650984357854}],"attachments":[],"parameters":[],"start":1650984357162,"name":"After Hooks","stop":1650984357864}],"attachments":[{"name":"video","type":"video/webm","source":"faa7fba1-3d6b-4ca2-a973-51f4bd2fb61b-attachment.webm"},{"name":"trace","type":"application/zip","source":"d439824d-48fc-4328-b2cc-b7f2f72bde82-attachment.ZIP"},{"name":"screenshot","type":"image/png","source":"76acdeb5-4266-4d3c-bcc1-34e33ffab69f-attachment.png"},{"name":"stdout","type":"text/plain","source":"5983f0ba-20c4-4aa3-a9ad-c4417250df1e-attachment.txt"},{"name":"stdout","type":"text/plain","source":"9604978e-e66c-47bf-bf7e-3ec0284e97fd-attachment.txt"},{"name":"stdout","type":"text/plain","source":"be2f02e5-6ece-4ddb-bcfe-906b9f3e5a51-attachment.txt"},{"name":"stdout","type":"text/plain","source":"55ddf975-3b56-4c5b-86d0-15b2094713a8-attachment.txt"}],"parameters":[],"labels":[{"name":"language","value":"JavaScript"},{"name":"framework","value":"Playwright"},{"name":"parentSuite","value":"firefox"},{"name":"suite","value":"04_RS_UI_Tests_Section_7/32_MouseHover.spec.js"}],"links":[],"start":1650984345658,"name":"RS - Playwright Test - RahulShettyAcademy Automation Practice App - Handle Alerts/Popu/Dialog","fullName":"RS - Playwright Test - RahulShettyAcademy Automation Practice App - Handle Alerts/Popu/Dialog","stop":1650984357877}
--------------------------------------------------------------------------------
/allure-results/6001a293-1434-4be5-8cdc-a119cb156613-container.json:
--------------------------------------------------------------------------------
1 | {"uuid":"6001a293-1434-4be5-8cdc-a119cb156613","children":["f6b18479-e3e4-474b-b8f1-6987e0b71eb4"],"befores":[],"afters":[],"name":"04_RS_UI_Tests_Section_7/29_goBack_Forward.spec.js"}
--------------------------------------------------------------------------------
/allure-results/6294aacd-1d49-4ac0-be0d-e5141bec2da3-attachment.txt:
--------------------------------------------------------------------------------
1 | Additional Wait for 2 seconds.
2 |
--------------------------------------------------------------------------------
/allure-results/645c6a4f-606e-4a6c-b588-893f7c30f8bc-attachment.txt:
--------------------------------------------------------------------------------
1 | Additional Wait for 2 seconds.
2 |
--------------------------------------------------------------------------------
/allure-results/694da101-5722-48e7-9895-eacc7dc1a0b6-attachment.txt:
--------------------------------------------------------------------------------
1 | Assertion for TextBox visible
2 |
--------------------------------------------------------------------------------
/allure-results/6fd0eb29-322f-4a13-8ab2-db83cc1ea269-container.json:
--------------------------------------------------------------------------------
1 | {"uuid":"6fd0eb29-322f-4a13-8ab2-db83cc1ea269","children":["ee1e9630-6b4e-4dc0-b48e-dd8f70291ea9","93d86d6f-c18f-46f7-8984-966d6e03e6f5","6001a293-1434-4be5-8cdc-a119cb156613","d80b822d-3c14-4136-a9a8-5bcbbf174ee8","d4b15b92-6d3d-47ee-9e6d-aff98f4a1b62"],"befores":[],"afters":[],"name":"firefox"}
--------------------------------------------------------------------------------
/allure-results/72e9dc81-83e2-49b1-b671-07a6cba70ef2-attachment.webm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/Playwright_JS/253a3370309b6d649bed58ef7948cff1be337349/allure-results/72e9dc81-83e2-49b1-b671-07a6cba70ef2-attachment.webm
--------------------------------------------------------------------------------
/allure-results/75f5d0b8-a7ba-4c63-83d3-b603ad7549b2-attachment.txt:
--------------------------------------------------------------------------------
1 | Additional Wait for 2 seconds.
2 |
--------------------------------------------------------------------------------
/allure-results/76acdeb5-4266-4d3c-bcc1-34e33ffab69f-attachment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/Playwright_JS/253a3370309b6d649bed58ef7948cff1be337349/allure-results/76acdeb5-4266-4d3c-bcc1-34e33ffab69f-attachment.png
--------------------------------------------------------------------------------
/allure-results/7794a463-a29a-4b17-b8aa-ee1e1a67467b-attachment.txt:
--------------------------------------------------------------------------------
1 | Assertion for TextBox hidden
2 |
--------------------------------------------------------------------------------
/allure-results/7b41064a-9d83-4bd7-979f-8da819ed9bd1-attachment.txt:
--------------------------------------------------------------------------------
1 | Additional Wait for 2 seconds.
2 |
--------------------------------------------------------------------------------
/allure-results/7c1f10e6-dab2-4119-bd6f-2ded8f4d2cf4-attachment.ZIP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/Playwright_JS/253a3370309b6d649bed58ef7948cff1be337349/allure-results/7c1f10e6-dab2-4119-bd6f-2ded8f4d2cf4-attachment.ZIP
--------------------------------------------------------------------------------
/allure-results/7e30bdc5-0459-45ee-a8ff-41418d22bb0f-attachment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/Playwright_JS/253a3370309b6d649bed58ef7948cff1be337349/allure-results/7e30bdc5-0459-45ee-a8ff-41418d22bb0f-attachment.png
--------------------------------------------------------------------------------
/allure-results/7e60137e-2c64-4fc6-bbe8-1b8449fed54e-attachment.webm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/Playwright_JS/253a3370309b6d649bed58ef7948cff1be337349/allure-results/7e60137e-2c64-4fc6-bbe8-1b8449fed54e-attachment.webm
--------------------------------------------------------------------------------
/allure-results/836dbe31-1a21-47e2-94fc-c4456d00fda5-result.json:
--------------------------------------------------------------------------------
1 | {"uuid":"836dbe31-1a21-47e2-94fc-c4456d00fda5","historyId":"firefox 04_RS_UI_Tests_Section_7/33_Handle_Frames.spec.js RS - Playwright Test - RahulShettyAcademy Automation Practice App - Handle Frames","status":"passed","statusDetails":{},"stage":"pending","steps":[{"status":"passed","statusDetails":{},"stage":"pending","steps":[{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984346775,"name":"browserContext.newPage","stop":1650984347864}],"attachments":[],"parameters":[],"start":1650984345655,"name":"Before Hooks","stop":1650984347864},{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984347864,"name":"page.goto(https://rahulshettyacademy.com/AutomationPractice/)","stop":1650984353960},{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984353962,"name":"locator.click(#courses-iframe >> control=enter-frame >> li a[href*='lifetime-access']:visible)","stop":1650984356300},{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984356301,"name":"locator.hover(#courses-iframe >> control=enter-frame >> .navigation .dropdown-toggle >> nth=0)","stop":1650984358228},{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984356304,"name":"expect.toContainText","stop":1650984356347},{"status":"passed","statusDetails":{},"stage":"pending","steps":[{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984362801,"name":"browserContext.close","stop":1650984362842}],"attachments":[],"parameters":[],"start":1650984362350,"name":"After Hooks","stop":1650984362847}],"attachments":[{"name":"video","type":"video/webm","source":"7e60137e-2c64-4fc6-bbe8-1b8449fed54e-attachment.webm"},{"name":"trace","type":"application/zip","source":"3bfbac35-c2e2-4615-99c2-b7cba0a3922f-attachment.ZIP"},{"name":"screenshot","type":"image/png","source":"e9225d8b-5e37-4dbd-92c0-d418f426b619-attachment.png"},{"name":"stdout","type":"text/plain","source":"2d3feb83-9bfc-4a4d-b35d-36c7067578df-attachment.txt"},{"name":"stdout","type":"text/plain","source":"bc222910-103b-4866-af25-9330174c886f-attachment.txt"}],"parameters":[],"labels":[{"name":"language","value":"JavaScript"},{"name":"framework","value":"Playwright"},{"name":"parentSuite","value":"firefox"},{"name":"suite","value":"04_RS_UI_Tests_Section_7/33_Handle_Frames.spec.js"}],"links":[],"start":1650984345654,"name":"RS - Playwright Test - RahulShettyAcademy Automation Practice App - Handle Frames","fullName":"RS - Playwright Test - RahulShettyAcademy Automation Practice App - Handle Frames","stop":1650984362853}
--------------------------------------------------------------------------------
/allure-results/8fce553c-868b-4722-ac60-6b6c66ce46bb-attachment.txt:
--------------------------------------------------------------------------------
1 | Additional Wait for 2 seconds.
2 |
--------------------------------------------------------------------------------
/allure-results/93d86d6f-c18f-46f7-8984-966d6e03e6f5-container.json:
--------------------------------------------------------------------------------
1 | {"uuid":"93d86d6f-c18f-46f7-8984-966d6e03e6f5","children":["b21b8f9b-344c-47e5-8b9f-5bd5b3d731cd"],"befores":[],"afters":[],"name":"04_RS_UI_Tests_Section_7/30_Element_VisibleOrHidden.spec.js"}
--------------------------------------------------------------------------------
/allure-results/9604978e-e66c-47bf-bf7e-3ec0284e97fd-attachment.txt:
--------------------------------------------------------------------------------
1 | Assertion for Element visible - Top
2 |
--------------------------------------------------------------------------------
/allure-results/9a5cfbda-5207-43b8-bc75-4983db0e6f3d-attachment.txt:
--------------------------------------------------------------------------------
1 | Go to application: https://www.google.com/
2 |
--------------------------------------------------------------------------------
/allure-results/aac21be1-d88e-4be1-aa67-46b780a50e91-container.json:
--------------------------------------------------------------------------------
1 | {"uuid":"aac21be1-d88e-4be1-aa67-46b780a50e91","children":["6fd0eb29-322f-4a13-8ab2-db83cc1ea269"],"befores":[],"afters":[],"name":"Unnamed"}
--------------------------------------------------------------------------------
/allure-results/b17eb6e3-6c24-4c6f-bb04-1547691af075-attachment.webm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/Playwright_JS/253a3370309b6d649bed58ef7948cff1be337349/allure-results/b17eb6e3-6c24-4c6f-bb04-1547691af075-attachment.webm
--------------------------------------------------------------------------------
/allure-results/b21b8f9b-344c-47e5-8b9f-5bd5b3d731cd-result.json:
--------------------------------------------------------------------------------
1 | {"uuid":"b21b8f9b-344c-47e5-8b9f-5bd5b3d731cd","historyId":"firefox 04_RS_UI_Tests_Section_7/30_Element_VisibleOrHidden.spec.js RS - Playwright Test - RahulShettyAcademy Automation Practice App - Assertion for Element Visible/Hidden","status":"passed","statusDetails":{},"stage":"pending","steps":[{"status":"passed","statusDetails":{},"stage":"pending","steps":[{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984346775,"name":"browserContext.newPage","stop":1650984347842}],"attachments":[],"parameters":[],"start":1650984345647,"name":"Before Hooks","stop":1650984347843},{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984347863,"name":"page.goto(https://rahulshettyacademy.com/AutomationPractice/)","stop":1650984353407},{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984353431,"name":"expect.toBeVisible","stop":1650984353667},{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984353689,"name":"locator.click(#hide-textbox)","stop":1650984354016},{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984355692,"name":"expect.toBeHidden","stop":1650984355732},{"status":"passed","statusDetails":{},"stage":"pending","steps":[{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984358440,"name":"browserContext.close","stop":1650984358505}],"attachments":[],"parameters":[],"start":1650984357734,"name":"After Hooks","stop":1650984358509}],"attachments":[{"name":"video","type":"video/webm","source":"72e9dc81-83e2-49b1-b671-07a6cba70ef2-attachment.webm"},{"name":"trace","type":"application/zip","source":"336a8b5a-5c33-43b0-ba87-dd77b37b5b0d-attachment.ZIP"},{"name":"screenshot","type":"image/png","source":"7e30bdc5-0459-45ee-a8ff-41418d22bb0f-attachment.png"},{"name":"stdout","type":"text/plain","source":"694da101-5722-48e7-9895-eacc7dc1a0b6-attachment.txt"},{"name":"stdout","type":"text/plain","source":"09080717-9e2b-4219-b853-6a8312da2546-attachment.txt"},{"name":"stdout","type":"text/plain","source":"7b41064a-9d83-4bd7-979f-8da819ed9bd1-attachment.txt"},{"name":"stdout","type":"text/plain","source":"7794a463-a29a-4b17-b8aa-ee1e1a67467b-attachment.txt"},{"name":"stdout","type":"text/plain","source":"6294aacd-1d49-4ac0-be0d-e5141bec2da3-attachment.txt"}],"parameters":[],"labels":[{"name":"language","value":"JavaScript"},{"name":"framework","value":"Playwright"},{"name":"parentSuite","value":"firefox"},{"name":"suite","value":"04_RS_UI_Tests_Section_7/30_Element_VisibleOrHidden.spec.js"}],"links":[],"start":1650984345647,"name":"RS - Playwright Test - RahulShettyAcademy Automation Practice App - Assertion for Element Visible/Hidden","fullName":"RS - Playwright Test - RahulShettyAcademy Automation Practice App - Assertion for Element Visible/Hidden","stop":1650984358515}
--------------------------------------------------------------------------------
/allure-results/bb05c060-5ce8-4795-9e57-ea30b11e0f3e-result.json:
--------------------------------------------------------------------------------
1 | {"uuid":"bb05c060-5ce8-4795-9e57-ea30b11e0f3e","historyId":"firefox 04_RS_UI_Tests_Section_7/31_Handle_Alerts_Popup_Dialog.spec.js RS - Playwright Test - RahulShettyAcademy Automation Practice App - Handle Alerts/Popu/Dialog","status":"passed","statusDetails":{},"stage":"pending","steps":[{"status":"passed","statusDetails":{},"stage":"pending","steps":[{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984346792,"name":"browserContext.newPage","stop":1650984347864}],"attachments":[],"parameters":[],"start":1650984345638,"name":"Before Hooks","stop":1650984347864},{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984347864,"name":"page.goto(https://rahulshettyacademy.com/AutomationPractice/)","stop":1650984353716},{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984353729,"name":"locator.click(#confirmbtn)","stop":1650984354705},{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984354608,"name":"dialog.accept","stop":1650984354684},{"status":"passed","statusDetails":{},"stage":"pending","steps":[{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984356735,"name":"browserContext.close","stop":1650984357023}],"attachments":[],"parameters":[],"start":1650984355726,"name":"After Hooks","stop":1650984357046}],"attachments":[{"name":"video","type":"video/webm","source":"1056a6b8-6d23-4270-876f-cdd50ae9e10c-attachment.webm"},{"name":"trace","type":"application/zip","source":"0dc9776c-66b9-4ce5-9796-e4b72a40f391-attachment.ZIP"},{"name":"screenshot","type":"image/png","source":"ed5c9ee9-a2b8-46c0-b14c-5392485457f3-attachment.png"},{"name":"stdout","type":"text/plain","source":"f5d44336-c3ed-47a2-bb8e-2f4de5bde174-attachment.txt"},{"name":"stdout","type":"text/plain","source":"8fce553c-868b-4722-ac60-6b6c66ce46bb-attachment.txt"}],"parameters":[],"labels":[{"name":"language","value":"JavaScript"},{"name":"framework","value":"Playwright"},{"name":"parentSuite","value":"firefox"},{"name":"suite","value":"04_RS_UI_Tests_Section_7/31_Handle_Alerts_Popup_Dialog.spec.js"}],"links":[],"start":1650984345638,"name":"RS - Playwright Test - RahulShettyAcademy Automation Practice App - Handle Alerts/Popu/Dialog","fullName":"RS - Playwright Test - RahulShettyAcademy Automation Practice App - Handle Alerts/Popu/Dialog","stop":1650984357054}
--------------------------------------------------------------------------------
/allure-results/bc222910-103b-4866-af25-9330174c886f-attachment.txt:
--------------------------------------------------------------------------------
1 | Additional Wait for 6 seconds.
2 |
--------------------------------------------------------------------------------
/allure-results/be2f02e5-6ece-4ddb-bcfe-906b9f3e5a51-attachment.txt:
--------------------------------------------------------------------------------
1 | Assertion for Element text - Top
2 |
--------------------------------------------------------------------------------
/allure-results/c9862c3b-52eb-4407-a7a9-50dc151fa9ee-attachment.txt:
--------------------------------------------------------------------------------
1 | Additional Wait for 2 seconds.
2 |
--------------------------------------------------------------------------------
/allure-results/d439824d-48fc-4328-b2cc-b7f2f72bde82-attachment.ZIP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/Playwright_JS/253a3370309b6d649bed58ef7948cff1be337349/allure-results/d439824d-48fc-4328-b2cc-b7f2f72bde82-attachment.ZIP
--------------------------------------------------------------------------------
/allure-results/d4b15b92-6d3d-47ee-9e6d-aff98f4a1b62-container.json:
--------------------------------------------------------------------------------
1 | {"uuid":"d4b15b92-6d3d-47ee-9e6d-aff98f4a1b62","children":["5dcf7397-5cca-4e14-9c02-0e0a9b98d88b"],"befores":[],"afters":[],"name":"04_RS_UI_Tests_Section_7/32_MouseHover.spec.js"}
--------------------------------------------------------------------------------
/allure-results/d6834311-42df-491b-8412-a5d98bba2d2b-attachment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/Playwright_JS/253a3370309b6d649bed58ef7948cff1be337349/allure-results/d6834311-42df-491b-8412-a5d98bba2d2b-attachment.png
--------------------------------------------------------------------------------
/allure-results/d80b822d-3c14-4136-a9a8-5bcbbf174ee8-container.json:
--------------------------------------------------------------------------------
1 | {"uuid":"d80b822d-3c14-4136-a9a8-5bcbbf174ee8","children":["836dbe31-1a21-47e2-94fc-c4456d00fda5"],"befores":[],"afters":[],"name":"04_RS_UI_Tests_Section_7/33_Handle_Frames.spec.js"}
--------------------------------------------------------------------------------
/allure-results/e45a4ede-1818-4eaa-a1db-351363647c08-attachment.txt:
--------------------------------------------------------------------------------
1 | Additional Wait for 2 seconds.
2 |
--------------------------------------------------------------------------------
/allure-results/e9225d8b-5e37-4dbd-92c0-d418f426b619-attachment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/Playwright_JS/253a3370309b6d649bed58ef7948cff1be337349/allure-results/e9225d8b-5e37-4dbd-92c0-d418f426b619-attachment.png
--------------------------------------------------------------------------------
/allure-results/ed5c9ee9-a2b8-46c0-b14c-5392485457f3-attachment.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/Playwright_JS/253a3370309b6d649bed58ef7948cff1be337349/allure-results/ed5c9ee9-a2b8-46c0-b14c-5392485457f3-attachment.png
--------------------------------------------------------------------------------
/allure-results/ee1e9630-6b4e-4dc0-b48e-dd8f70291ea9-container.json:
--------------------------------------------------------------------------------
1 | {"uuid":"ee1e9630-6b4e-4dc0-b48e-dd8f70291ea9","children":["bb05c060-5ce8-4795-9e57-ea30b11e0f3e"],"befores":[],"afters":[],"name":"04_RS_UI_Tests_Section_7/31_Handle_Alerts_Popup_Dialog.spec.js"}
--------------------------------------------------------------------------------
/allure-results/f5d44336-c3ed-47a2-bb8e-2f4de5bde174-attachment.txt:
--------------------------------------------------------------------------------
1 | Clicking on: Confirm button
2 |
--------------------------------------------------------------------------------
/allure-results/f6b18479-e3e4-474b-b8f1-6987e0b71eb4-result.json:
--------------------------------------------------------------------------------
1 | {"uuid":"f6b18479-e3e4-474b-b8f1-6987e0b71eb4","historyId":"firefox 04_RS_UI_Tests_Section_7/29_goBack_Forward.spec.js RS - Playwright Test - RahulShettyAcademy Automation Practice App - Assertion with Go Back and Forward","status":"passed","statusDetails":{},"stage":"pending","steps":[{"status":"passed","statusDetails":{},"stage":"pending","steps":[{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984346810,"name":"browserContext.newPage","stop":1650984347854}],"attachments":[],"parameters":[],"start":1650984345648,"name":"Before Hooks","stop":1650984347854},{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984347863,"name":"page.goto(https://rahulshettyacademy.com/AutomationPractice/)","stop":1650984349917},{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984349872,"name":"page.goto(https://www.google.com/)","stop":1650984352550},{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984351882,"name":"expect.toHaveTitle","stop":1650984352518},{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984352519,"name":"page.goBack","stop":1650984355773},{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984357778,"name":"expect.toHaveTitle","stop":1650984357813},{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984357814,"name":"page.goForward","stop":1650984358357},{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984360359,"name":"expect.toHaveTitle","stop":1650984360372},{"status":"passed","statusDetails":{},"stage":"pending","steps":[{"status":"passed","statusDetails":{},"stage":"pending","steps":[],"attachments":[],"parameters":[],"start":1650984362640,"name":"browserContext.close","stop":1650984362730}],"attachments":[],"parameters":[],"start":1650984362372,"name":"After Hooks","stop":1650984362735}],"attachments":[{"name":"video","type":"video/webm","source":"b17eb6e3-6c24-4c6f-bb04-1547691af075-attachment.webm"},{"name":"trace","type":"application/zip","source":"7c1f10e6-dab2-4119-bd6f-2ded8f4d2cf4-attachment.ZIP"},{"name":"screenshot","type":"image/png","source":"d6834311-42df-491b-8412-a5d98bba2d2b-attachment.png"},{"name":"stdout","type":"text/plain","source":"1d9e1581-90cd-49c5-bb87-24401eb3da01-attachment.txt"},{"name":"stdout","type":"text/plain","source":"75f5d0b8-a7ba-4c63-83d3-b603ad7549b2-attachment.txt"},{"name":"stdout","type":"text/plain","source":"9a5cfbda-5207-43b8-bc75-4983db0e6f3d-attachment.txt"},{"name":"stdout","type":"text/plain","source":"4e9029a5-14a6-43d2-87f9-f5981c0c4865-attachment.txt"},{"name":"stdout","type":"text/plain","source":"c9862c3b-52eb-4407-a7a9-50dc151fa9ee-attachment.txt"},{"name":"stdout","type":"text/plain","source":"645c6a4f-606e-4a6c-b588-893f7c30f8bc-attachment.txt"},{"name":"stdout","type":"text/plain","source":"e45a4ede-1818-4eaa-a1db-351363647c08-attachment.txt"}],"parameters":[],"labels":[{"name":"language","value":"JavaScript"},{"name":"framework","value":"Playwright"},{"name":"parentSuite","value":"firefox"},{"name":"suite","value":"04_RS_UI_Tests_Section_7/29_goBack_Forward.spec.js"}],"links":[],"start":1650984345648,"name":"RS - Playwright Test - RahulShettyAcademy Automation Practice App - Assertion with Go Back and Forward","fullName":"RS - Playwright Test - RahulShettyAcademy Automation Practice App - Assertion with Go Back and Forward","stop":1650984362742}
--------------------------------------------------------------------------------
/allure-results/faa7fba1-3d6b-4ca2-a973-51f4bd2fb61b-attachment.webm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/Playwright_JS/253a3370309b6d649bed58ef7948cff1be337349/allure-results/faa7fba1-3d6b-4ca2-a973-51f4bd2fb61b-attachment.webm
--------------------------------------------------------------------------------
/pageObjects/CartPage.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | class CartPage{
14 |
15 | constructor(page){
16 | this.page = page;
17 | this.productName = page.locator("div[class='cartSection'] h3");
18 | this.btn_checkout = page.locator("text=Checkout");
19 | }//constructor
20 |
21 | getProductName(){
22 | this.productName.waitFor();
23 | return this.productName;
24 | }
25 |
26 | getProductNameText(){
27 | this.productName.waitFor();
28 | return this.productName.textContent();
29 | }
30 |
31 |
32 | async goToCheckoutPage(){
33 | console.log('Clicking on Checkout button')
34 | await this.btn_checkout.click();
35 | }
36 |
37 | }//class
38 |
39 | module.exports = {CartPage};
--------------------------------------------------------------------------------
/pageObjects/CheckoutPage.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | class CheckoutPage{
14 |
15 | constructor(page){
16 | this.page = page;
17 | this.txtBox_email = page.locator(".user__name [type='text']").nth(0);
18 | this.btn_placeOrder = page.locator('.action__submit');
19 | this.drpdwn_selectCountry = page.locator("[placeholder='Select Country']");
20 | this.options_country = page.locator('.ta-results');
21 |
22 | }//constructor
23 |
24 | get_TxtBox_Email(){
25 | this.txtBox_email.waitFor();
26 | return this.txtBox_email;
27 | }
28 |
29 | async placeOrder(){
30 | console.log('Clicking on Place Order button')
31 | await this.btn_placeOrder.click();
32 | }
33 |
34 | async searchCountryAndSelect(inputToTextBox,country_ToSearch){
35 | console.log("Filling "+inputToTextBox+" in Select Country slowly")
36 | //{delay:100} -> This will help to type Ind slowly
37 | this.drpdwn_selectCountry.type(inputToTextBox, { delay:1000 } );
38 |
39 | console.log("Waiting for Countries to load after search for '"+inputToTextBox+"'");
40 | await this.options_country.waitFor();
41 |
42 | const countriesCount = this.options_country.locator('button').count();
43 |
44 | for(let index=0;index To remove the spaces from country name
49 | if(countryName.trim() === country_ToSearch){
50 | console.log('Clicking on '+country_ToSearch+'.')
51 | await this.options_country.locator('button').nth(index).click();
52 | break;
53 | }//if
54 | }//for
55 | }//searchProduct_And_AddToCart()
56 | }//class
57 |
58 | module.exports = {CheckoutPage};
--------------------------------------------------------------------------------
/pageObjects/DashboardPage.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | class DashboardPage{
14 |
15 | constructor(page){
16 | this.page = page;
17 | this.msg_login_success = page.locator("div[aria-label='Login Successfully']");
18 | this.msg_productAdded_ToCart = page.locator("div[aria-label='Product Added To Cart']");
19 |
20 | this.products = page.locator('.card-body');
21 | this.tab_cart = page.locator("[routerlink*=cart]");
22 | this.tab_home = page.locator("[routerlink='/dashboard/']");
23 | }//constructor
24 |
25 | async searchProduct_And_AddToCart(product_ToAdd){
26 | const productsCount = await this.products.count();
27 | console.log("productsCount: " + productsCount);
28 |
29 | for(let index=0;index < productsCount;index++){
30 |
31 | // Searching for b tag inside
32 | // Scope for search is limited; not search in the whole page
33 | // const products = page.locator('.card-body');
34 | const productName = await this.products.nth(index).locator('b').textContent();
35 | console.log("productName: "+productName);
36 |
37 | if(productName === product_ToAdd){
38 | console.log('Adding '+productName+' to the Cart.')
39 | await this.products.nth(index).locator('text= Add To Cart').click();
40 | break;
41 | }//if
42 | }//for
43 | }//searchProduct_And_AddToCart()
44 |
45 |
46 | async navigateToCart(){
47 | await this.tab_cart.click();
48 | await this.page.waitForLoadState('networkidle');
49 | }
50 |
51 | getMsg_LoginSuccess(){
52 | this.tab_home.click();
53 | this.msg_login_success.waitFor();
54 | return this.msg_login_success;
55 | }
56 |
57 | getMsg_ProductAdded_ToCart(){
58 | this.msg_productAdded_ToCart.waitFor();
59 | return this.msg_productAdded_ToCart;
60 | }
61 | }//class
62 |
63 | module.exports = {DashboardPage};
--------------------------------------------------------------------------------
/pageObjects/LoginPage.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | class LoginPage{
14 |
15 | constructor(page){
16 | this.page = page;
17 | this.txtBox_username = page.locator('#userEmail');
18 | this.txtBox_password = page.locator('#userPassword');
19 | this.btn_Login = page.locator('#login');
20 | this.msg_incorrect_username_password = page.locator('[style*=block]');
21 | }//constructor
22 |
23 |
24 |
25 | getMsg_Incorrect_username_password(){
26 | //this.tab_home.click();
27 | this.msg_incorrect_username_password.waitFor();
28 | return this.msg_incorrect_username_password;
29 | }
30 |
31 | async goToApplication(){
32 | const applicationURL = "https://www.rahulshettyacademy.com/client/";
33 | console.log('Go to application: ' + applicationURL);
34 | await this.page.goto(applicationURL);
35 | }//goToApplication()
36 |
37 | async loginToApplication(username,password){
38 | console.log('Filling ' + username + ' in Username textBox');
39 | await this.txtBox_username.fill(username);
40 |
41 | console.log('Filling ' + password + ' in Password textBox');
42 | await this.txtBox_password.fill(password);
43 |
44 | console.log('Clicking on Login button');
45 | await this.btn_Login.click();
46 |
47 | await this.page.waitForLoadState('networkidle');
48 | }//loginToApplication()
49 |
50 | }//class
51 |
52 | module.exports = {LoginPage};
--------------------------------------------------------------------------------
/pageObjects/POM_Manager.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | const {LoginPage} = require('./LoginPage');
14 | const {DashboardPage} = require('./DashboardPage');
15 | const {CartPage} = require('./CartPage');
16 | const {CheckoutPage} = require('./CheckoutPage');
17 |
18 | class POM_Manager{
19 |
20 | constructor(page){
21 | this.page=page;
22 | this.loginPage = new LoginPage(this.page);
23 | this.dashboardPage = new DashboardPage(this.page);
24 | this.cartPage = new CartPage(this.page);
25 | this.checkoutPage = new CheckoutPage(this.page);
26 | }//constructor
27 |
28 | getLoginPage(){
29 | return this.loginPage;
30 | }
31 | getDashboardPage(){
32 | return this.dashboardPage;
33 | }
34 | getCartPage(){
35 | return this.cartPage;
36 | }
37 | getCheckoutPage(){
38 | return this.checkoutPage;
39 | }
40 |
41 |
42 |
43 | }//class
44 |
45 | module.exports = {POM_Manager};
--------------------------------------------------------------------------------
/playwright.config-custom.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | // @ts-check
14 | const { devices } = require('@playwright/test');
15 |
16 | /**
17 | * Read environment variables from file.
18 | * https://github.com/motdotla/dotenv
19 | */
20 | // require('dotenv').config();
21 |
22 |
23 | /**
24 | * @see https://playwright.dev/docs/test-configuration
25 | * @type {import('@playwright/test').PlaywrightTestConfig}
26 | */
27 | const config = {
28 | /* This is the location where all test cases are present. */
29 | testDir: './tests',
30 | /* Maximum time one test can run for. */
31 | timeout: 20 * 1000,
32 | expect: {
33 | /**
34 | * Maximum time expect() should wait for the condition to be met.
35 | * For example in `await expect(locator).toHaveText();`
36 | */
37 | timeout: 5000
38 | },
39 | /* Fail the build on CI if you accidentally left test.only in the source code. */
40 | forbidOnly: !!process.env.CI,
41 | /* Retry on CI only */
42 | retries: process.env.CI ? 2 : 0,
43 | /* Opt out of parallel tests on CI. */
44 | workers: process.env.CI ? 1 : undefined,
45 | /* Reporter to use. See https://playwright.dev/docs/test-reporters */
46 | reporter: 'html',
47 | /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
48 | use: {
49 | /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
50 | actionTimeout: 0,
51 | /* Base URL to use in actions like `await page.goto('/')`. */
52 | // baseURL: 'http://localhost:3000',
53 |
54 | /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
55 | //trace: 'on-first-retry',
56 | trace: 'on',
57 | //trace: 'retain-on-failure',
58 |
59 | /* This can change the mode of Execution - Headless/Headed*/
60 | //headless:true // Headless
61 | //headless:false // Headed
62 |
63 | /* This is for the screenshots (will be attached in the Reports) */
64 | screenshot: 'on' // For every step
65 | // screenshot: 'off'
66 | // screenshot: 'only-on-failure'
67 |
68 | },
69 |
70 | /* Configure projects for major browsers */
71 | projects: [
72 | {
73 | name: 'chromium',
74 | use: {
75 | ...devices['Desktop Chrome'],
76 | },
77 | },
78 |
79 | // {
80 | // name: 'firefox',
81 | // use: {
82 | // ...devices['Desktop Firefox'],
83 | // },
84 | // },
85 |
86 | // {
87 | // name: 'webkit',
88 | // use: {
89 | // ...devices['Desktop Safari'],
90 | // },
91 | // },
92 |
93 | /* Test against mobile viewports. */
94 | // {
95 | // name: 'Mobile Chrome',
96 | // use: {
97 | // ...devices['Pixel 5'],
98 | // },
99 | // },
100 | // {
101 | // name: 'Mobile Safari',
102 | // use: {
103 | // ...devices['iPhone 12'],
104 | // },
105 | // },
106 |
107 | /* Test against branded browsers. */
108 | /* Actual Edge Browser installed*/
109 | // {
110 | // name: 'Microsoft Edge',
111 | // use: {
112 | // channel: 'msedge',
113 | // },
114 | // },
115 | /* Actual Chrome Browser installed*/
116 | // {
117 | // name: 'Google Chrome',
118 | // use: {
119 | // channel: 'chrome',
120 | // },
121 | // },
122 | ],
123 |
124 | /* Folder for test artifacts such as screenshots, videos, traces, etc. */
125 | // outputDir: 'test-results/',
126 |
127 | /* Run your local dev server before starting the tests */
128 | // webServer: {
129 | // command: 'npm run start',
130 | // port: 3000,
131 | // },
132 | };
133 |
134 | module.exports = config;
135 |
--------------------------------------------------------------------------------
/playwright.config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | // @ts-check
14 | const { devices } = require('@playwright/test');
15 |
16 | /**
17 | * Read environment variables from file.
18 | * https://github.com/motdotla/dotenv
19 | */
20 | // require('dotenv').config();
21 |
22 |
23 | /**
24 | * @see https://playwright.dev/docs/test-configuration
25 | * @type {import('@playwright/test').PlaywrightTestConfig}
26 | */
27 | const config = {
28 |
29 | /* This is the location where all test cases are present. */
30 | testDir: './tests',
31 |
32 | /* Maximum time one test can run for. */
33 | timeout: 20 * 1000,
34 | expect: {
35 | /**
36 | * Maximum time expect() should wait for the condition to be met.
37 | * For example in `await expect(locator).toHaveText();`
38 | */
39 | timeout: 5000
40 | },
41 | /* Fail the build on CI if you accidentally left test.only in the source code. */
42 | forbidOnly: !!process.env.CI,
43 |
44 | /* Retry on CI only */
45 | //retries: process.env.CI ? 2 : 0,
46 | retries: 1, //Failed test case will retry for 1 time
47 |
48 |
49 | /* Opt out of parallel tests on CI. */
50 | //workers: process.env.CI ? 1 : undefined,
51 | /* This will start 10 instances will start parallely of any browser */
52 | workers: 7, // Default is 5
53 |
54 |
55 | /* Reporter to use. See https://playwright.dev/docs/test-reporters */
56 | reporter: 'html',
57 | /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
58 | use: {
59 |
60 | /* This is for handling SSL certificates */
61 | // ignoreHTTPSErrors:true,
62 |
63 | /* This is to set the permissions */
64 | // geolocation -> For Location
65 | // permissions:['geolocation'],
66 |
67 | /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
68 | actionTimeout: 0,
69 | /* Base URL to use in actions like `await page.goto('/')`. */
70 | // baseURL: 'http://localhost:3000',
71 |
72 | /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
73 | //trace: 'on-first-retry',
74 | //trace: 'on',
75 | trace: 'retain-on-failure',
76 | //trace:'on-first-retry',
77 | //trace:'off'
78 |
79 | /* This can change the mode of Execution - Headless/Headed*/
80 | //headless:true // Headless
81 | //headless:false // Headed
82 |
83 | /* This is for the screenshots (will be attached in the Reports) */
84 | //screenshot: 'on', // For every step
85 | // screenshot: 'off',
86 | screenshot: 'only-on-failure',
87 |
88 | /* This is for recording the videos */
89 | //video:'off', // Do not record video.
90 | //video:'on', //Record video for each test.
91 | //video:'on-first-retry', // Record video only when retrying a test for the first time.
92 | video:'retain-on-failure', //Record video for each test, but remove all videos from successful test runs.
93 | //video:'retry-with-video',
94 |
95 | },
96 |
97 | /* Configure projects for major browsers */
98 | projects: [
99 | {
100 | name: 'chromium',
101 | use: {
102 | ...devices['Desktop Chrome'],
103 | },
104 | },
105 |
106 | // {
107 | // name: 'firefox',
108 | // use: {
109 | // ...devices['Desktop Firefox'],
110 | // },
111 | // },
112 |
113 | // {
114 | // name: 'webkit',
115 | // use: {
116 | // ...devices['Desktop Safari'],
117 | // },
118 | // },
119 |
120 | /* Test against mobile viewports. */
121 | // {
122 | // name: 'Mobile Chrome',
123 | // use: {
124 | // ...devices['Pixel 5'],
125 | // },
126 | // },
127 | // {
128 | // name: 'Mobile Safari',
129 | // use: {
130 | // ...devices['iPhone 12'],
131 | // },
132 | // },
133 |
134 | /* Test against branded browsers. */
135 | /* Actual Edge Browser installed*/
136 | // {
137 | // name: 'Microsoft Edge',
138 | // use: {
139 | // channel: 'msedge',
140 | // },
141 | // },
142 | // /* Actual Chrome Browser installed*/
143 | // {
144 | // name: 'Google Chrome',
145 | // use: {
146 | // channel: 'chrome',
147 | // },
148 | // },
149 | ],
150 |
151 | /* Folder for test artifacts such as screenshots, videos, traces, etc. */
152 | // outputDir: 'test-results/',
153 |
154 | /* Run your local dev server before starting the tests */
155 | // webServer: {
156 | // command: 'npm run start',
157 | // port: 3000,
158 | // },
159 | };
160 |
161 | module.exports = config;
162 |
--------------------------------------------------------------------------------
/screenshots/Screenshot_Element.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/Playwright_JS/253a3370309b6d649bed58ef7948cff1be337349/screenshots/Screenshot_Element.png
--------------------------------------------------------------------------------
/screenshots/Screenshot_FullPage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/Playwright_JS/253a3370309b6d649bed58ef7948cff1be337349/screenshots/Screenshot_FullPage.png
--------------------------------------------------------------------------------
/screenshots/Screenshot_VisibleScreen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/Playwright_JS/253a3370309b6d649bed58ef7948cff1be337349/screenshots/Screenshot_VisibleScreen.png
--------------------------------------------------------------------------------
/state.json:
--------------------------------------------------------------------------------
1 | {
2 | "cookies": [],
3 | "origins": [
4 | {
5 | "origin": "https://www.rahulshettyacademy.com",
6 | "localStorage": [
7 | {
8 | "name": "token",
9 | "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MjY1NTFlYmUyNmI3ZTFhMTBlOGFjYmMiLCJ1c2VyRW1haWwiOiJ0ZXN0dG1haWw5NUBnbWFpbC5jb20iLCJ1c2VyTW9iaWxlIjo4OTUwODExNjQ0LCJ1c2VyUm9sZSI6ImN1c3RvbWVyIiwiaWF0IjoxNjUxMTYyODE5LCJleHAiOjE2ODI3MjA0MTl9.9oHpUMaE2duXwqpmbDPPp0auYhQUNpRoumhFPgTkz84"
10 | }
11 | ]
12 | }
13 | ]
14 | }
--------------------------------------------------------------------------------
/testData/credentials_login.json:
--------------------------------------------------------------------------------
1 | {
2 | "valid_username_1" : "testtmail95@gmail.com",
3 | "valid_password_1" : "HiRahul@123"
4 | }
--------------------------------------------------------------------------------
/testData/credentials_login_multipleDataSet.json:
--------------------------------------------------------------------------------
1 | [{
2 | "username" : "First@gmail.com",
3 | "password" : "First@1"
4 | },
5 | {
6 | "username" : "Second@gmail.com",
7 | "password" : "Second@2"
8 | },
9 | {
10 | "username" : "Third@gmail.com",
11 | "password" : "Third@3"
12 | }]
--------------------------------------------------------------------------------
/tests/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/Playwright_JS/253a3370309b6d649bed58ef7948cff1be337349/tests/.DS_Store
--------------------------------------------------------------------------------
/tests/Section_02_RS_UI_Tests/01_NavigateToApplication.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 | const {test} = require('@playwright/test');
11 |
12 | // test() -> Function (takes 1st argument as Test case name and 2nd as Anonymous function())
13 | // {browser} -> Fixture (Available for all the tests)
14 | // test('My First Playwright Test', async function(){
15 | test('Section_02_RS_UI_Tests - My First Playwright Test - 01_NavigateToApplication, Direct use Fixture: Browser', async ({browser} )=> {
16 |
17 | // Step-1: Open Browser
18 | // Set the Browser context
19 | // newContext()
20 | // -> This will help to create a fresh Browser instance
21 | // -> This can inject Cookies in the Browser
22 | // -> This can open the application with proxy
23 | // -> We can set the capabilities
24 | const context = await browser.newContext(); // ----------------------------------- > (A)
25 |
26 | // newPage() -> This will be the page where automation tests will execute
27 | const page = await context.newPage(); // ----------------------------------- > (B)
28 |
29 | // What Playwright team has done
30 | // If you do not want to set any context (Cookies/Proxy/etc.), then, it will be done automatically
31 | // We do not need to write anything, just import page fixture
32 |
33 | //Step-2: Go to the application
34 | await page.goto("https://www.rahulshettyacademy.com/loginpagePractise/");
35 |
36 | });
37 | // {page} -> Fixture (Available for all the tests)
38 | //only -> Only this test case will run
39 | //test.only('RS - My second Playwright Test - No Browser Context, Direct use Fixture: page', async ({page} )=> {
40 |
41 | test('Section_02_RS_UI_Tests - My second Playwright Test - No Browser Context, Direct use Fixture: page', async ({page} )=> {
42 |
43 | //Step-1: Go to the application
44 | // await page.goto("https://www.rahulshettyacademy.com/loginpagePractise/");
45 | await page.goto("https://www.google.com/");
46 | });
47 |
--------------------------------------------------------------------------------
/tests/Section_02_RS_UI_Tests/02_Assert_Title.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 |
14 | test('Section_02_RS_UI_Tests - Assert the Page Title', async ({page} )=> {
15 |
16 | // Go to the application
17 | await page.goto("https://www.google.com/");
18 |
19 | // Get the Title and Print
20 | console.log(await page.title());
21 |
22 | // Assert the Page Title
23 | await expect(page).toHaveTitle('Google');
24 |
25 | });
26 |
--------------------------------------------------------------------------------
/tests/Section_02_RS_UI_Tests/03_WaitAndAssertTitle.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 |
14 | test('Section_02_RS_UI_Tests - Wait and Assert the Page Title', async ({page} )=> {
15 |
16 | // Go to the application
17 | await page.goto("https://www.google.com/");
18 |
19 | // Get the Title and Print
20 | console.log(await page.title());
21 |
22 | //await delay(5000); //ReferenceError: delay is not defined
23 | await new Promise(resolve => setTimeout(resolve, 5000)); // 5 sec
24 |
25 | // Assert the Page Title
26 | await expect(page).toHaveTitle('Google');
27 |
28 | });
29 |
30 | test('Section_02_RS_UI_Tests - Intentionally Failing - Wait and Assert the Page Title', async ({page} )=> {
31 |
32 | // Go to the application
33 | await page.goto("https://www.google.com/");
34 |
35 | // Get the Title and Print
36 | console.log(await page.title());
37 |
38 | //await delay(5000); //ReferenceError: delay is not defined
39 | await new Promise(resolve => setTimeout(resolve, 2000)); // 2 sec
40 |
41 | // Assert the Page Title
42 | await expect(page).toHaveTitle('Google1');
43 |
44 | });
45 |
--------------------------------------------------------------------------------
/tests/Section_03_RS_UI_Tests/04_Type_And_Click.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 |
14 | test('Section_03_RS_UI_Tests - Fill value in TextBox using type() and Click on Button', async ({page} )=> {
15 |
16 | // Go to the application
17 | await page.goto("https://www.rahulshettyacademy.com/loginpagePractise/");
18 |
19 | // Get the Title and Print
20 | console.log(await page.title());
21 |
22 | // Assert the Page Title
23 | await expect(page).toHaveTitle('LoginPage Practise | Rahul Shetty Academy');
24 |
25 | //Playwright will look for the element having CSS selector '#username' and once
26 | // it finds the element, then, it will fill 'rahulshetty'
27 | //await page.locator('#username').type('rahulshettyacademy');
28 | await page.locator('#username').type('rahulshetty');
29 |
30 | await page.locator('#password').type('learning');
31 |
32 | console.log('Click on Sign In button');
33 | await page.locator('#signInBtn').click();
34 |
35 | //await delay(5000); //ReferenceError: delay is not defined
36 | await new Promise(resolve => setTimeout(resolve, 5000)); // 5 sec
37 |
38 | });
39 |
--------------------------------------------------------------------------------
/tests/Section_03_RS_UI_Tests/05_Assert_ExtractTextOfElement.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 |
14 | test('Section_03_RS_UI_Tests - Extract the text of Element and Assert', async ({page} )=> {
15 |
16 | // Go to the application
17 | await page.goto("https://www.rahulshettyacademy.com/loginpagePractise/");
18 |
19 | // Get the Title and Print
20 | console.log(await page.title());
21 |
22 | // Assert the Page Title
23 | await expect(page).toHaveTitle('LoginPage Practise | Rahul Shetty Academy');
24 |
25 | //Playwright will look for the element having CSS selector '#username' and once
26 | // it finds the element, then, it will fill 'rahulshetty'
27 | //await page.locator('#username').type('rahulshettyacademy');
28 | await page.locator('#username').type('rahulshetty');
29 |
30 | await page.locator('#password').type('learning');
31 |
32 | console.log('Click on Sign In button');
33 | await page.locator('#signInBtn').click();
34 |
35 | console.log('Extract the element text')
36 | //[style*=block] -> This is the CSS Selector of Error message (Incorrect username/password.)
37 | console.log(await page.locator('[style*=block]').textContent());
38 |
39 | console.log('Assertion for Error message(Incorrect username/password.)')
40 | await expect(page.locator('[style*=block]')).toHaveText('Incorrect username/password.');
41 | await expect(page.locator('[style*=block]')).toContainText('Incorrect');
42 |
43 | //await delay(5000); //ReferenceError: delay is not defined
44 | await new Promise(resolve => setTimeout(resolve, 5000)); // 5 sec
45 |
46 | });
47 |
--------------------------------------------------------------------------------
/tests/Section_03_RS_UI_Tests/06_Optimized.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 |
14 | test('Section_03_RS_UI_Tests - Code optimized', async ({page} )=> {
15 |
16 | const applicationURL = "https://www.rahulshettyacademy.com/loginpagePractise/";
17 |
18 | const expectedApplicationTitle = "LoginPage Practise | Rahul Shetty Academy";
19 |
20 | const txtBox_username = page.locator('#username');
21 | const txtBox_password = page.locator('#password');
22 | const btn_SignIn = page.locator('#signInBtn');
23 | const msg_error_incorrect_credentials = page.locator('[style*=block]');
24 |
25 | // Go to the application
26 | await page.goto(applicationURL);
27 |
28 | // Get the Title and Print
29 | console.log(await page.title());
30 |
31 | // Assert the Page Title
32 | await expect(page).toHaveTitle(expectedApplicationTitle);
33 |
34 | //Playwright will look for the element having CSS selector '#username' and once
35 | // it finds the element, then, it will fill 'rahulshetty'
36 | //await page.locator('#username').type('rahulshettyacademy');
37 | await txtBox_username.type('rahulshetty');
38 |
39 | await txtBox_password.type('learning');
40 |
41 | console.log('Click on Sign In button');
42 | await btn_SignIn.click();
43 |
44 | console.log('Extract the element text')
45 | //[style*=block] -> This is the CSS Selector of Error message (Incorrect username/password.)
46 | console.log(await msg_error_incorrect_credentials.textContent());
47 |
48 | console.log('Assertion for Error message(Incorrect username/password.)')
49 | await expect(msg_error_incorrect_credentials).toHaveText('Incorrect username/password.');
50 | await expect(msg_error_incorrect_credentials).toContainText('Incorrect');
51 |
52 | await new Promise(resolve => setTimeout(resolve, 5000)); // 5 sec
53 |
54 | });
55 |
--------------------------------------------------------------------------------
/tests/Section_03_RS_UI_Tests/07_Fill_And_SignIn.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 |
14 | test('Section_03_RS_UI_Tests - fill() method usage', async ({page} )=> {
15 |
16 | const applicationURL = "https://www.rahulshettyacademy.com/loginpagePractise/";
17 |
18 | const expectedApplicationTitle = "LoginPage Practise | Rahul Shetty Academy";
19 |
20 | const txtBox_username = page.locator('#username');
21 | const txtBox_password = page.locator('#password');
22 | const btn_SignIn = page.locator('#signInBtn');
23 | const msg_error_incorrect_credentials = page.locator('[style*=block]');
24 |
25 | // Go to the application
26 | await page.goto(applicationURL);
27 |
28 | // Get the Title and Print
29 | console.log(await page.title());
30 |
31 | // Assert the Page Title
32 | await expect(page).toHaveTitle(expectedApplicationTitle);
33 |
34 | //Playwright will look for the element having CSS selector '#username' and once
35 | // it finds the element, then, it will fill 'rahulshetty'
36 | //await page.locator('#username').type('rahulshettyacademy');
37 | await txtBox_username.type('rahulshetty');
38 |
39 | await txtBox_password.type('learning');
40 |
41 | console.log('Click on Sign In button');
42 | await btn_SignIn.click();
43 |
44 | console.log('Extract the element text');
45 | //[style*=block] -> This is the CSS Selector of Error message (Incorrect username/password.)
46 | console.log(await msg_error_incorrect_credentials.textContent());
47 |
48 | console.log('Assertion for Error message(Incorrect username/password.)');
49 | await expect(msg_error_incorrect_credentials).toHaveText('Incorrect username/password.');
50 | await expect(msg_error_incorrect_credentials).toContainText('Incorrect');
51 |
52 | await new Promise(resolve => setTimeout(resolve, 2000)); // 2 sec
53 |
54 | //type() -> This method will not clear the textbox; will fill the value in the textBox directly
55 | await txtBox_username.type('abcdefghi');
56 |
57 | await new Promise(resolve => setTimeout(resolve, 2000)); // 2 sec
58 |
59 | //fill() -> This method will first clear the textbox. Then, will fill the value in the textBox
60 | await txtBox_username.fill('rahulshettyacademy');
61 |
62 | await new Promise(resolve => setTimeout(resolve, 3000)); // 2 sec
63 |
64 | await btn_SignIn.click();
65 |
66 | await new Promise(resolve => setTimeout(resolve, 3000)); // 2 sec
67 | });
68 |
--------------------------------------------------------------------------------
/tests/Section_03_RS_UI_Tests/08_SignIn_GetTitleOfFirstProduct.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 |
14 | test('Section_03_RS_UI_Tests - SignIn GetTitleOfFirstProduct using first().textContent(), nth(0).textContent()', async ({page} )=> {
15 |
16 | const applicationURL = "https://www.rahulshettyacademy.com/loginpagePractise/";
17 |
18 | const txtBox_username = page.locator('#username');
19 | const txtBox_password = page.locator('#password');
20 | const btn_SignIn = page.locator('#signInBtn');
21 | const title_products = page.locator('.card-body a')
22 |
23 | const data_login_username = "rahulshettyacademy";
24 | const data_login_password = "learning";
25 |
26 | // Go to the application
27 | await page.goto(applicationURL);
28 |
29 | console.log('Filling '+data_login_username+' in Username textBox');
30 | //fill() -> This method will first clear the textbox. Then, will fill the value in the textBox
31 | await txtBox_username.fill(data_login_username);
32 |
33 | console.log('Filling '+data_login_password+' in Password textBox');
34 | await txtBox_password.fill(data_login_password);
35 |
36 | await new Promise(resolve => setTimeout(resolve, 2000)); // 2 sec
37 |
38 | console.log('Click on Sign In button');
39 | await btn_SignIn.click();
40 |
41 | await new Promise(resolve => setTimeout(resolve, 3000)); // 2 sec
42 |
43 | //.card-body a -> This is a CSS Selector; Returning 4 elements
44 | //console.log(await page.locator('.card-body a').textContent()); // Strict mode violation
45 | console.log(await title_products.nth(0).textContent()); //This will look for the 1st element
46 | console.log(await title_products.first().textContent()); //This will look for the 1st element
47 |
48 | //allTextContents()
49 | // -> This will get the title of all the elements and put into one array
50 | // -> Playwright does not auto-wait for this method
51 | console.log(await title_products.allTextContents());
52 |
53 |
54 |
55 |
56 | });
57 |
--------------------------------------------------------------------------------
/tests/Section_03_RS_UI_Tests/09_SignIn_allTextContents.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | test('Section_03_RS_UI_Tests - SignIn Get Text of all elements using allTextContents() method', async ({page} )=> {
14 |
15 | const applicationURL = "https://www.rahulshettyacademy.com/loginpagePractise/";
16 |
17 | const txtBox_username = page.locator('#username');
18 | const txtBox_password = page.locator('#password');
19 | const btn_SignIn = page.locator('#signInBtn');
20 | const title_products = page.locator('.card-body a')
21 |
22 | const data_login_username = "rahulshettyacademy";
23 | const data_login_password = "learning";
24 |
25 | // Go to the application
26 | await page.goto(applicationURL);
27 |
28 | console.log('Filling '+data_login_username+' in Username textBox');
29 | //fill() -> This method will first clear the textbox. Then, will fill the value in the textBox
30 | await txtBox_username.fill(data_login_username);
31 |
32 | console.log('Filling '+data_login_password+' in Password textBox');
33 | await txtBox_password.fill(data_login_password);
34 |
35 | await new Promise(resolve => setTimeout(resolve, 2000)); // 2 sec
36 |
37 | console.log('Click on Sign In button');
38 | await btn_SignIn.click();
39 |
40 | //await new Promise(resolve => setTimeout(resolve, 3000)); // 2 sec
41 |
42 | //.card-body a -> This is a CSS Selector; Returning 4 elements
43 | //console.log(await page.locator('.card-body a').textContent()); // Strict mode violation
44 | // console.log(await title_products.nth(0).textContent()); //This will look for the 1st element
45 | // console.log(await title_products.first().textContent()); //This will look for the 1st element
46 |
47 | /***************** Wait for Page Load - START *****************/
48 |
49 | //Wait for Page Load -> Once all the APIs are called and UI got the response, then, only proceed
50 | //networkidle -> Wait until Network comes to Idle state
51 | //await page.waitForLoadState('networkidle');
52 |
53 | //await page.waitForLoadState('domcontentloaded');
54 |
55 | //await page.waitForLoadState('load');
56 |
57 | /***************** Wait for Page Load - END *****************/
58 |
59 | //allTextContents()
60 | // -> This will get the title of all the elements and put into one array
61 | // -> Playwright does not auto-wait for this method; This will return an empty Array
62 | console.log(await title_products.allTextContents());
63 |
64 | });
65 |
--------------------------------------------------------------------------------
/tests/Section_03_RS_UI_Tests/10_NW_SignIn_WaitForStaticSite.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 |
14 | test('Section_03_RS_UI_Tests - SignIn Get Text of all elements using allTextContents() with wait for Static websites', async ({page} )=> {
15 |
16 | const applicationURL = "https://www.rahulshettyacademy.com/loginpagePractise/";
17 |
18 | const txtBox_username = page.locator('#username');
19 | const txtBox_password = page.locator('#password');
20 | const btn_SignIn = page.locator('#signInBtn');
21 | const title_products = page.locator('.card-body a')
22 |
23 | const data_login_username = "rahulshettyacademy";
24 | const data_login_password = "learning";
25 |
26 | // Go to the application
27 | await page.goto(applicationURL);
28 |
29 | console.log('Filling '+data_login_username+' in Username textBox');
30 | //fill() -> This method will first clear the textbox. Then, will fill the value in the textBox
31 | await txtBox_username.fill(data_login_username);
32 |
33 | console.log('Filling '+data_login_password+' in Password textBox');
34 | await txtBox_password.fill(data_login_password);
35 |
36 | await new Promise(resolve => setTimeout(resolve, 2000)); // 2 sec
37 |
38 | console.log('Click on Sign In button');
39 | //await btn_SignIn.click();
40 |
41 | // https://playwright.dev/docs/navigations
42 | // Note that Promise.all prevents a race condition
43 | // between clicking and waiting for a navigation.
44 | await Promise.all([
45 | // Waits for the next navigation.
46 | // It is important to call waitForNavigation before click to set up waiting.
47 | page.waitForNavigation(),
48 | // Triggers a navigation after a timeout.
49 | btn_SignIn.click(),
50 | ]);
51 |
52 | //allTextContents()
53 | // -> This will get the title of all the elements and put into one array
54 | // -> Playwright does not auto-wait for this method; This will return an empty Array
55 | console.log(await title_products.allTextContents());
56 |
57 | });
58 |
59 |
60 | test('Section_03_RS_UI_Tests - Intentionally Failing - Wait and Assert the Page Title', async ({page} )=> {
61 |
62 | // Go to the application
63 | await page.goto("https://www.google.com/");
64 |
65 | // Get the Title and Print
66 | console.log(await page.title());
67 |
68 | //await delay(5000); //ReferenceError: delay is not defined
69 | await new Promise(resolve => setTimeout(resolve, 2000)); // 2 sec
70 |
71 | // Assert the Page Title
72 | await expect(page).toHaveTitle('Google1');
73 |
74 | });
75 |
--------------------------------------------------------------------------------
/tests/Section_04_RS_UI_Tests/11_Dropdown_Static.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 |
14 | test('Section_04_RS_UI_Tests - Handle Static Dropdown', async ({page} )=> {
15 |
16 | const applicationURL = "https://www.rahulshettyacademy.com/loginpagePractise/";
17 |
18 | const txtBox_username = page.locator('#username');
19 | const txtBox_password = page.locator('#password');
20 | const btn_SignIn = page.locator('#signInBtn');
21 | const drpdwn_role = page.locator("select[class='form-control']");
22 |
23 | const title_products = page.locator('.card-body a')
24 |
25 | const data_login_username = "rahulshettyacademy";
26 | const data_login_password = "learning";
27 |
28 | // Go to the application
29 | await page.goto(applicationURL);
30 |
31 | console.log('Filling '+data_login_username+' in Username textBox');
32 | await txtBox_username.fill(data_login_username);
33 |
34 | console.log('Filling '+data_login_password+' in Password textBox');
35 | await txtBox_password.fill(data_login_password);
36 |
37 | //consult :
38 | await drpdwn_role.selectOption('consult')
39 |
40 | await new Promise(resolve => setTimeout(resolve, 2000)); // 2 sec
41 |
42 | console.log('Click on Sign In button');
43 | await btn_SignIn.click();
44 |
45 |
46 | });
47 |
--------------------------------------------------------------------------------
/tests/Section_04_RS_UI_Tests/12_Dropdown_Static_Pause.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 |
14 | test('Section_04_RS_UI_Tests - HHandle Static Dropdown and Pause the execution', async ({page} )=> {
15 |
16 | const applicationURL = "https://www.rahulshettyacademy.com/loginpagePractise/";
17 |
18 | const txtBox_username = page.locator('#username');
19 | const txtBox_password = page.locator('#password');
20 | const btn_SignIn = page.locator('#signInBtn');
21 | const drpdwn_role = page.locator("select[class='form-control']");
22 |
23 | const title_products = page.locator('.card-body a')
24 |
25 | const data_login_username = "rahulshettyacademy";
26 | const data_login_password = "learning";
27 |
28 | // Go to the application
29 | await page.goto(applicationURL);
30 |
31 | console.log('Filling '+data_login_username+' in Username textBox');
32 | await txtBox_username.fill(data_login_username);
33 |
34 | console.log('Filling '+data_login_password+' in Password textBox');
35 | await txtBox_password.fill(data_login_password);
36 |
37 | //consult :
38 | await drpdwn_role.selectOption('consult')
39 |
40 | await new Promise(resolve => setTimeout(resolve, 2000)); // 2 sec
41 |
42 | console.log('Click on Sign In button');
43 | await btn_SignIn.click();
44 |
45 | await page.pause();
46 |
47 | });
48 |
--------------------------------------------------------------------------------
/tests/Section_04_RS_UI_Tests/13_RadioButton.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | test('Section_04_RS_UI_Tests - Handle Radio Button', async ({page} )=> {
14 |
15 | const applicationURL = "https://www.rahulshettyacademy.com/loginpagePractise/";
16 |
17 | const txtBox_username = page.locator('#username');
18 | const txtBox_password = page.locator('#password');
19 | const btn_SignIn = page.locator('#signInBtn');
20 | const radioBtn_user = page.locator("[value='user']");
21 | const radioBtn_user_PopUp_Okay = page.locator("#okayBtn");
22 |
23 | const title_products = page.locator('.card-body a')
24 |
25 | const data_login_username = "rahulshettyacademy";
26 | const data_login_password = "learning";
27 |
28 | // Go to the application
29 | await page.goto(applicationURL);
30 |
31 | console.log('Filling '+data_login_username+' in Username textBox');
32 | await txtBox_username.fill(data_login_username);
33 |
34 | console.log('Filling '+data_login_password+' in Password textBox');
35 | await txtBox_password.fill(data_login_password);
36 |
37 | console.log('Click on Radio button: User');
38 | await radioBtn_user.click();
39 | await new Promise(resolve => setTimeout(resolve, 2000)); // 2 sec
40 |
41 | console.log('Click on Okay button');
42 | await radioBtn_user_PopUp_Okay.click();
43 | await new Promise(resolve => setTimeout(resolve, 2000)); // 2 sec
44 |
45 | console.log("await radioBtn_user.isChecked(): "+await radioBtn_user.isChecked());
46 | console.log('Assertion for Radio button to be checked');
47 | await expect(radioBtn_user).toBeChecked();
48 |
49 | console.log('Click on Sign In button');
50 | await btn_SignIn.click();
51 |
52 | });
53 |
--------------------------------------------------------------------------------
/tests/Section_04_RS_UI_Tests/14_Checkbox.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 |
14 | test('Section_04_RS_UI_Tests - Handle Checkbox', async ({page} )=> {
15 |
16 | const applicationURL = "https://www.rahulshettyacademy.com/loginpagePractise/";
17 |
18 | const txtBox_username = page.locator('#username');
19 | const txtBox_password = page.locator('#password');
20 | const btn_SignIn = page.locator('#signInBtn');
21 | const radioBtn_user = page.locator("[value='user']");
22 | const radioBtn_user_PopUp_Okay = page.locator("#okayBtn");
23 |
24 | const checkBox_terms = page.locator("#terms");
25 |
26 | const title_products = page.locator('.card-body a')
27 |
28 | const data_login_username = "rahulshettyacademy";
29 | const data_login_password = "learning";
30 |
31 | // Go to the application
32 | await page.goto(applicationURL);
33 |
34 | console.log('Filling '+data_login_username+' in Username textBox');
35 | await txtBox_username.fill(data_login_username);
36 |
37 | console.log('Filling '+data_login_password+' in Password textBox');
38 | await txtBox_password.fill(data_login_password);
39 |
40 | console.log('Click on CheckBox: Terms');
41 | await checkBox_terms.click();
42 | await new Promise(resolve => setTimeout(resolve, 2000)); // 2 sec
43 |
44 | console.log("await checkBox_terms.isChecked(): "+await checkBox_terms.isChecked());
45 | console.log('Assertion for Checkbox_Terms to be checked');
46 | await expect(checkBox_terms).toBeChecked();
47 |
48 | await checkBox_terms.uncheck();
49 |
50 | console.log('Assertion for Checkbox_Terms to not be checked');
51 | console.log("await checkBox_terms.isChecked(): " + await checkBox_terms.isChecked())
52 | //Expecting false
53 | expect(await checkBox_terms.isChecked()).toBeFalsy();
54 |
55 | //Expecting true
56 | //await expect(checkBox_terms.isChecked()).toBeTruthy();
57 |
58 | console.log('Click on Sign In button');
59 | await btn_SignIn.click();
60 |
61 | });
62 |
--------------------------------------------------------------------------------
/tests/Section_04_RS_UI_Tests/15_Assert_AttributeValue.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 |
14 | test('Section_04_RS_UI_Tests - Assert Attribute values for an element', async ({page} )=> {
15 |
16 | const applicationURL = "https://www.rahulshettyacademy.com/loginpagePractise/";
17 |
18 | //const msg_blinkingText = page.locator("[href='https://rahulshettyacademy.com/#/documents-request']");
19 | const msg_blinkingText = page.locator("[href*='documents-request']");
20 | const btn_SignIn = page.locator('#signInBtn');
21 |
22 | console.log('Go to application: '+applicationURL);
23 | await page.goto(applicationURL);
24 |
25 | //Free Access to InterviewQues/ResumeAssistance/Material
26 | console.log("Assertion for element has attribute:'class' and value:'blinkingText'");
27 | await expect(msg_blinkingText).toHaveAttribute('class', 'blinkingText');
28 |
29 | //
30 | console.log("Assertion for element has attribute:'value' and value:'Sign In'");
31 | await expect(btn_SignIn).toHaveAttribute('value', 'Sign In');
32 | console.log("Assertion for element has attribute:'name' and value:'signin'");
33 | await expect(btn_SignIn).toHaveAttribute('name', 'signin');
34 | console.log("Assertion for element has attribute:'type' and value:'submit'");
35 | await expect(btn_SignIn).toHaveAttribute('type', 'submit');
36 |
37 | });
38 |
--------------------------------------------------------------------------------
/tests/Section_04_RS_UI_Tests/16_Handle_ChildWindows.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | test('Section_04_RS_UI_Tests - Handle Child Windows', async ({browser} )=> {
14 |
15 | const context = await browser.newContext(); // ----------------------------------- > (A)
16 |
17 | const page = await context.newPage(); // ----------------------------------- > (B)
18 |
19 | const applicationURL = "https://www.rahulshettyacademy.com/loginpagePractise/";
20 | const msg_blinkingText = page.locator("[href*='documents-request']");
21 |
22 | console.log('Go to application: '+applicationURL);
23 | await page.goto(applicationURL);
24 |
25 | console.log('Click on the link that opens in new window');
26 | //msg_blinkingText.click();
27 |
28 | /**************** Operations on New Window - START ****************/
29 |
30 | const [newPage] = await Promise.all([
31 | context.waitForEvent('page'),
32 | msg_blinkingText.click(),
33 | ]);
34 |
35 | //newPage -> This is the new page (Opened after click operation over link)
36 | //.theme-btn.register-btn -> Login button
37 | const elementText_OnNewPage = await newPage.locator('.theme-btn.register-btn').textContent();
38 | console.log('elementText_OnNewPage: '+elementText_OnNewPage);
39 | console.log("Assertion for Element Text present on new page");
40 | await expect(newPage.locator('.theme-btn.register-btn')).toHaveText('Login');
41 |
42 | /**************** Operations on New Window - END ****************/
43 | });
44 |
--------------------------------------------------------------------------------
/tests/Section_04_RS_UI_Tests/17_NW_ChangeFocusFromChildToParentWin.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 |
14 | test('Section_04_RS_UI_Tests - Change Focus From Child To Parent Window', async ({browser} )=> {
15 |
16 | const context = await browser.newContext(); // ----------------------------------- > (A)
17 |
18 | const page = await context.newPage(); // ----------------------------------- > (B)
19 |
20 | const applicationURL = "https://www.rahulshettyacademy.com/loginpagePractise/";
21 | const msg_blinkingText = page.locator("[href*='documents-request']");
22 |
23 | console.log('Go to application: '+applicationURL);
24 | await page.goto(applicationURL);
25 |
26 | console.log('Click on the link that opens in new window');
27 | //msg_blinkingText.click();
28 |
29 | /**************** Operations on Child Window - START ****************/
30 | const [newPage] = await Promise.all([
31 | context.waitForEvent('page'),
32 | msg_blinkingText.click(),
33 | ]);
34 |
35 | //newPage -> This is the new page (Opened after click operation over link)
36 | //.theme-btn.register-btn -> Login button
37 | const elementText_OnNewPage = await newPage.locator('.theme-btn.register-btn').textContent();
38 | console.log('elementText_OnNewPage: '+elementText_OnNewPage);
39 | console.log("Assertion for Element Text present on new page");
40 | await expect(newPage.locator('.theme-btn.register-btn')).toHaveText('Login');
41 |
42 | /**************** Operations on Child Window - END ****************/
43 |
44 | /**************** Operations on Parent Window - START ****************/
45 |
46 | console.log("Filling 'Rajat Verma' in username textbox present on parent window");
47 | await page.locator('#username').fill("Rajat Verma");
48 |
49 | //await page.pause();
50 |
51 | console.log("await page.locator('#username').textContent(): " + await page.locator('#username').textContent());
52 |
53 | // console.log("Assertion for username textbox - It should contain text: 'Rajat Verma'")
54 | // await expect(page.locator('#username')).toContainText('Rajat Verma');
55 |
56 | await new Promise(resolve => setTimeout(resolve, 4000)); // 4 sec
57 |
58 | /**************** Operations on Parent Window - END ****************/
59 |
60 | });
61 |
--------------------------------------------------------------------------------
/tests/Section_04_RS_UI_Tests/18_NW_MoreThanOneChildWindows.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | test('Section_04_RS_UI_Tests - Change Focus From Child To Parent Window', async ({browser} )=> {
14 |
15 |
16 | /**************** Operations on Child Window - START ****************/
17 |
18 | const [child1,child2,child3] = await Promise.all([
19 | context.waitForEvent('page'),
20 | msg_blinkingText.click(),
21 | ]);
22 | /**************** Operations on Child Window - END ****************/
23 |
24 | });
25 |
--------------------------------------------------------------------------------
/tests/Section_06_RS_UI_Tests_ClientApp/19_Login_Assert_LoginSuccess.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 |
14 |
15 | test('Section_06_RS_UI_Tests - RahulShettyAcademy Client App Login', async ({page} )=> {
16 |
17 | const applicationURL = "https://www.rahulshettyacademy.com/client/";
18 |
19 | const txtBox_username = page.locator('#userEmail');
20 | const txtBox_password = page.locator('#userPassword');
21 | const btn_Login = page.locator('#login');
22 |
23 | const data_login_username = "testtmail95@gmail.com";
24 | const data_login_password = "HiRahul@123";
25 |
26 | const msg_login_success = page.locator("div[aria-label='Login Successfully']");
27 |
28 | await loginToApplication(applicationURL, page, data_login_username, txtBox_username, data_login_password, txtBox_password, btn_Login);
29 |
30 | console.log('Assertions for message: Login Successfully')
31 | await expect(msg_login_success).toBeVisible();
32 | await expect(msg_login_success).toHaveText('Login Successfully');
33 | await expect(msg_login_success).toContainText('Successfully');
34 |
35 | await waitForSomeTime(2);
36 |
37 | });
38 |
39 | async function waitForSomeTime(timeInSeconds) {
40 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
41 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
42 | }
43 |
44 | async function loginToApplication(applicationURL, page, data_login_username, txtBox_username, data_login_password, txtBox_password, btn_Login) {
45 | console.log('Go to application: ' + applicationURL);
46 | await page.goto(applicationURL);
47 |
48 | console.log('Filling ' + data_login_username + ' in Username textBox');
49 | await txtBox_username.fill(data_login_username);
50 |
51 | console.log('Filling ' + data_login_password + ' in Password textBox');
52 | await txtBox_password.fill(data_login_password);
53 |
54 | await new Promise(resolve => setTimeout(resolve, 2000)); // 2 sec
55 |
56 | console.log('Click on Log In button');
57 | await btn_Login.click();
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/tests/Section_06_RS_UI_Tests_ClientApp/20_Login_allTextContents.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | test('Section_06_RS_UI_Tests - RahulShettyAcademy Client App Login - allTextContents()', async ({page} )=> {
14 |
15 | const applicationURL = "https://www.rahulshettyacademy.com/client/";
16 |
17 | const txtBox_username = page.locator('#userEmail');
18 | const txtBox_password = page.locator('#userPassword');
19 | const btn_Login = page.locator('#login');
20 |
21 | const data_login_username = "testtmail95@gmail.com";
22 | const data_login_password = "HiRahul@123";
23 |
24 | const msg_login_success = page.locator("div[aria-label='Login Successfully']");
25 |
26 | const title_products = page.locator('.card-body b');
27 |
28 | await loginToApplication(applicationURL, page, data_login_username, txtBox_username, data_login_password, txtBox_password, btn_Login, msg_login_success);
29 |
30 | // Wait
31 | //await page.waitForLoadState('networkidle');
32 | //await page.waitForLoadState('domcontentloaded');
33 | //await page.waitForLoadState('load');
34 |
35 | const productTitles = await title_products.allTextContents();
36 | console.log(productTitles);
37 |
38 | await waitForSomeTime(2);
39 |
40 |
41 | });
42 |
43 | async function waitForSomeTime(timeInSeconds) {
44 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
45 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
46 | }
47 |
48 | async function loginToApplication(applicationURL, page, data_login_username, txtBox_username, data_login_password, txtBox_password, btn_Login, msg_login_success) {
49 | console.log('Go to application: ' + applicationURL);
50 | await page.goto(applicationURL);
51 |
52 | console.log('Filling ' + data_login_username + ' in Username textBox');
53 | await txtBox_username.fill(data_login_username);
54 |
55 | console.log('Filling ' + data_login_password + ' in Password textBox');
56 | await txtBox_password.fill(data_login_password);
57 |
58 | await new Promise(resolve => setTimeout(resolve, 2000)); // 2 sec
59 |
60 | console.log('Click on Log In button');
61 | await btn_Login.click();
62 |
63 | console.log('Assertions for message: Login Successfully')
64 | await expect(msg_login_success).toBeVisible();
65 | await expect(msg_login_success).toHaveText('Login Successfully');
66 | await expect(msg_login_success).toContainText('Successfully');
67 |
68 | }
69 |
70 |
--------------------------------------------------------------------------------
/tests/Section_06_RS_UI_Tests_ClientApp/21_Login_AddProduct_ToCart.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | test('Section_06_RS_UI_Tests - RahulShettyAcademy Client App Login - Iterate Over Products', async ({page} )=> {
14 |
15 | const applicationURL = "https://www.rahulshettyacademy.com/client/";
16 |
17 | const txtBox_username = page.locator('#userEmail');
18 | const txtBox_password = page.locator('#userPassword');
19 | const btn_Login = page.locator('#login');
20 |
21 | const data_login_username = "testtmail95@gmail.com";
22 | const data_login_password = "HiRahul@123";
23 |
24 | const msg_login_success = page.locator("div[aria-label='Login Successfully']");
25 |
26 | const products = page.locator('.card-body');
27 | const product_ToAdd='iphone 13 pro';
28 |
29 | const msg_productAdded_ToCart = page.locator("div[aria-label='Product Added To Cart']");
30 |
31 | await loginToApplication(applicationURL, page, data_login_username, txtBox_username, data_login_password, txtBox_password, btn_Login, msg_login_success);
32 |
33 | const productsCount = await products.count();
34 | console.log("productsCount: " + productsCount);
35 |
36 | for(let index=0;index setTimeout(resolve, (timeInSeconds*1000)));
66 | }
67 |
68 | async function loginToApplication(applicationURL, page, data_login_username, txtBox_username, data_login_password, txtBox_password, btn_Login, msg_login_success) {
69 | console.log('Go to application: ' + applicationURL);
70 | await page.goto(applicationURL);
71 |
72 | console.log('Filling ' + data_login_username + ' in Username textBox');
73 | await txtBox_username.fill(data_login_username);
74 |
75 | console.log('Filling ' + data_login_password + ' in Password textBox');
76 | await txtBox_password.fill(data_login_password);
77 |
78 | await new Promise(resolve => setTimeout(resolve, 2000)); // 2 sec
79 |
80 | console.log('Click on Log In button');
81 | await btn_Login.click();
82 |
83 | console.log('Assertions for message: Login Successfully')
84 | await expect(msg_login_success).toBeVisible();
85 | await expect(msg_login_success).toHaveText('Login Successfully');
86 | await expect(msg_login_success).toContainText('Successfully');
87 |
88 | }
89 |
90 |
--------------------------------------------------------------------------------
/tests/Section_06_RS_UI_Tests_ClientApp/22_Login_AssertProductOnCartPage.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | test('Section_06_RS_UI_Tests - RahulShettyAcademy Client App Login - Assert Product On Cart Page', async ({page} )=> {
14 |
15 | const applicationURL = "https://www.rahulshettyacademy.com/client/";
16 |
17 | const txtBox_username = page.locator('#userEmail');
18 | const txtBox_password = page.locator('#userPassword');
19 | const btn_Login = page.locator('#login');
20 |
21 | const data_login_username = "testtmail95@gmail.com";
22 | const data_login_password = "HiRahul@123";
23 |
24 | const msg_login_success = page.locator("div[aria-label='Login Successfully']");
25 |
26 | const products = page.locator('.card-body');
27 | const product_ToAdd='iphone 13 pro';
28 |
29 | const msg_productAdded_ToCart = page.locator("div[aria-label='Product Added To Cart']");
30 |
31 | await loginToApplication(applicationURL, page, data_login_username, txtBox_username, data_login_password, txtBox_password, btn_Login, msg_login_success);
32 |
33 | /****************** Product Add to Cart - START *******************/
34 | const productsCount = await products.count();
35 | console.log("productsCount: " + productsCount);
36 |
37 | for(let index=0;index This is required because Playwright is not supporting Auto-wait for isVisible()
72 | // Auto-Wait -> https://playwright.dev/docs/actionability
73 | await page.locator('div li').first().waitFor();
74 |
75 | console.log("Assertion for Product name on Cart Page")
76 | //Pseudo text
77 | const productNameStatus = await page.locator("h3:has-text('"+product_ToAdd+"')").isVisible();
78 | expect(productNameStatus).toBeTruthy();
79 |
80 | /****************** Cart Page - END *******************/
81 |
82 |
83 |
84 |
85 | await waitForSomeTime(2);
86 |
87 |
88 | });
89 |
90 |
91 |
92 | async function waitForSomeTime(timeInSeconds) {
93 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
94 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
95 | }
96 |
97 | async function loginToApplication(applicationURL, page, data_login_username, txtBox_username, data_login_password, txtBox_password, btn_Login, msg_login_success) {
98 | console.log('Go to application: ' + applicationURL);
99 | await page.goto(applicationURL);
100 |
101 | console.log('Filling ' + data_login_username + ' in Username textBox');
102 | await txtBox_username.fill(data_login_username);
103 |
104 | console.log('Filling ' + data_login_password + ' in Password textBox');
105 | await txtBox_password.fill(data_login_password);
106 |
107 | await new Promise(resolve => setTimeout(resolve, 2000)); // 2 sec
108 |
109 | console.log('Click on Log In button');
110 | await btn_Login.click();
111 |
112 | console.log('Assertions for message: Login Successfully')
113 | await expect(msg_login_success).toBeVisible();
114 | await expect(msg_login_success).toHaveText('Login Successfully');
115 | await expect(msg_login_success).toContainText('Successfully');
116 |
117 | }
118 |
119 |
--------------------------------------------------------------------------------
/tests/Section_06_RS_UI_Tests_ClientApp/23_NW_Login_Dropdown_AutoSuggestive.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | test('Section_06_RS_UI_Tests - RahulShettyAcademy Client App Login - Dropdown_AutoSuggestive', async ({page} )=> {
14 |
15 | const applicationURL = "https://www.rahulshettyacademy.com/client/";
16 |
17 | const txtBox_username = page.locator('#userEmail');
18 | const txtBox_password = page.locator('#userPassword');
19 | const btn_Login = page.locator('#login');
20 |
21 | const data_login_username = "testtmail95@gmail.com";
22 | const data_login_password = "HiRahul@123";
23 |
24 | const msg_login_success = page.locator("div[aria-label='Login Successfully']");
25 |
26 | const products = page.locator('.card-body');
27 | const product_ToAdd='iphone 13 pro';
28 |
29 | const msg_productAdded_ToCart = page.locator("div[aria-label='Product Added To Cart']");
30 |
31 | await loginToApplication(applicationURL, page, data_login_username, txtBox_username, data_login_password, txtBox_password, btn_Login, msg_login_success);
32 |
33 | /****************** Product Add to Cart - START *******************/
34 | const productsCount = await products.count();
35 | console.log("productsCount: " + productsCount);
36 |
37 | for(let index=0;index This is required because Playwright is not supporting Auto-wait for isVisible()
71 | // Auto-Wait -> https://playwright.dev/docs/actionability
72 | await page.locator('div li').first().waitFor();
73 |
74 | console.log("Assertion for Product name on Cart Page")
75 | //Pseudo text
76 | const productNameStatus = await page.locator("h3:has-text('"+product_ToAdd+"')").isVisible();
77 | expect(productNameStatus).toBeTruthy();
78 |
79 | const btn_checkout = page.locator("text=Checkout");
80 |
81 | console.log('Clicking on Checkout button')
82 | await btn_checkout.click();
83 |
84 | /****************** Cart Page - END *******************/
85 |
86 | /****************** Checkout Page - START *******************/
87 |
88 | /***** Select value from Dropdown - START ******/
89 |
90 | const drpdwn_selectCountry = page.locator("[placeholder='Select Country']");
91 |
92 | const country_ToSearch = 'India';
93 |
94 | console.log("Filling 'ind' in Select Country slowly")
95 | //{delay:100} -> This will help to type Ind slowly
96 | drpdwn_selectCountry.type('ind', { delay:1000 } );
97 |
98 | const options_country = page.locator('.ta-results');
99 | console.log("Waiting for Countries to load after search for 'ind'");
100 | await options_country.waitFor();
101 |
102 | const countriesCount = options_country.locator('button').count();
103 |
104 | for(let index=0;index To remove the spaces from country name
110 | if(countryName.trim() === country_ToSearch){
111 | console.log('Clicking on '+country_ToSearch+'.')
112 | await options_country.locator('button').nth(index).click();
113 | break;
114 | }
115 | }
116 |
117 | /***** Select value from Dropdown - END ******/
118 |
119 | /****************** Checkout Page - END *******************/
120 |
121 |
122 |
123 |
124 | await waitForSomeTime(2);
125 |
126 |
127 | });
128 |
129 |
130 |
131 | async function waitForSomeTime(timeInSeconds) {
132 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
133 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
134 | }
135 |
136 | async function loginToApplication(applicationURL, page, data_login_username, txtBox_username, data_login_password, txtBox_password, btn_Login, msg_login_success) {
137 | console.log('Go to application: ' + applicationURL);
138 | await page.goto(applicationURL);
139 |
140 | console.log('Filling ' + data_login_username + ' in Username textBox');
141 | await txtBox_username.fill(data_login_username);
142 |
143 | console.log('Filling ' + data_login_password + ' in Password textBox');
144 | await txtBox_password.fill(data_login_password);
145 |
146 | await new Promise(resolve => setTimeout(resolve, 2000)); // 2 sec
147 |
148 | console.log('Click on Log In button');
149 | await btn_Login.click();
150 |
151 | console.log('Assertions for message: Login Successfully')
152 | await expect(msg_login_success).toBeVisible();
153 | await expect(msg_login_success).toHaveText('Login Successfully');
154 | await expect(msg_login_success).toContainText('Successfully');
155 |
156 | }
157 |
158 |
--------------------------------------------------------------------------------
/tests/Section_06_RS_UI_Tests_ClientApp/25_Login_Assert_EmailID.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | test('Section_06_RS_UI_Tests - RahulShettyAcademy Client App Login - Assertion for Email ID', async ({page} )=> {
14 |
15 | const applicationURL = "https://www.rahulshettyacademy.com/client/";
16 |
17 | const txtBox_username = page.locator('#userEmail');
18 | const txtBox_password = page.locator('#userPassword');
19 | const btn_Login = page.locator('#login');
20 |
21 | const data_login_username = "testtmail95@gmail.com";
22 | const data_login_password = "HiRahul@123";
23 |
24 | const msg_login_success = page.locator("div[aria-label='Login Successfully']");
25 |
26 | const products = page.locator('.card-body');
27 | const product_ToAdd='iphone 13 pro';
28 |
29 | const msg_productAdded_ToCart = page.locator("div[aria-label='Product Added To Cart']");
30 |
31 | await loginToApplication(applicationURL, page, data_login_username, txtBox_username, data_login_password, txtBox_password, btn_Login, msg_login_success);
32 |
33 | /****************** Product Add to Cart - START *******************/
34 | const productsCount = await products.count();
35 | console.log("productsCount: " + productsCount);
36 |
37 | for(let index=0;index This is required because Playwright is not supporting Auto-wait for isVisible()
71 | // Auto-Wait -> https://playwright.dev/docs/actionability
72 | await page.locator('div li').first().waitFor();
73 |
74 | console.log("Assertion for Product name on Cart Page")
75 | //Pseudo text
76 | const productNameStatus = await page.locator("h3:has-text('"+product_ToAdd+"')").isVisible();
77 | expect(productNameStatus).toBeTruthy();
78 |
79 | const btn_checkout = page.locator("text=Checkout");
80 |
81 | console.log('Clicking on Checkout button')
82 | await btn_checkout.click();
83 |
84 | /****************** Cart Page - END *******************/
85 |
86 | /****************** Checkout Page - START *******************/
87 |
88 | /***** Select value from Dropdown - START ******/
89 |
90 | const drpdwn_selectCountry = page.locator("[placeholder='Select Country']");
91 | const country_ToSearch = 'India';
92 |
93 | console.log("Filling 'ind' in Select Country slowly")
94 | //{delay:100} -> This will help to type Ind slowly
95 | drpdwn_selectCountry.type('ind', { delay:1000 } );
96 |
97 | const options_country = page.locator('.ta-results');
98 | console.log("Waiting for Countries to load after search for 'ind'");
99 | // await options_country.waitFor();
100 |
101 | // const countriesCount = options_country.locator('button').count();
102 |
103 | // for(let index=0;index To remove the spaces from country name
109 | // if(countryName.trim() === country_ToSearch){
110 | // console.log('Clicking on '+country_ToSearch+'.')
111 | // await options_country.locator('button').nth(index).click();
112 | // break;
113 | // }
114 | // }
115 |
116 | console.log('Commented the Dropdown - Auto-Suggestive');
117 | /***** Select value from Dropdown - END ******/
118 |
119 | /***** Assertion for Email ID - START ******/
120 |
121 | //const txtBox_email_checkoutPage = page.locator(".user__name [type='text']").nth(0);
122 | const txtBox_email_checkoutPage = page.locator(".user__name [type='text']").first();
123 | console.log('Assertion for EMail ID on Checkout page');
124 | await expect(txtBox_email_checkoutPage).toContainText(data_login_username);
125 |
126 | const btn_placeOrder = page.locator('.action__submit');
127 | console.log('Clickin on Place Order button');
128 | await btn_placeOrder.click();
129 |
130 | /***** Assertion for Email ID - END ******/
131 |
132 | /****************** Checkout Page - END *******************/
133 |
134 | /****************** Order Placed Page - START *******************/
135 |
136 |
137 | /****************** Order Placed Page - END *******************/
138 |
139 | await page.pause();
140 |
141 | await waitForSomeTime(2);
142 |
143 |
144 | });
145 |
146 |
147 |
148 | async function waitForSomeTime(timeInSeconds) {
149 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
150 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
151 | }
152 |
153 | async function loginToApplication(applicationURL, page, data_login_username, txtBox_username, data_login_password, txtBox_password, btn_Login, msg_login_success) {
154 | console.log('Go to application: ' + applicationURL);
155 | await page.goto(applicationURL);
156 |
157 | console.log('Filling ' + data_login_username + ' in Username textBox');
158 | await txtBox_username.fill(data_login_username);
159 |
160 | console.log('Filling ' + data_login_password + ' in Password textBox');
161 | await txtBox_password.fill(data_login_password);
162 |
163 | await new Promise(resolve => setTimeout(resolve, 2000)); // 2 sec
164 |
165 | console.log('Click on Log In button');
166 | await btn_Login.click();
167 |
168 | console.log('Assertions for message: Login Successfully')
169 | await expect(msg_login_success).toBeVisible();
170 | await expect(msg_login_success).toHaveText('Login Successfully');
171 | await expect(msg_login_success).toContainText('Successfully');
172 |
173 | }
174 |
175 |
--------------------------------------------------------------------------------
/tests/Section_06_RS_UI_Tests_ClientApp/26_NW_Login_Assert_Message_OrderPlacedPage.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | test('Section_06_RS_UI_Tests - RahulShettyAcademy Client App Login - Assertion for message on OrderPlaced Page', async ({page} )=> {
14 |
15 | const applicationURL = "https://www.rahulshettyacademy.com/client/";
16 |
17 | const txtBox_username = page.locator('#userEmail');
18 | const txtBox_password = page.locator('#userPassword');
19 | const btn_Login = page.locator('#login');
20 |
21 | const data_login_username = "testtmail95@gmail.com";
22 | const data_login_password = "HiRahul@123";
23 |
24 | const msg_login_success = page.locator("div[aria-label='Login Successfully']");
25 |
26 | const products = page.locator('.card-body');
27 | const product_ToAdd='iphone 13 pro';
28 |
29 | const msg_productAdded_ToCart = page.locator("div[aria-label='Product Added To Cart']");
30 |
31 | await loginToApplication(applicationURL, page, data_login_username, txtBox_username, data_login_password, txtBox_password, btn_Login, msg_login_success);
32 |
33 | /****************** Product Add to Cart - START *******************/
34 | const productsCount = await products.count();
35 | console.log("productsCount: " + productsCount);
36 |
37 | for(let index=0;index This is required because Playwright is not supporting Auto-wait for isVisible()
71 | // Auto-Wait -> https://playwright.dev/docs/actionability
72 | await page.locator('div li').first().waitFor();
73 |
74 | console.log("Assertion for Product name on Cart Page")
75 | //Pseudo text
76 | const productNameStatus = await page.locator("h3:has-text('"+product_ToAdd+"')").isVisible();
77 | expect(productNameStatus).toBeTruthy();
78 |
79 | const btn_checkout = page.locator("text=Checkout");
80 |
81 | console.log('Clicking on Checkout button')
82 | await btn_checkout.click();
83 |
84 | /****************** Cart Page - END *******************/
85 |
86 | /****************** Checkout Page - START *******************/
87 | /***** Select value from Dropdown - START ******/
88 |
89 | const drpdwn_selectCountry = page.locator("[placeholder='Select Country']");
90 |
91 | const country_ToSearch = 'India';
92 |
93 | await page.waitForLoadState('networkidle');
94 |
95 | console.log("Filling 'ind' in Select Country slowly")
96 | //{delay:100} -> This will help to type Ind slowly
97 | drpdwn_selectCountry.type('ind', { delay:1000 } );
98 |
99 | const options_country = page.locator('.ta-results');
100 | console.log("Waiting for Countries to load after search for 'ind'");
101 | await options_country.waitFor();
102 |
103 | const countriesCount = options_country.locator('button').count();
104 |
105 | for(let index=0;index To remove the spaces from country name
111 | if(countryName.trim() === country_ToSearch){
112 | console.log('Clicking on '+country_ToSearch+'.')
113 | await options_country.locator('button').nth(index).click();
114 | break;
115 | }
116 | }
117 |
118 | /***** Select value from Dropdown - END ******/
119 |
120 |
121 | /***** Assertion for Email ID - START ******/
122 |
123 | //const txtBox_email_checkoutPage = page.locator(".user__name [type='text']").nth(0);
124 | const txtBox_email_checkoutPage = page.locator(".user__name [type='text']").first();
125 | console.log('Assertion for EMail ID on Checkout page');
126 | await expect(txtBox_email_checkoutPage).toContainText(data_login_username);
127 |
128 | const btn_placeOrder = page.locator('.action__submit');
129 | console.log('Clicking on Place Order button');
130 | await btn_placeOrder.click();
131 |
132 | /***** Assertion for Email ID - END ******/
133 |
134 | /****************** Checkout Page - END *******************/
135 |
136 | /****************** Order Placed Page - START *******************/
137 |
138 | const msg_orderPlaced = page.locator("h1[class='hero-primary']");
139 | console.log('Assertions for message: Thankyou for the order.')
140 | await expect(msg_orderPlaced).toBeVisible();
141 | await expect(msg_orderPlaced).toContainText('Thankyou for the order.');
142 |
143 | const orderID = await page.locator(".em-spacer-1 .ng-star-inserted").textContent();
144 | console.log("orderID: "+orderID);
145 |
146 | /****************** Order Placed Page - END *******************/
147 |
148 | await page.pause();
149 |
150 | await waitForSomeTime(2);
151 |
152 |
153 | });
154 |
155 |
156 |
157 | async function waitForSomeTime(timeInSeconds) {
158 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
159 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
160 | }
161 |
162 | async function loginToApplication(applicationURL, page, data_login_username, txtBox_username, data_login_password, txtBox_password, btn_Login, msg_login_success) {
163 | console.log('Go to application: ' + applicationURL);
164 | await page.goto(applicationURL);
165 |
166 | console.log('Filling ' + data_login_username + ' in Username textBox');
167 | await txtBox_username.fill(data_login_username);
168 |
169 | console.log('Filling ' + data_login_password + ' in Password textBox');
170 | await txtBox_password.fill(data_login_password);
171 |
172 | await new Promise(resolve => setTimeout(resolve, 2000)); // 2 sec
173 |
174 | console.log('Click on Log In button');
175 | await btn_Login.click();
176 |
177 | console.log('Assertions for message: Login Successfully')
178 | await expect(msg_login_success).toBeVisible();
179 | await expect(msg_login_success).toHaveText('Login Successfully');
180 | await expect(msg_login_success).toContainText('Successfully');
181 |
182 | }
183 |
184 |
--------------------------------------------------------------------------------
/tests/Section_06_RS_UI_Tests_ClientApp/27_NW_Login_Assert_OrderID_On_OrderHistoryPage.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | test('Section_06_RS_UI_Tests - RahulShettyAcademy Client App Login - Assertion for Order ID Order History Page', async ({page} )=> {
14 |
15 | const applicationURL = "https://www.rahulshettyacademy.com/client/";
16 |
17 | const txtBox_username = page.locator('#userEmail');
18 | const txtBox_password = page.locator('#userPassword');
19 | const btn_Login = page.locator('#login');
20 |
21 | const data_login_username = "testtmail95@gmail.com";
22 | const data_login_password = "HiRahul@123";
23 |
24 | const msg_login_success = page.locator("div[aria-label='Login Successfully']");
25 |
26 | const products = page.locator('.card-body');
27 | const product_ToAdd='iphone 13 pro';
28 |
29 | const msg_productAdded_ToCart = page.locator("div[aria-label='Product Added To Cart']");
30 |
31 | await loginToApplication(applicationURL, page, data_login_username, txtBox_username, data_login_password, txtBox_password, btn_Login, msg_login_success);
32 |
33 | /****************** Product Add to Cart - START *******************/
34 | const productsCount = await products.count();
35 | console.log("productsCount: " + productsCount);
36 |
37 | for(let index=0;index This is required because Playwright is not supporting Auto-wait for isVisible()
71 | // Auto-Wait -> https://playwright.dev/docs/actionability
72 | await page.locator('div li').first().waitFor();
73 |
74 | console.log("Assertion for Product name on Cart Page")
75 | //Pseudo text
76 | const productNameStatus = await page.locator("h3:has-text('"+product_ToAdd+"')").isVisible();
77 | expect(productNameStatus).toBeTruthy();
78 |
79 | const btn_checkout = page.locator("text=Checkout");
80 |
81 | console.log('Clicking on Checkout button')
82 | await btn_checkout.click();
83 |
84 | /****************** Cart Page - END *******************/
85 |
86 | /****************** Checkout Page - START *******************/
87 | /***** Select value from Dropdown - START ******/
88 |
89 | const drpdwn_selectCountry = page.locator("[placeholder='Select Country']");
90 |
91 | const country_ToSearch = 'India';
92 |
93 | await page.waitForLoadState('networkidle');
94 |
95 | console.log("Filling 'ind' in Select Country slowly")
96 | //{delay:100} -> This will help to type Ind slowly
97 | drpdwn_selectCountry.type('ind', { delay:1000 } );
98 |
99 | const options_country = page.locator('.ta-results');
100 | console.log("Waiting for Countries to load after search for 'ind'");
101 | await options_country.waitFor();
102 |
103 | const countriesCount = options_country.locator('button').count();
104 |
105 | for(let index=0;index To remove the spaces from country name
111 | if(countryName.trim() === country_ToSearch){
112 | console.log('Clicking on '+country_ToSearch+'.')
113 | await options_country.locator('button').nth(index).click();
114 | break;
115 | }
116 | }
117 |
118 | /***** Select value from Dropdown - END ******/
119 |
120 |
121 | /***** Assertion for Email ID - START ******/
122 |
123 | //const txtBox_email_checkoutPage = page.locator(".user__name [type='text']").nth(0);
124 | const txtBox_email_checkoutPage = page.locator(".user__name [type='text']").first();
125 | console.log('Assertion for EMail ID on Checkout page');
126 | await expect(txtBox_email_checkoutPage).toContainText(data_login_username);
127 |
128 | const btn_placeOrder = page.locator('.action__submit');
129 | console.log('Clicking on Place Order button');
130 | await btn_placeOrder.click();
131 |
132 | /***** Assertion for Email ID - END ******/
133 |
134 | /****************** Checkout Page - END *******************/
135 |
136 | /****************** Order Placed Page - START *******************/
137 |
138 | const msg_orderPlaced = page.locator("h1[class='hero-primary']");
139 | console.log('Assertions for message: Thankyou for the order.')
140 | await expect(msg_orderPlaced).toBeVisible();
141 | await expect(msg_orderPlaced).toContainText('Thankyou for the order.');
142 |
143 | const orderID = await page.locator(".em-spacer-1 .ng-star-inserted").textContent();
144 | console.log("orderID: "+orderID);
145 |
146 | const tab_orders = page.locator("button[routerlink*='myorders']");
147 | await tab_orders.click();
148 |
149 | /****************** Order Placed Page - END *******************/
150 |
151 | /****************** Order History Page - START *******************/
152 |
153 | const rows_orders = page.locator("tbody tr");
154 | for(let i=0;i setTimeout(resolve, (timeInSeconds*1000)));
183 | }
184 |
185 | async function loginToApplication(applicationURL, page, data_login_username, txtBox_username, data_login_password, txtBox_password, btn_Login, msg_login_success) {
186 | console.log('Go to application: ' + applicationURL);
187 | await page.goto(applicationURL);
188 |
189 | console.log('Filling ' + data_login_username + ' in Username textBox');
190 | await txtBox_username.fill(data_login_username);
191 |
192 | console.log('Filling ' + data_login_password + ' in Password textBox');
193 | await txtBox_password.fill(data_login_password);
194 |
195 | await new Promise(resolve => setTimeout(resolve, 2000)); // 2 sec
196 |
197 | console.log('Click on Log In button');
198 | await btn_Login.click();
199 |
200 | console.log('Assertions for message: Login Successfully')
201 | await expect(msg_login_success).toBeVisible();
202 | await expect(msg_login_success).toHaveText('Login Successfully');
203 | await expect(msg_login_success).toContainText('Successfully');
204 |
205 | }
206 |
207 |
--------------------------------------------------------------------------------
/tests/Section_07_RS_UI_Tests/29_goBack_Forward.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | test('Section_07_RS_UI_Tests - RahulShettyAcademy Automation Practice App - Assertion with Go Back and Forward', async ({page} )=> {
14 |
15 | const rs_applicationURL = "https://rahulshettyacademy.com/AutomationPractice/";
16 | const google_URL = "https://www.google.com/";
17 |
18 | console.log('Go to application: '+rs_applicationURL);
19 | page.goto(rs_applicationURL);
20 | await waitForSomeTime(2);
21 |
22 | console.log('Go to application: '+google_URL);
23 | page.goto(google_URL);
24 | await waitForSomeTime(2);
25 |
26 | await expect(page).toHaveTitle('Google');
27 |
28 | await page.goBack();
29 | await waitForSomeTime(2);
30 |
31 | await expect(page).toHaveTitle('Practice Page');
32 |
33 | await page.goForward();
34 | await waitForSomeTime(2);
35 |
36 | await expect(page).toHaveTitle('Google');
37 | await waitForSomeTime(2);
38 | });
39 |
40 |
41 |
42 | async function waitForSomeTime(timeInSeconds) {
43 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
44 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/tests/Section_07_RS_UI_Tests/30_Element_VisibleOrHidden.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | test('Section_07_RS_UI_Tests - RahulShettyAcademy Automation Practice App - Assertion for Element Visible/Hidden', async ({page} )=> {
14 |
15 | const applicationURL = "https://rahulshettyacademy.com/AutomationPractice/";
16 |
17 | const txtBox_hide_show_example = page.locator('#displayed-text');
18 | const btn_hide = page.locator('#hide-textbox');
19 |
20 | await page.goto(applicationURL);
21 |
22 | console.log('Assertion for TextBox visible');
23 | await expect(txtBox_hide_show_example).toBeVisible();
24 |
25 | clickOnElement(btn_hide);
26 |
27 | await waitForSomeTime(2);
28 |
29 | console.log('Assertion for TextBox hidden');
30 | await expect(txtBox_hide_show_example).toBeHidden();
31 |
32 | await waitForSomeTime(2);
33 |
34 | });
35 |
36 |
37 | async function clickOnElement(element,elementText) {
38 | console.log('Clicking on: '+elementText);
39 | await element.click();
40 | }
41 |
42 |
43 | async function waitForSomeTime(timeInSeconds) {
44 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
45 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/tests/Section_07_RS_UI_Tests/31_Handle_Alerts_Popup_Dialog.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | test('Section_07_RS_UI_Tests - RahulShettyAcademy Automation Practice App - Handle Alerts/Popu/Dialog', async ({page} )=> {
14 |
15 | const applicationURL = "https://rahulshettyacademy.com/AutomationPractice/";
16 |
17 | const btn_confirm = page.locator('#confirmbtn');
18 |
19 | await page.goto(applicationURL);
20 |
21 |
22 | clickOnElement(btn_confirm,'Confirm button');
23 |
24 | // We are listening to this event
25 | // To accept it
26 | page.on('dialog' , dialog => dialog.accept());
27 | // To dismiss it
28 | // page.on('dialog' , dialog => dialog.dismiss());
29 |
30 | // await page.pause();
31 |
32 | await waitForSomeTime(2);
33 |
34 | });
35 |
36 |
37 | async function clickOnElement(element,elementText) {
38 | console.log('Clicking on: '+elementText);
39 | await element.click();
40 | }
41 |
42 |
43 | async function waitForSomeTime(timeInSeconds) {
44 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
45 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/tests/Section_07_RS_UI_Tests/32_MouseHover.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | test('Section_07_RS_UI_Tests - RahulShettyAcademy Automation Practice App - Handle Alerts/Popu/Dialog', async ({page} )=> {
14 |
15 | const applicationURL = "https://rahulshettyacademy.com/AutomationPractice/";
16 |
17 | const btn_mouseHover = page.locator('#mousehover');
18 |
19 | const link_top = page.locator("[href='#top']");
20 |
21 | await page.goto(applicationURL);
22 |
23 | mouseHoverOnElement(btn_mouseHover,'Button Mouse Hover');
24 |
25 | console.log('Assertion for Element visible - Top ');
26 | await expect(link_top).toBeVisible();
27 |
28 | console.log('Assertion for Element text - Top ');
29 | await expect(link_top).toHaveText('Top');
30 |
31 | await waitForSomeTime(2);
32 |
33 | });
34 |
35 | async function mouseHoverOnElement(element,elementText) {
36 | console.log('Mouse Hover on: '+elementText);
37 | await element.hover();
38 | }
39 |
40 | async function clickOnElement(element,elementText) {
41 | console.log('Clicking on: '+elementText);
42 | await element.click();
43 | }
44 |
45 |
46 | async function waitForSomeTime(timeInSeconds) {
47 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
48 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/tests/Section_07_RS_UI_Tests/33_Handle_Frames.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | //NW -> Playwright unable to scroll to Frame element
14 | test('Section_07_RS_UI_Tests - RahulShettyAcademy Automation Practice App - Handle Frames', async ({page} )=> {
15 |
16 | const applicationURL = "https://rahulshettyacademy.com/AutomationPractice/";
17 |
18 | await page.goto(applicationURL);
19 |
20 | // courses-iframe -> This is the ID of this frame
21 | const frame_courses = page.frameLocator('#courses-iframe');
22 |
23 | // frame_courses has the acces of this frame (which has ID courses-iframe)
24 | // Perform operations on the elements in this Frame
25 | // li a[href*='lifetime-access'] -> This CSS seector is giving 2 elements count (1 visible, 1 hidden)
26 | await frame_courses.locator(" li a[href*='lifetime-access']:visible").click();
27 |
28 | const frame_courses_link_more = frame_courses.locator('.navigation .dropdown-toggle').first();
29 | mouseHoverOnElement(frame_courses_link_more,'Button Mouse Hover');
30 |
31 | await expect(frame_courses.locator("[href*='about-my-mission']").first()).toContainText('About us');
32 |
33 | await waitForSomeTime(6);
34 |
35 | });
36 |
37 | async function mouseHoverOnElement(element,elementText) {
38 | console.log('Mouse Hover on: '+elementText);
39 | await element.hover();
40 | }
41 |
42 | async function clickOnElement(element,elementText) {
43 | console.log('Clicking on: '+elementText);
44 | await element.click();
45 | }
46 |
47 |
48 | async function waitForSomeTime(timeInSeconds) {
49 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
50 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
51 | }
52 |
53 |
--------------------------------------------------------------------------------
/tests/Section_08_RS_UI_API_Tests/34_Skip_Login_Using_API.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect, request} = require('@playwright/test');
12 |
13 | let api_login_token;
14 |
15 | // This is an Javascript object
16 | const requestBody_Login = {
17 | userEmail: "testtmail95@gmail.com",
18 | userPassword: "HiRahul@123"
19 | };
20 |
21 | test.beforeAll(async() => {
22 |
23 | const apiContext = await request.newContext();
24 | const response_login = await apiContext.post(
25 | //Request URL
26 | 'https://www.rahulshettyacademy.com/api/ecom/auth/login',
27 | {
28 | //Request Body
29 | data: requestBody_Login
30 | })//post
31 |
32 | //Assertion for Response status code - 200
33 | expect(response_login.ok()).toBeTruthy();
34 |
35 | //Extract the Response Body in JSON format
36 | const response_login_json = await response_login.json();
37 |
38 | //Extract the token
39 | api_login_token = response_login_json.token;
40 |
41 | console.log('api_login_token: '+api_login_token);
42 |
43 | });
44 |
45 | test.beforeEach(async ({page} )=> {
46 |
47 | const applicationURL = "https://www.rahulshettyacademy.com/client/";
48 |
49 | // Injecting the Javascript snippet in Playwright
50 | page.addInitScript(value => {
51 | // Set the item in Local storage
52 | window.localStorage.setItem('token',value);
53 | },api_login_token);
54 |
55 | await page.goto(applicationURL);
56 | });
57 |
58 |
59 | test.afterEach(async() => {
60 | await waitForSomeTime(2);
61 | });
62 |
63 |
64 | test('Section_08_RS_UI_API_Tests - RahulShettyAcademy Client App - Skip Login using API call - Assert Tab: Home', async ({page} )=> {
65 | const tab_Home = page.locator("[routerlink='/dashboard/']");
66 | console.log('Assertions for tab: Home')
67 | await expect(tab_Home).toBeVisible();
68 | });
69 |
70 | test('Section_08_RS_UI_API_Tests - RahulShettyAcademy Client App - Skip Login using API call - Assert Tab: Sign Out', async ({page} )=> {
71 | const tab_SignOut = page.locator("[class='fa fa-sign-out']");
72 | console.log('Assertions for tab: Sign Out')
73 | await expect(tab_SignOut).toBeVisible();
74 | });
75 |
76 |
77 |
78 |
79 |
80 | async function mouseHoverOnElement(element,elementText) {
81 | console.log('Mouse Hover on: '+elementText);
82 | await element.hover();
83 | }
84 |
85 | async function clickOnElement(element,elementText) {
86 | console.log('Clicking on: '+elementText);
87 | await element.click();
88 | }
89 |
90 |
91 | async function waitForSomeTime(timeInSeconds) {
92 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
93 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
94 | }
95 |
96 |
--------------------------------------------------------------------------------
/tests/Section_08_RS_UI_API_Tests/35_Skip_Login_CreateOrder_AssertOrderHistoryPage.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect, request} = require('@playwright/test');
12 |
13 | let api_login_token;
14 | let orderID_from_createOrderAPI;
15 |
16 | // This is an Javascript object
17 | const requestBody_Login = {
18 | userEmail: "testtmail95@gmail.com",
19 | userPassword: "HiRahul@123"
20 | };
21 |
22 | test.beforeAll(async() => {
23 |
24 |
25 | /*************** Do Login - START ********************/
26 | const apiContext = await request.newContext();
27 | const response_login = await apiContext.post(
28 | //Request URL
29 | 'https://www.rahulshettyacademy.com/api/ecom/auth/login',
30 | {
31 | //Request Body
32 | data: requestBody_Login
33 | });//post
34 |
35 | //Assertion for Response status code - 200
36 | expect(response_login.ok()).toBeTruthy();
37 |
38 | //Extract the Response Body in JSON format
39 | const response_login_json = await response_login.json();
40 |
41 | //Extract the token
42 | api_login_token = response_login_json.token;
43 | console.log('api_login_token: '+api_login_token);
44 |
45 | /*************** Do Login - END ********************/
46 |
47 |
48 | /*************** Create Order - START ********************/
49 |
50 | // Do Login -> Place an Order
51 | // Authorization to be sent as Request Header
52 | // All the Products have unique ID
53 |
54 | // This is an Javascript object
55 | const requestBody_createOrder = {
56 | orders:[
57 | {
58 | country:"Cuba",
59 | //6262e9d9e26b7e1a10e89c04 -> Product ID for iPhone 13
60 | productOrderedId:"6262e9d9e26b7e1a10e89c04"
61 | }
62 | ]
63 | };
64 | const response_createOrder = await apiContext.post(
65 | //Request URL
66 | 'https://www.rahulshettyacademy.com/api/ecom/order/create-order',
67 | {
68 | //Request Body
69 | data: requestBody_createOrder,
70 | //Request Headers
71 | headers:{
72 | 'Authorization' : api_login_token,
73 | 'Content-Type' : 'application/json'
74 | }
75 | });//post
76 |
77 | //Extract the Response Body in JSON format
78 | const response_createOrder_json = await response_createOrder.json();
79 | console.log('Assertion for Response body - message');
80 | expect((response_createOrder_json.message === 'Order Placed Successfully')).toBeTruthy();
81 |
82 | console.log(response_createOrder_json);
83 | console.log(response_createOrder_json.message);
84 | //Extract the order ID
85 | orderID_from_createOrderAPI = response_createOrder_json.orders[0];
86 | console.log('orderID_from_createOrderAPI: '+orderID_from_createOrderAPI);
87 |
88 | /*************** Create Order - END ********************/
89 |
90 | });
91 |
92 | test.beforeEach(async ({page} )=> {
93 |
94 | const applicationURL = "https://www.rahulshettyacademy.com/client/";
95 |
96 | // Injecting the Javascript snippet in Playwright
97 | page.addInitScript(value => {
98 | // Set the item in Local storage
99 | window.localStorage.setItem('token',value);
100 | },api_login_token);
101 |
102 | await page.goto(applicationURL);
103 | });
104 |
105 |
106 | test.afterEach(async() => {
107 | await waitForSomeTime(2);
108 | });
109 |
110 |
111 | test('Section_08_RS_UI_API_Tests - RahulShettyAcademy Client App - Skip Login and Create Order using API call - Assert Order ID on Order History Page', async ({page} )=> {
112 | const tab_Orders = page.locator("[routerlink='/dashboard/myorders']");
113 | await tab_Orders.click();
114 |
115 | const rows_orderID = page.locator("tbody th").first();
116 | await rows_orderID.waitFor();
117 |
118 | const rows_orderID_all = page.locator("tbody th");
119 | const orderID_count = await rows_orderID_all.count();
120 | console.log(' -> orderID_count: '+orderID_count);
121 |
122 | for(let i=0;i orderID_from_createOrderAPI: '+orderID_from_createOrderAPI);
126 | console.log(' -> orderID_Table: '+orderID_Table);
127 |
128 | if(orderID_from_createOrderAPI.includes(orderID_Table)){
129 | console.log('Assertion for Order ID: '+orderID_Table+' on Order history page');
130 | await expect(rows_orderID_all.nth(i)).toBeVisible();
131 | await expect(rows_orderID_all.nth(i)).toHaveText(orderID_from_createOrderAPI);
132 | break;
133 | }//if
134 | }//for
135 |
136 | });
137 |
138 |
139 |
140 |
141 |
142 | async function mouseHoverOnElement(element,elementText) {
143 | console.log('Mouse Hover on: '+elementText);
144 | await element.hover();
145 | }
146 |
147 | async function clickOnElement(element,elementText) {
148 | console.log('Clicking on: '+elementText);
149 | await element.click();
150 | }
151 |
152 |
153 | async function waitForSomeTime(timeInSeconds) {
154 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
155 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
156 | }
157 |
158 |
--------------------------------------------------------------------------------
/tests/Section_08_RS_UI_API_Tests/36_Optimized_Skip_Login_From_Utils.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect, request} = require('@playwright/test');
12 | const {APIUtils} = require('../../utils/APIUtils');
13 |
14 | let api_login_token;
15 |
16 | // This is an Javascript object
17 | const requestBody_Login = {
18 | userEmail: "testtmail95@gmail.com",
19 | userPassword: "HiRahul@123"
20 | };
21 |
22 | test.beforeAll(async() => {
23 |
24 | const apiContext = await request.newContext();
25 | const apiUtils = new APIUtils(apiContext,requestBody_Login);
26 | api_login_token = await apiUtils.getAccessTokenForLogin();
27 | });
28 |
29 | test.beforeEach(async ({page} )=> {
30 |
31 | const applicationURL = "https://www.rahulshettyacademy.com/client/";
32 |
33 | // Injecting the Javascript snippet in Playwright
34 | page.addInitScript(value => {
35 | // Set the item in Local storage
36 | window.localStorage.setItem('token',value);
37 | },api_login_token);
38 |
39 | await page.goto(applicationURL);
40 | });
41 |
42 | test('Section_08_RS_UI_API_Tests - RahulShettyAcademy Client App - Optimized_Skip_Login_From_Utils', async ({page} )=> {
43 | const tab_Home = page.locator("[routerlink='/dashboard/']");
44 | console.log('Assertions for tab: Home')
45 | await expect(tab_Home).toBeVisible();
46 | });
47 |
48 |
49 | test.afterEach(async() => {
50 | await waitForSomeTime(2);
51 | });
52 |
53 |
54 |
55 | async function mouseHoverOnElement(element,elementText) {
56 | console.log('Mouse Hover on: '+elementText);
57 | await element.hover();
58 | }
59 |
60 | async function clickOnElement(element,elementText) {
61 | console.log('Clicking on: '+elementText);
62 | await element.click();
63 | }
64 |
65 |
66 | async function waitForSomeTime(timeInSeconds) {
67 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
68 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
69 | }
70 |
71 |
--------------------------------------------------------------------------------
/tests/Section_08_RS_UI_API_Tests/37_Optimized_Skip_Login_CreateOrder.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect, request} = require('@playwright/test');
12 | const {APIUtils} = require('../../utils/APIUtils');
13 |
14 | // let api_login_token;
15 | // let orderID_from_createOrderAPI;
16 | let response;
17 |
18 | // This is an Javascript object
19 | const requestBody_Login = {
20 | userEmail: "testtmail95@gmail.com",
21 | userPassword: "HiRahul@123"
22 | };
23 | // This is an Javascript object
24 | const requestBody_createOrder = {
25 | orders:[
26 | {
27 | country:"Cuba",
28 | //6262e9d9e26b7e1a10e89c04 -> Product ID for iPhone 13
29 | productOrderedId:"6262e9d9e26b7e1a10e89c04"
30 | }
31 | ]
32 | };
33 |
34 | test.beforeAll(async() => {
35 |
36 | const apiContext = await request.newContext();
37 | const apiUtils = new APIUtils(apiContext,requestBody_Login);
38 | response = await apiUtils.createOrder(requestBody_createOrder);
39 | });
40 |
41 | test.beforeEach(async ({page} )=> {
42 |
43 | const applicationURL = "https://www.rahulshettyacademy.com/client/";
44 |
45 | // Injecting the Javascript snippet in Playwright
46 | page.addInitScript(value => {
47 | // Set the item in Local storage
48 | window.localStorage.setItem('token',value);
49 | //},api_login_token);
50 | },response.token);
51 |
52 | await page.goto(applicationURL);
53 | });
54 |
55 |
56 | test.afterEach(async() => {
57 | await waitForSomeTime(2);
58 | });
59 |
60 |
61 | test('Section_08_RS_UI_API_Tests - RahulShettyAcademy Client App - Skip Login and Create Order using API call - Assert Order ID on Order History Page', async ({page} )=> {
62 | const tab_Orders = page.locator("[routerlink='/dashboard/myorders']");
63 | await tab_Orders.click();
64 |
65 | const rows_orderID = page.locator("tbody th").first();
66 | await rows_orderID.waitFor();
67 |
68 | const rows_orderID_all = page.locator("tbody th");
69 | const orderID_count = await rows_orderID_all.count();
70 | console.log(' -> orderID_count: '+orderID_count);
71 |
72 | for(let i=0;i orderID_from_createOrderAPI: '+orderID_from_createOrderAPI);
76 | console.log(' -> response.orderID: '+response.orderID);
77 | console.log(' -> orderID_Table: '+orderID_Table);
78 |
79 | //if(orderID_from_createOrderAPI.includes(orderID_Table)){
80 | if(response.orderID.includes(orderID_Table)){
81 | console.log('Assertion for Order ID: '+orderID_Table+' on Order history page');
82 | await expect(rows_orderID_all.nth(i)).toBeVisible();
83 | await expect(rows_orderID_all.nth(i)).toHaveText(response.orderID);
84 | break;
85 | }//if
86 | }//for
87 |
88 | });
89 |
90 |
91 |
92 | test('Section_08_RS_UI_Tests - Intentionally Failing - Wait and Assert the Page Title', async ({page} )=> {
93 |
94 | // Go to the application
95 | await page.goto("https://www.google.com/");
96 |
97 | // Get the Title and Print
98 | console.log(await page.title());
99 |
100 | //await delay(5000); //ReferenceError: delay is not defined
101 | await new Promise(resolve => setTimeout(resolve, 2000)); // 2 sec
102 |
103 | // Assert the Page Title
104 | await expect(page).toHaveTitle('Google1');
105 |
106 | });
107 |
108 |
109 | async function mouseHoverOnElement(element,elementText) {
110 | console.log('Mouse Hover on: '+elementText);
111 | await element.hover();
112 | }
113 |
114 | async function clickOnElement(element,elementText) {
115 | console.log('Clicking on: '+elementText);
116 | await element.click();
117 | }
118 |
119 |
120 | async function waitForSomeTime(timeInSeconds) {
121 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
122 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
123 | }
124 |
125 |
--------------------------------------------------------------------------------
/tests/Section_09_RS_UI_API_Tests/38_Use_Browser_StorageState_ToSkip_Login.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | const applicationURL = "https://www.rahulshettyacademy.com/client/";
14 |
15 | let webContext;
16 |
17 | test.beforeAll(async({browser})=>{
18 | const context = await browser.newContext();
19 | const page = await context.newPage();
20 |
21 | await page.goto(applicationURL);
22 | await page.locator('#userEmail').fill('testtmail95@gmail.com');
23 | await page.locator('#userPassword').fill('HiRahul@123');
24 | await page.locator('#login').click();
25 | await page.waitForLoadState('networkidle');
26 |
27 | // Store application stated in json file.
28 | await context.storageState({path:'state.json'});
29 |
30 | // Creating a webContext using this json file
31 | webContext = await browser.newContext({storageState:'state.json'});
32 |
33 | });//beforeAll
34 |
35 | test('Section_09_RS_UI_API_Tests - RahulShettyAcademy Client App Login - Skip Login using Browser Context (JSON file): Assert Tab - Home', async ()=> {
36 | const page = await webContext.newPage();
37 | page.goto(applicationURL);
38 | const tab_Home = page.locator("[routerlink='/dashboard/']");
39 | console.log('Assertions for tab: Home')
40 | await expect(tab_Home).toBeVisible();
41 |
42 | });
43 |
44 | test('Section_09_RS_UI_API_Tests - RahulShettyAcademy Client App Login - Skip Login using Browser Context (JSON file): Assert Tab - Sign Out', async ()=> {
45 | const page = await webContext.newPage();
46 | page.goto(applicationURL);
47 | const tab_SignOut = page.locator("[class='fa fa-sign-out']");
48 | console.log('Assertions for tab: Sign Out')
49 | await expect(tab_SignOut).toBeVisible();
50 | });
51 |
52 | test.afterEach(async() => {
53 | await waitForSomeTime(2);
54 | });//afterEach
55 |
56 | async function waitForSomeTime(timeInSeconds) {
57 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
58 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/tests/Section_09_RS_UI_API_Tests/39_NW_Intercept_API_Response_ToSee_NoOrderMessage.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | test('Section_09_RS_UI_API_Tests - RahulShettyAcademy Client App Login - Intercept_API_Response_ToSee_NoOrderMessage.spec', async ({page})=> {
14 |
15 | await page.goto('https://www.rahulshettyacademy.com/client/');
16 | await page.locator('#userEmail').fill('testtmail95@gmail.com');
17 | await page.locator('#userPassword').fill('HiRahul@123');
18 | waitForSomeTime(2);
19 | await page.locator('#login').click();
20 | //await page.waitForLoadState('networkidle');
21 |
22 | await page.route(
23 | // Request URL (When this URL will come, we want customied response)
24 | 'https://www.rahulshettyacademy.com/api/ecom/order/get-orders-for-customer/626551ebe26b7e1a10e8acbc',
25 | async route =>{
26 |
27 | // This is Real response
28 | const response = await page.request.fetch(route.request());
29 |
30 | // Got this response from application (From User account which has created no Orders)
31 | const responseBody_customized_For_NoOrderMessage = {
32 | message:"No Product in Cart"
33 | };
34 | // Intercepting the Response
35 | // We will send the customized Response to Browser and Browser will render the data on FrontEnd
36 | // API response -> ** Playwright intercepts here (Custom Response) ** ->Response Data send to Browser -> Browser renders UI
37 |
38 | route.fulfill({
39 | response,
40 | responseBody_customized_For_NoOrderMessage,
41 | });
42 | }
43 | );
44 |
45 | const tab_Orders = page.locator("button[routerlink='/dashboard/myorders']");
46 |
47 | console.log('Clicking on Orders Tab');
48 | await tab_Orders.click();
49 |
50 | });
51 |
52 | test.afterEach(async() => {
53 | await waitForSomeTime(6);
54 | });//afterEach
55 |
56 | async function waitForSomeTime(timeInSeconds) {
57 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
58 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/tests/Section_09_RS_UI_API_Tests/40_Intercept_API_Request_Message_YouAreNotAuthorized.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | test('Section_09_RS_UI_API_Tests - RahulShettyAcademy Client App Login - Intercept_API_Request_Message_YouAreNotAuthorized', async ({page})=> {
14 |
15 | await page.goto('https://www.rahulshettyacademy.com/client/');
16 | await page.locator('#userEmail').fill('testtmail95@gmail.com');
17 | await page.locator('#userPassword').fill('HiRahul@123');
18 | waitForSomeTime(2);
19 | await page.locator('#login').click();
20 | //await page.waitForLoadState('networkidle');
21 |
22 |
23 | const tab_Orders = page.locator("button[routerlink='/dashboard/myorders']");
24 | console.log('Clicking on Orders Tab');
25 | await tab_Orders.click();
26 |
27 | await page.route(
28 | // Request URL
29 | // 6266ccd2e26b7e1a10e8d1c5 -> ID of the product from testtmail95@gmail.com account
30 | 'https://www.rahulshettyacademy.com/api/ecom/order/get-orders-details?id=6266ccd2e26b7e1a10e8d1c5',
31 |
32 | // 6266ccd2e26b7e1a1232333 -> fake account
33 | route => route.continue({url:'https://www.rahulshettyacademy.com/api/ecom/order/get-orders-details?id=6266ccd2e26b7e1a1232333'})
34 | );
35 |
36 |
37 | const btn_view_firstOrder = page.locator("button:has-text('View')").first();
38 | console.log('Clicking on View button of first Order');
39 | await btn_view_firstOrder.click();
40 |
41 | console.log('Assertion for message: You are not authorize to view this order');
42 | const msg_youAreNotAuthorized = page.locator("p:has-text('You are not authorize to view this order')");
43 | await expect(msg_youAreNotAuthorized).toHaveText('You are not authorize to view this order');
44 |
45 | });
46 |
47 | test.afterEach(async() => {
48 | await waitForSomeTime(6);
49 | });//afterEach
50 |
51 | async function waitForSomeTime(timeInSeconds) {
52 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
53 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
54 | }
55 |
56 |
--------------------------------------------------------------------------------
/tests/Section_09_RS_UI_API_Tests/41_Intercept_API_Block_NetworkCalls.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | test('Section_09_RS_UI_API_Tests - RahulShettyAcademy Client App Login - Intercept_API_Block_NetworkCalls - BLOCK', async ({page})=> {
14 |
15 |
16 | // Intercept -> Block Network call
17 | await page.route(
18 | // Any Request URL which ends with CSS
19 | // We are blocking the CSS to be loaded in Browser
20 | '**/*.css',
21 |
22 | // abort() -> it will stop the API call to reach to Browser
23 | route => route.abort()
24 | );
25 |
26 | await page.goto('https://www.rahulshettyacademy.com/loginpagePractise/');
27 |
28 | });
29 |
30 | test('Section_09_RS_UI_API_Tests - RahulShettyAcademy Client App Login - Intercept_API_Block_NetworkCalls - DO NOT BLOCK', async ({page})=> {
31 |
32 |
33 | // // Intercept -> Block Network call
34 | // await page.route(
35 | // // Any Request URL which ends with CSS
36 | // // We are blocking the CSS to be loaded in Browser
37 | // '**/*.css',
38 |
39 | // // abort() -> it will stop the API call to reach to Browser
40 | // route => route.abort()
41 | // );
42 |
43 | await page.goto('https://www.rahulshettyacademy.com/loginpagePractise/');
44 |
45 | });
46 |
47 |
48 | test.afterEach(async() => {
49 | await waitForSomeTime(6);
50 | });//afterEach
51 |
52 | async function waitForSomeTime(timeInSeconds) {
53 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
54 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/tests/Section_09_RS_UI_API_Tests/42_Intercept_API_Block_Images_ToLoad.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | test('Section_09_RS_UI_API_Tests - RahulShettyAcademy Client App Login - Intercept_API_Block_Images_ToLoad', async ({page})=> {
14 |
15 | // Intercept -> Block Network call
16 | await page.route(
17 | // Any Request URL which ends with CSS, jpg, png, jpeg
18 | // We are blocking the CSS, jpg, png, jpeg to be loaded in Browser
19 | '**/*.{css,jpg,png,jpeg}',
20 |
21 | // abort() -> it will stop the API call to reach to Browser
22 | route => route.abort()
23 | );
24 |
25 | await page.goto('https://www.rahulshettyacademy.com/loginpagePractise/');
26 |
27 | await page.locator('#username').type('rahulshettyacademy');
28 | await page.locator('#password').type('learning');
29 | console.log('Click on Sign In button');
30 | await page.locator('#signInBtn').click();
31 |
32 | });
33 |
34 | test.afterEach(async() => {
35 | await waitForSomeTime(6);
36 | });//afterEach
37 |
38 | async function waitForSomeTime(timeInSeconds) {
39 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
40 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
41 | }
42 |
43 |
--------------------------------------------------------------------------------
/tests/Section_09_RS_UI_API_Tests/43_API_Log_RequestURLs_ResponseStatusCode.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | test('Section_09_RS_UI_API_Tests - RahulShettyAcademy Client App Login - API_Log_RequestURLs_ResponseStatusCode', async ({page})=> {
14 |
15 | //on() -> It is an event
16 | page.on('request', request=>
17 | console.log(request.url())
18 | );
19 |
20 | page.on('response', response=>
21 | console.log(response.url()," | ", response.status())
22 | );
23 |
24 | await page.goto('https://www.rahulshettyacademy.com/loginpagePractise/');
25 | await page.locator('#username').type('rahulshettyacademy');
26 |
27 | });
28 |
29 | test.afterEach(async() => {
30 | await waitForSomeTime(6);
31 | });//afterEach
32 |
33 | async function waitForSomeTime(timeInSeconds) {
34 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
35 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/tests/Section_10_RS_UI_Tests/44_Screenshot_Element_VisibleScreen_FullPage.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | test('Section_10_RS_UI_Tests - RahulShettyAcademy Automation Practice App - Screenshot', async ({page} )=> {
14 |
15 | const applicationURL = "https://rahulshettyacademy.com/AutomationPractice/";
16 |
17 | const txtBox_hide_show_example = page.locator('#displayed-text');
18 | const btn_hide = page.locator('#hide-textbox');
19 |
20 | await page.goto(applicationURL);
21 |
22 | console.log('Assertion for TextBox visible');
23 | await expect(txtBox_hide_show_example).toBeVisible();
24 |
25 | clickOnElement(btn_hide);
26 |
27 | await waitForSomeTime(2);
28 |
29 | console.log('Assertion for TextBox hidden');
30 | await expect(txtBox_hide_show_example).toBeHidden();
31 |
32 | await waitForSomeTime(2);
33 |
34 | console.log('Sreenshot: Full Page');
35 | await page.screenshot({path:'./screenshots/Screenshot_FullPage.png',fullPage: true });
36 |
37 | console.log('Sreenshot: Visible Screen');
38 | await page.screenshot({path:'./screenshots/Screenshot_VisibleScreen.png'});
39 |
40 | console.log('Sreenshot: Element');
41 | await btn_hide.screenshot({path:'./screenshots/Screenshot_Element.png'});
42 |
43 | });
44 |
45 |
46 | async function clickOnElement(element,elementText) {
47 | console.log('Clicking on: '+elementText);
48 | await element.click();
49 | }
50 |
51 |
52 | async function waitForSomeTime(timeInSeconds) {
53 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
54 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/tests/Section_10_RS_UI_Tests/45_Screenshots_Comparison.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 |
13 | test('Section_10_RS_UI_Tests - Screenshots_Comparison', async ({page} )=> {
14 | await page.goto('https://uk.flightaware.com/');
15 | expect(await page.screenshot()).toMatchSnapshot('uk.flightaware-prod.png');
16 |
17 | });
18 |
19 |
--------------------------------------------------------------------------------
/tests/Section_10_RS_UI_Tests/45_Screenshots_Comparison.spec.js-snapshots/uk-flightaware-prod-chromium-darwin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/Playwright_JS/253a3370309b6d649bed58ef7948cff1be337349/tests/Section_10_RS_UI_Tests/45_Screenshots_Comparison.spec.js-snapshots/uk-flightaware-prod-chromium-darwin.png
--------------------------------------------------------------------------------
/tests/Section_10_RS_UI_Tests/45_Screenshots_Comparison.spec.js-snapshots/uk-flightaware-prod-webkit-darwin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rajatt95/Playwright_JS/253a3370309b6d649bed58ef7948cff1be337349/tests/Section_10_RS_UI_Tests/45_Screenshots_Comparison.spec.js-snapshots/uk-flightaware-prod-webkit-darwin.png
--------------------------------------------------------------------------------
/tests/Section_11_RS_UI_Tests_POM/46_POM_Login_Assert_Msg_LoginSuccess.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | const {test,expect} = require('@playwright/test');
12 | //const { default: CommonUtils } = require('../../utils/CommonUtils');
13 | //import commonUtils from '../../utils/CommonUtils'
14 | const {CommonUtils}=require('../../utils/CommonUtils');
15 | const {LoginPage} = require('../../pageObjects/LoginPage');
16 | const {DashboardPage} = require('../../pageObjects/DashboardPage');
17 |
18 |
19 | test('Section_11_RS_UI_Tests - RahulShettyAcademy Client App Login - POM_Login_Assert_Msg_LoginSuccess', async ({page} )=> {
20 |
21 | const data_login_username = "testtmail95@gmail.com";
22 | const data_login_password = "HiRahul@123";
23 |
24 | /****************** Login Page - START *******************/
25 |
26 | const loginPage = new LoginPage(page);
27 | await loginPage.goToApplication();
28 | await loginPage.loginToApplication(data_login_username,data_login_password);
29 |
30 | /****************** Login Page - END *******************/
31 |
32 | /****************** Dashboard Page - START *******************/
33 | const dashboardPage = new DashboardPage(page);
34 |
35 | console.log('Assertions for message: Login Successfully')
36 | await expect(dashboardPage.getMsg_LoginSuccess()).toBeVisible();
37 | await expect(dashboardPage.getMsg_LoginSuccess()).toHaveText('Login Successfully');
38 | await expect(dashboardPage.getMsg_LoginSuccess()).toContainText('Successfully');
39 |
40 | /****************** Dashboard Page - END *******************/
41 |
42 | //await page.pause();
43 | });
44 |
45 | test.afterEach(async() => {
46 | await new CommonUtils().waitForSomeTime(5);
47 | });//afterEach
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/tests/Section_11_RS_UI_Tests_POM/47_POM_Login_Assert_Msg_AddToCart.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | const {test,expect} = require('@playwright/test');
14 | //const { default: CommonUtils } = require('../../utils/CommonUtils');
15 | //import commonUtils from '../../utils/CommonUtils'
16 | const {CommonUtils}=require('../../utils/CommonUtils');
17 | const {LoginPage} = require('../../pageObjects/LoginPage');
18 | const {DashboardPage} = require('../../pageObjects/DashboardPage');
19 |
20 |
21 | test('Section_11_RS_UI_Tests - RahulShettyAcademy Client App Login - POM_Login_Assert_Msg_LoginSuccess', async ({page} )=> {
22 |
23 | const data_login_username = "testtmail95@gmail.com";
24 | const data_login_password = "HiRahul@123";
25 |
26 | /****************** Login Page - START *******************/
27 |
28 | const loginPage = new LoginPage(page);
29 | await loginPage.goToApplication();
30 | await loginPage.loginToApplication(data_login_username,data_login_password);
31 |
32 | /****************** Login Page - END *******************/
33 |
34 | /****************** Dashboard Page - START *******************/
35 | const dashboardPage = new DashboardPage(page);
36 | const product_ToAdd='iphone 13 pro';
37 | await dashboardPage.searchProduct_And_AddToCart(product_ToAdd);
38 |
39 | console.log('Assertions for message: Product Added To Cart')
40 | await expect(dashboardPage.getMsg_ProductAdded_ToCart()).toBeVisible();
41 | await expect(dashboardPage.getMsg_ProductAdded_ToCart()).toHaveText('Product Added To Cart');
42 | await expect(dashboardPage.getMsg_ProductAdded_ToCart()).toContainText('Added To Cart');
43 |
44 | /****************** Dashboard Page - END *******************/
45 |
46 | //await page.pause();
47 | });
48 |
49 | test.afterEach(async() => {
50 | await new CommonUtils().waitForSomeTime(5);
51 | });//afterEach
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/tests/Section_11_RS_UI_Tests_POM/48_NW_POM_Login_Assert_ProductName_OnCartPage.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | const {test,expect} = require('@playwright/test');
14 | //const { default: CommonUtils } = require('../../utils/CommonUtils');
15 | //import commonUtils from '../../utils/CommonUtils'
16 | const {CommonUtils}=require('../../utils/CommonUtils');
17 | const {LoginPage} = require('../../pageObjects/LoginPage');
18 | const {DashboardPage} = require('../../pageObjects/DashboardPage');
19 | const {CartPage} = require('../../pageObjects/CartPage');
20 |
21 |
22 | test('Section_11_RS_UI_Tests - RahulShettyAcademy Client App Login - POM_Login_Assert_ProductName_OnCartPage', async ({page} )=> {
23 |
24 | const data_login_username = "testtmail95@gmail.com";
25 | const data_login_password = "HiRahul@123";
26 |
27 | /****************** Login Page - START *******************/
28 |
29 | const loginPage = new LoginPage(page);
30 | await loginPage.goToApplication();
31 | await loginPage.loginToApplication(data_login_username,data_login_password);
32 |
33 | /****************** Login Page - END *******************/
34 |
35 | /****************** Dashboard Page - START *******************/
36 | const dashboardPage = new DashboardPage(page);
37 | const product_ToAdd='iphone 13 pro';
38 | await dashboardPage.searchProduct_And_AddToCart(product_ToAdd);
39 | await dashboardPage.navigateToCart();
40 |
41 | /****************** Dashboard Page - END *******************/
42 |
43 | /****************** Cart Page - START *******************/
44 |
45 | const cartPage = new CartPage(page);
46 |
47 | console.log("Assertion for Product name on Cart Page")
48 | await expect(cartPage.getProductName()).toHaveText(product_ToAdd);
49 | console.log('cartPage.getProductNameText(): '+ await cartPage.getProductNameText());
50 |
51 | // console.log('cartPage.getProductName().textContent(): '+cartPage.getProductName().textContent());
52 | // const productNameStatus = await cartPage.getProductName().isVisible();
53 | // console.log('productNameStatus: '+productNameStatus)
54 | // expect(productNameStatus).toBeTruthy();
55 | // await expect(cartPage.getProductName()).toHaveText(product_ToAdd);
56 |
57 | /****************** Cart Page - END *******************/
58 |
59 | //await page.pause();
60 | });
61 |
62 | test.afterEach(async() => {
63 | await new CommonUtils().waitForSomeTime(5);
64 | });//afterEach
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/tests/Section_11_RS_UI_Tests_POM/49_POM_Login_Assert_Email_OnCheckoutPage.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | const {test,expect} = require('@playwright/test');
14 | //const { default: CommonUtils } = require('../../utils/CommonUtils');
15 | //import commonUtils from '../../utils/CommonUtils'
16 | const {CommonUtils}=require('../../utils/CommonUtils');
17 | const {LoginPage} = require('../../pageObjects/LoginPage');
18 | const {DashboardPage} = require('../../pageObjects/DashboardPage');
19 | const {CartPage} = require('../../pageObjects/CartPage');
20 | const {CheckoutPage} = require('../../pageObjects/CheckoutPage');
21 |
22 |
23 | test('Section_11_RS_UI_Tests - RahulShettyAcademy Client App Login - POM_Login_Assert_Email_OnCheckoutPage', async ({page} )=> {
24 |
25 | const data_login_username = "testtmail95@gmail.com";
26 | const data_login_password = "HiRahul@123";
27 |
28 | /****************** Login Page - START *******************/
29 |
30 | const loginPage = new LoginPage(page);
31 | await loginPage.goToApplication();
32 | await loginPage.loginToApplication(data_login_username,data_login_password);
33 |
34 | /****************** Login Page - END *******************/
35 |
36 | /****************** Dashboard Page - START *******************/
37 | const dashboardPage = new DashboardPage(page);
38 | const product_ToAdd='iphone 13 pro';
39 | await dashboardPage.searchProduct_And_AddToCart(product_ToAdd);
40 | await dashboardPage.navigateToCart();
41 |
42 | /****************** Dashboard Page - END *******************/
43 |
44 | /****************** Cart Page - START *******************/
45 |
46 | const cartPage = new CartPage(page);
47 | cartPage.goToCheckoutPage();
48 |
49 | /****************** Cart Page - END *******************/
50 |
51 | /****************** Checkout Page - START *******************/
52 |
53 | /***** Assertion for Email ID - START ******/
54 | const checkoutPage = new CheckoutPage(page);
55 |
56 | console.log('Assertion for EMail ID on Checkout page');
57 | console.log('checkoutPage.get_TxtBox_Email().textContent(): '+checkoutPage.get_TxtBox_Email().textContent());
58 | await expect(checkoutPage.get_TxtBox_Email()).toContainText(data_login_username);
59 |
60 | /***** Assertion for Email ID - END ******/
61 |
62 | /****************** Checkout Page - END *******************/
63 |
64 | //await page.pause();
65 | });
66 |
67 | test.afterEach(async() => {
68 | await new CommonUtils().waitForSomeTime(5);
69 | });//afterEach
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/tests/Section_11_RS_UI_Tests_POM/50_NW_POM_Login_Dropdown_AutoSuggestive.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | const {test,expect} = require('@playwright/test');
14 | //const { default: CommonUtils } = require('../../utils/CommonUtils');
15 | //import commonUtils from '../../utils/CommonUtils'
16 | const {CommonUtils}=require('../../utils/CommonUtils');
17 | const {LoginPage} = require('../../pageObjects/LoginPage');
18 | const {DashboardPage} = require('../../pageObjects/DashboardPage');
19 | const {CartPage} = require('../../pageObjects/CartPage');
20 | const {CheckoutPage} = require('../../pageObjects/CheckoutPage');
21 |
22 |
23 | test('Section_11_RS_UI_Tests - RahulShettyAcademy Client App Login - POM_Login_Dropdown_AutoSuggestive', async ({page} )=> {
24 |
25 | const data_login_username = "testtmail95@gmail.com";
26 | const data_login_password = "HiRahul@123";
27 |
28 | /****************** Login Page - START *******************/
29 |
30 | const loginPage = new LoginPage(page);
31 | await loginPage.goToApplication();
32 | await loginPage.loginToApplication(data_login_username,data_login_password);
33 |
34 | /****************** Login Page - END *******************/
35 |
36 | /****************** Dashboard Page - START *******************/
37 | const dashboardPage = new DashboardPage(page);
38 | const product_ToAdd='iphone 13 pro';
39 | await dashboardPage.searchProduct_And_AddToCart(product_ToAdd);
40 | await dashboardPage.navigateToCart();
41 |
42 | /****************** Dashboard Page - END *******************/
43 |
44 | /****************** Cart Page - START *******************/
45 |
46 | const cartPage = new CartPage(page);
47 | cartPage.goToCheckoutPage();
48 |
49 | /****************** Cart Page - END *******************/
50 |
51 | /****************** Checkout Page - START *******************/
52 |
53 | /***** Assertion for Email ID - START ******/
54 | const checkoutPage = new CheckoutPage(page);
55 |
56 | console.log('Assertion for EMail ID on Checkout page');
57 | console.log('checkoutPage.get_TxtBox_Email().textContent(): '+checkoutPage.get_TxtBox_Email().textContent());
58 | await expect(checkoutPage.get_TxtBox_Email()).toContainText(data_login_username);
59 |
60 | /***** Assertion for Email ID - END ******/
61 |
62 | /***** Select value from Dropdown - START ******/
63 |
64 | const country_ToSearch = 'India';
65 | checkoutPage.searchCountryAndSelect('ind',country_ToSearch);
66 | // console.log('Commented the Dropdown - Auto-Suggestive');
67 | /***** Select value from Dropdown - END ******/
68 |
69 | // const btn_placeOrder = page.locator('.action__submit');
70 | // console.log('Clickin on Place Order button');
71 | // await btn_placeOrder.click();
72 |
73 | /****************** Checkout Page - END *******************/
74 |
75 | await page.pause();
76 | });
77 |
78 | test.afterEach(async() => {
79 | await new CommonUtils().waitForSomeTime(5);
80 | });//afterEach
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/tests/Section_11_RS_UI_Tests_POM/51_POM_Optimized_Login_Assert_Email_OnCheckoutPage.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | const {test,expect} = require('@playwright/test');
14 | const {CommonUtils}=require('../../utils/CommonUtils');
15 | // const {LoginPage} = require('../../pageObjects/LoginPage');
16 | // const {DashboardPage} = require('../../pageObjects/DashboardPage');
17 | // const {CartPage} = require('../../pageObjects/CartPage');
18 | // const {CheckoutPage} = require('../../pageObjects/CheckoutPage');
19 | const {POM_Manager} = require('../../pageObjects/POM_Manager');
20 |
21 |
22 | test('Section_11_RS_UI_Tests - RahulShettyAcademy Client App Login - POM_Optimized_Login_Assert_Email_OnCheckoutPage', async ({page} )=> {
23 |
24 | const data_login_username = "testtmail95@gmail.com";
25 | const data_login_password = "HiRahul@123";
26 |
27 | const pom_Manager = new POM_Manager(page);
28 | /****************** Login Page - START *******************/
29 |
30 | //const loginPage = new LoginPage(page);
31 | const loginPage = pom_Manager.getLoginPage();
32 | await loginPage.goToApplication();
33 | await loginPage.loginToApplication(data_login_username,data_login_password);
34 |
35 | /****************** Login Page - END *******************/
36 |
37 | /****************** Dashboard Page - START *******************/
38 | //const dashboardPage = new DashboardPage(page);
39 | const dashboardPage = pom_Manager.getDashboardPage();
40 | const product_ToAdd='iphone 13 pro';
41 | await dashboardPage.searchProduct_And_AddToCart(product_ToAdd);
42 | await dashboardPage.navigateToCart();
43 |
44 | /****************** Dashboard Page - END *******************/
45 |
46 | /****************** Cart Page - START *******************/
47 |
48 | //const cartPage = new CartPage(page);
49 | const cartPage = pom_Manager.getCartPage();
50 |
51 | cartPage.goToCheckoutPage();
52 |
53 | /****************** Cart Page - END *******************/
54 |
55 | /****************** Checkout Page - START *******************/
56 |
57 | /***** Assertion for Email ID - START ******/
58 | //const checkoutPage = new CheckoutPage(page);
59 | const checkoutPage = pom_Manager.getCheckoutPage();
60 |
61 | console.log('Assertion for EMail ID on Checkout page');
62 | console.log('checkoutPage.get_TxtBox_Email().textContent(): '+checkoutPage.get_TxtBox_Email().textContent());
63 | await expect(checkoutPage.get_TxtBox_Email()).toContainText(data_login_username);
64 |
65 | /***** Assertion for Email ID - END ******/
66 |
67 | /****************** Checkout Page - END *******************/
68 |
69 | //await page.pause();
70 | });
71 |
72 | test.afterEach(async() => {
73 | await new CommonUtils().waitForSomeTime(5);
74 | });//afterEach
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/tests/Section_11_RS_UI_Tests_POM/53_POM_Optimized_Login_TestData_JSON.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | const {test,expect} = require('@playwright/test');
14 | const {CommonUtils}=require('../../utils/CommonUtils');
15 | const {POM_Manager} = require('../../pageObjects/POM_Manager');
16 |
17 | // JSON -> String -> JS Object
18 | const credentials_login_dataSet = JSON.parse(JSON.stringify(require('../../testData/credentials_login.json')));
19 |
20 | test('Section_11_RS_UI_Tests - POM_Optimized_Login_TestData_JSON', async ({page} )=> {
21 |
22 | // const data_login_username = "testtmail95@gmail.com";
23 | // const data_login_password = "HiRahul@123";
24 |
25 | const data_login_username = credentials_login_dataSet.valid_username_1;
26 | const data_login_password = credentials_login_dataSet.valid_password_1;
27 |
28 | const pom_Manager = new POM_Manager(page);
29 | /****************** Login Page - START *******************/
30 |
31 | //const loginPage = new LoginPage(page);
32 | const loginPage = pom_Manager.getLoginPage();
33 | await loginPage.goToApplication();
34 | await loginPage.loginToApplication(data_login_username,data_login_password);
35 |
36 | /****************** Login Page - END *******************/
37 |
38 | /****************** Dashboard Page - START *******************/
39 | const dashboardPage = pom_Manager.getDashboardPage();
40 |
41 | console.log('Assertions for message: Login Successfully')
42 | await expect(dashboardPage.getMsg_LoginSuccess()).toBeVisible();
43 | await expect(dashboardPage.getMsg_LoginSuccess()).toHaveText('Login Successfully');
44 | await expect(dashboardPage.getMsg_LoginSuccess()).toContainText('Successfully');
45 |
46 | /****************** Dashboard Page - END *******************/
47 | //await page.pause();
48 | });
49 |
50 | test.afterEach(async() => {
51 | await new CommonUtils().waitForSomeTime(5);
52 | });//afterEach
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/tests/Section_11_RS_UI_Tests_POM/54_POM_Optimized_Login_MultipleDataSet_JSON.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | const {test,expect} = require('@playwright/test');
14 | const {CommonUtils}=require('../../utils/CommonUtils');
15 | const {POM_Manager} = require('../../pageObjects/POM_Manager');
16 |
17 | // JSON -> String -> JS Object
18 | const credentials_login_multipleDataSet = JSON.parse(JSON.stringify(require('../../testData/credentials_login_multipleDataSet.json')));
19 |
20 | //Iterating through an Array
21 | for(const data of credentials_login_multipleDataSet){
22 |
23 | test(`Section_11_RS_UI_Tests - POM_Optimized_Login_MultipleDataSet_JSON with Credentials: ${data.username} and ${data.password}`, async ({page} )=> {
24 |
25 | const data_login_username = data.username;
26 | const data_login_password = data.password;
27 |
28 | const pom_Manager = new POM_Manager(page);
29 | console.log('******************');
30 |
31 | /****************** Login Page - START *******************/
32 | const loginPage = pom_Manager.getLoginPage();
33 | await loginPage.goToApplication();
34 | await loginPage.loginToApplication(data_login_username,data_login_password);
35 |
36 | /****************** Login Page - END *******************/
37 | console.log('******************');
38 | });//test
39 | }//for
40 |
41 | test.afterEach(async() => {
42 | await new CommonUtils().waitForSomeTime(2);
43 | });//afterEach
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/tests/Section_11_RS_UI_Tests_POM/55_POM_Optimized_Login_TestData_Fixture.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | const {test,expect} = require('@playwright/test');
14 | const {CommonUtils}=require('../../utils/CommonUtils');
15 | const {POM_Manager} = require('../../pageObjects/POM_Manager');
16 | const {customtest} = require('../../utils/test-base');
17 |
18 | customtest('Section_11_RS_UI_Tests - POM_Optimized_Login_TestData_FixtureFile', async ({page, testData_Login})=> {
19 |
20 | const data_login_username = testData_Login.username;
21 | const data_login_password = testData_Login.password;
22 |
23 | const pom_Manager = new POM_Manager(page);
24 | /****************** Login Page - START *******************/
25 |
26 | //const loginPage = new LoginPage(page);
27 | const loginPage = pom_Manager.getLoginPage();
28 | await loginPage.goToApplication();
29 | await loginPage.loginToApplication(data_login_username,data_login_password);
30 |
31 | /****************** Login Page - END *******************/
32 |
33 | });
34 |
35 | test.afterEach(async() => {
36 | await new CommonUtils().waitForSomeTime(5);
37 | });//afterEach
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/tests/Section_11_RS_UI_Tests_POM/P_52_NW_POM_Optimized_CompleteTillOrderHistory.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | const {test,expect} = require('@playwright/test');
14 | const {CommonUtils}=require('../../utils/CommonUtils');
15 | // const {LoginPage} = require('../../pageObjects/LoginPage');
16 | // const {DashboardPage} = require('../../pageObjects/DashboardPage');
17 | // const {CartPage} = require('../../pageObjects/CartPage');
18 | // const {CheckoutPage} = require('../../pageObjects/CheckoutPage');
19 | const {POM_Manager} = require('../../pageObjects/POM_Manager');
20 |
21 |
22 | test('Section_11_RS_UI_Tests - RahulShettyAcademy Client App Login - POM_Optimized_Login_Assert_Email_OnCheckoutPage', async ({page} )=> {
23 |
24 | const data_login_username = "testtmail95@gmail.com";
25 | const data_login_password = "HiRahul@123";
26 |
27 | const pom_Manager = new POM_Manager(page);
28 | /****************** Login Page - START *******************/
29 |
30 | //const loginPage = new LoginPage(page);
31 | const loginPage = pom_Manager.getLoginPage();
32 | await loginPage.goToApplication();
33 | await loginPage.loginToApplication(data_login_username,data_login_password);
34 |
35 | /****************** Login Page - END *******************/
36 |
37 | /****************** Dashboard Page - START *******************/
38 | //const dashboardPage = new DashboardPage(page);
39 | const dashboardPage = pom_Manager.getDashboardPage();
40 | const product_ToAdd='iphone 13 pro';
41 | await dashboardPage.searchProduct_And_AddToCart(product_ToAdd);
42 | await dashboardPage.navigateToCart();
43 |
44 | /****************** Dashboard Page - END *******************/
45 |
46 | /****************** Cart Page - START *******************/
47 |
48 | //const cartPage = new CartPage(page);
49 | const cartPage = pom_Manager.getCartPage();
50 |
51 | cartPage.goToCheckoutPage();
52 |
53 | /****************** Cart Page - END *******************/
54 |
55 | /****************** Checkout Page - START *******************/
56 |
57 | /***** Assertion for Email ID - START ******/
58 | //const checkoutPage = new CheckoutPage(page);
59 | const checkoutPage = pom_Manager.getCheckoutPage();
60 |
61 | console.log('Assertion for EMail ID on Checkout page');
62 | console.log('checkoutPage.get_TxtBox_Email().textContent(): '+checkoutPage.get_TxtBox_Email().textContent());
63 | await expect(checkoutPage.get_TxtBox_Email()).toContainText(data_login_username);
64 |
65 | /***** Assertion for Email ID - END ******/
66 |
67 | /****************** Checkout Page - END *******************/
68 |
69 | //await page.pause();
70 | });
71 |
72 | test.afterEach(async() => {
73 | await new CommonUtils().waitForSomeTime(5);
74 | });//afterEach
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/tests/Section_11_RS_UI_Tests_POM/P_54_POM_Optimized_Login_MultipleDataSet_JSON.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | const {test,expect} = require('@playwright/test');
14 | const {CommonUtils}=require('../../utils/CommonUtils');
15 | const {POM_Manager} = require('../../pageObjects/POM_Manager');
16 |
17 | // JSON -> String -> JS Object
18 | const credentials_login_multipleDataSet = JSON.parse(JSON.stringify(require('../../testData/credentials_login_multipleDataSet.json')));
19 |
20 | //Iterating through an Array
21 | for(const data of credentials_login_multipleDataSet){
22 |
23 | test(`Section_11_RS_UI_Tests - POM_Optimized_Login_MultipleDataSet_JSON with Credentials: ${data.username} and ${data.password}`, async ({page} )=> {
24 |
25 | const data_login_username = data.username;
26 | const data_login_password = data.password;
27 |
28 | const pom_Manager = new POM_Manager(page);
29 | console.log('******************');
30 |
31 | /****************** Login Page - START *******************/
32 | const loginPage = pom_Manager.getLoginPage();
33 | await loginPage.goToApplication();
34 | await loginPage.loginToApplication(data_login_username,data_login_password);
35 |
36 | // PENDING
37 | console.log('Assertion for Error message(Incorrect username/password.)')
38 | await expect(loginPage.getMsg_Incorrect_username_password()).toBeVisible();
39 | await expect(dashboardPage.getMsg_Incorrect_username_password()).toHaveText('Incorrect username/password.');
40 | /****************** Login Page - END *******************/
41 | console.log('******************');
42 | });//test
43 | }//for
44 |
45 | test.afterEach(async() => {
46 | await new CommonUtils().waitForSomeTime(5);
47 | });//afterEach
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/tests/Section_13_RS_UI_Tests/55_RetryFailedTestCase_Assert_Title.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | const {test,expect} = require('@playwright/test');
14 |
15 | test('Section_13_RS_UI_Tests - Retry Failed TestCase_AssertTitle', async ({page} )=> {
16 |
17 | // Go to the application
18 | await page.goto("https://www.google.com/");
19 |
20 | // Get the Title and Print
21 | console.log(await page.title());
22 |
23 | // Assert the Page Title
24 | await expect(page).toHaveTitle('Googlem');
25 |
26 | });
27 |
--------------------------------------------------------------------------------
/tests/Section_13_RS_UI_Tests/56_RetryFailedTestCase_Type_And_Click.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | const {test,expect} = require('@playwright/test');
14 |
15 | test('Section_13_RS_UI_Tests - RetryFailedTestCase_Type_And_Click', async ({page} )=> {
16 |
17 | // Go to the application
18 | await page.goto("https://www.rahulshettyacademy.com/loginpagePractise/");
19 |
20 | // Get the Title and Print
21 | console.log(await page.title());
22 |
23 | // Assert the Page Title
24 | await expect(page).toHaveTitle('LoginPage Practise | Rahul Shetty Academy');
25 |
26 | //Playwright will look for the element having CSS selector '#username' and once
27 | // it finds the element, then, it will fill 'rahulshetty'
28 | //await page.locator('#username').type('rahulshettyacademy');
29 | await page.locator('#username123').type('rahulshetty');
30 |
31 | await page.locator('#password').type('learning');
32 |
33 | console.log('Click on Sign In button');
34 | await page.locator('#signInBtn').click();
35 |
36 | //await delay(5000); //ReferenceError: delay is not defined
37 | await new Promise(resolve => setTimeout(resolve, 5000)); // 5 sec
38 |
39 | });
40 |
--------------------------------------------------------------------------------
/tests/Section_13_RS_UI_Tests/57_Assert_Title_4_TestsInOneSpecFile_Parallel.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | const {test,expect} = require('@playwright/test');
14 |
15 | test.describe.configure( { mode : 'parallel' } );
16 |
17 | test('Section_13_RS_UI_Tests - Playwright Test #1 - Assert_Title_4_TestsInOneSpecFile', async ({page} )=> {
18 |
19 | // Go to the application
20 | await page.goto("https://www.google.com/");
21 |
22 | // Get the Title and Print
23 | console.log(await page.title());
24 |
25 | // Assert the Page Title
26 | await expect(page).toHaveTitle('Google1');
27 |
28 | });
29 |
30 | test('Section_13_RS_UI_Tests - Playwright Test #2 - Assert_Title_4_TestsInOneSpecFile', async ({page} )=> {
31 |
32 | // Go to the application
33 | await page.goto("https://www.google.com/");
34 |
35 | // Get the Title and Print
36 | console.log(await page.title());
37 |
38 | // Assert the Page Title
39 | await expect(page).toHaveTitle('Google');
40 |
41 | });
42 |
43 | test('Section_13_RS_UI_Tests - Playwright Test #3 - Assert_Title_4_TestsInOneSpecFile', async ({page} )=> {
44 |
45 | // Go to the application
46 | await page.goto("https://www.google.com/");
47 |
48 | // Get the Title and Print
49 | console.log(await page.title());
50 |
51 | // Assert the Page Title
52 | await expect(page).toHaveTitle('Google1');
53 |
54 | });
55 |
56 | test('Section_13_RS_UI_Tests - Playwright Test #4 - Assert_Title_4_TestsInOneSpecFile', async ({page} )=> {
57 |
58 | // Go to the application
59 | await page.goto("https://www.google.com/");
60 |
61 | // Get the Title and Print
62 | console.log(await page.title());
63 |
64 | // Assert the Page Title
65 | await expect(page).toHaveTitle('Google');
66 |
67 | });
--------------------------------------------------------------------------------
/tests/Section_13_RS_UI_Tests/58_Assert_Title_4_TestsInOneSpecFile_Default.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | const {test,expect} = require('@playwright/test');
14 |
15 | //test.describe.configure( { mode : 'serial' } );
16 |
17 | test('Section_13_RS_UI_Tests - Playwright Test #1 - Assert_Title_4_TestsInOneSpecFile', async ({page} )=> {
18 |
19 | // Go to the application
20 | await page.goto("https://www.google.com/");
21 |
22 | // Get the Title and Print
23 | console.log(await page.title());
24 |
25 | // Assert the Page Title
26 | await expect(page).toHaveTitle('Google');
27 |
28 | });
29 |
30 | test('Section_13_RS_UI_Tests - Playwright Test #2 - Assert_Title_4_TestsInOneSpecFile', async ({page} )=> {
31 |
32 | // Go to the application
33 | await page.goto("https://www.google.com/");
34 |
35 | // Get the Title and Print
36 | console.log(await page.title());
37 |
38 | // Assert the Page Title
39 | await expect(page).toHaveTitle('Google1');
40 |
41 | });
42 |
43 | test('Section_13_RS_UI_Tests - Playwright Test #3 - Assert_Title_4_TestsInOneSpecFile', async ({page} )=> {
44 |
45 | // Go to the application
46 | await page.goto("https://www.google.com/");
47 |
48 | // Get the Title and Print
49 | console.log(await page.title());
50 |
51 | // Assert the Page Title
52 | await expect(page).toHaveTitle('Google1');
53 |
54 | });
55 |
56 | test('Section_13_RS_UI_Tests - Playwright Test #4 - Assert_Title_4_TestsInOneSpecFile', async ({page} )=> {
57 |
58 | // Go to the application
59 | await page.goto("https://www.google.com/");
60 |
61 | // Get the Title and Print
62 | console.log(await page.title());
63 |
64 | // Assert the Page Title
65 | await expect(page).toHaveTitle('Google');
66 |
67 | });
--------------------------------------------------------------------------------
/tests/Section_13_RS_UI_Tests/58_Assert_Title_4_TestsInOneSpecFile_Serial.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | const {test,expect} = require('@playwright/test');
14 |
15 | test.describe.configure( { mode : 'serial' } );
16 |
17 | test('Section_13_RS_UI_Tests - Playwright Test #1 - Assert_Title_4_TestsInOneSpecFile', async ({page} )=> {
18 |
19 | // Go to the application
20 | await page.goto("https://www.google.com/");
21 |
22 | // Get the Title and Print
23 | console.log(await page.title());
24 |
25 | // Assert the Page Title
26 | await expect(page).toHaveTitle('Google');
27 |
28 | });
29 |
30 | test('Section_13_RS_UI_Tests - Playwright Test #2 - Assert_Title_4_TestsInOneSpecFile', async ({page} )=> {
31 |
32 | // Go to the application
33 | await page.goto("https://www.google.com/");
34 |
35 | // Get the Title and Print
36 | console.log(await page.title());
37 |
38 | // Assert the Page Title
39 | await expect(page).toHaveTitle('Google1');
40 |
41 | });
42 |
43 |
44 | test('Section_13_RS_UI_Tests - Playwright Test #3 - Assert_Title_4_TestsInOneSpecFile', async ({page} )=> {
45 |
46 | // Go to the application
47 | await page.goto("https://www.google.com/");
48 |
49 | // Get the Title and Print
50 | console.log(await page.title());
51 |
52 | // Assert the Page Title
53 | await expect(page).toHaveTitle('Google1');
54 |
55 | });
56 |
57 | test('Section_13_RS_UI_Tests - Playwright Test #4 - Assert_Title_4_TestsInOneSpecFile', async ({page} )=> {
58 |
59 | // Go to the application
60 | await page.goto("https://www.google.com/");
61 |
62 | // Get the Title and Print
63 | console.log(await page.title());
64 |
65 | // Assert the Page Title
66 | await expect(page).toHaveTitle('Google');
67 |
68 | });
--------------------------------------------------------------------------------
/tests/Section_13_RS_UI_Tests/59_Tagging.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | const {test,expect} = require('@playwright/test');
14 |
15 | test('@Regression @Sanity @Smoke Section_13_RS_UI_Tests - Playwright Test #1 - Assert_Title_4_TestsInOneSpecFile', async ({page} )=> {
16 |
17 | // Go to the application
18 | await page.goto("https://www.google.com/");
19 |
20 | // Get the Title and Print
21 | console.log(await page.title());
22 |
23 | // Assert the Page Title
24 | await expect(page).toHaveTitle('Google');
25 |
26 | });
27 |
28 | test('@Regression @BVT @Sanity Section_13_RS_UI_Tests - Playwright Test #2 - Assert_Title_4_TestsInOneSpecFile', async ({page} )=> {
29 |
30 | // Go to the application
31 | await page.goto("https://www.google.com/");
32 |
33 | // Get the Title and Print
34 | console.log(await page.title());
35 |
36 | // Assert the Page Title
37 | await expect(page).toHaveTitle('Google1');
38 |
39 | });
40 |
41 |
42 | test('@Regression @BVT Section_13_RS_UI_Tests - Playwright Test #3 - Assert_Title_4_TestsInOneSpecFile', async ({page} )=> {
43 |
44 | // Go to the application
45 | await page.goto("https://www.google.com/");
46 |
47 | // Get the Title and Print
48 | console.log(await page.title());
49 |
50 | // Assert the Page Title
51 | await expect(page).toHaveTitle('Google1');
52 |
53 | });
54 |
55 | test('@Regression @Smoke Section_13_RS_UI_Tests - Playwright Test #4 - Assert_Title_4_TestsInOneSpecFile', async ({page} )=> {
56 |
57 | // Go to the application
58 | await page.goto("https://www.google.com/");
59 |
60 | // Get the Title and Print
61 | console.log(await page.title());
62 |
63 | // Assert the Page Title
64 | await expect(page).toHaveTitle('Google');
65 |
66 | });
--------------------------------------------------------------------------------
/utils/APIUtils.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | const {expect} = require('@playwright/test');
14 | class APIUtils{
15 |
16 | apiContext;
17 | requestBody_Login;
18 |
19 | constructor(apiContext,requestBody_Login){
20 | this.apiContext = apiContext;
21 | this.requestBody_Login = requestBody_Login;
22 | }
23 |
24 | /*************** Get Access Token - START ********************/
25 | async getAccessTokenForLogin(){
26 | console.log('this.requestBody_Login');
27 | console.log(this.requestBody_Login);
28 | const response_login = await this.apiContext.post(
29 | //Request URL
30 | 'https://www.rahulshettyacademy.com/api/ecom/auth/login',
31 | {
32 | //Request Body
33 | data: this.requestBody_Login
34 | });//post
35 |
36 | //Assertion for Response status code - 200
37 | expect(response_login.ok()).toBeTruthy();
38 |
39 | //Extract the Response Body in JSON format
40 | const response_login_json = await response_login.json();
41 |
42 | //Extract the token
43 | const api_login_token = response_login_json.token;
44 | console.log('api_login_token: '+api_login_token);
45 |
46 | return api_login_token;
47 | }
48 |
49 | /*************** Get Access Token - END ********************/
50 |
51 | /*************** Create Order - START ********************/
52 |
53 | async createOrder(requestBody_createOrder){
54 |
55 | // Javascript Object
56 | // This will have 2 properties
57 | // 1. Token
58 | // 2. Order ID
59 | let response={};
60 |
61 | console.log('this.getAccessTokenForLogin()');
62 | console.log(this.getAccessTokenForLogin());
63 | response.token = await this.getAccessTokenForLogin();
64 | console.log('response.token: '+response.token)
65 | const response_createOrder = await this.apiContext.post(
66 | //Request URL
67 | 'https://www.rahulshettyacademy.com/api/ecom/order/create-order',
68 | {
69 | //Request Body
70 | data: requestBody_createOrder,
71 | //Request Headers
72 | headers:{
73 | //'Authorization' : api_login_token,
74 | //'Authorization' : this.getAccessTokenForLogin(),
75 | 'Authorization' : response.token,
76 | 'Content-Type' : 'application/json'
77 | }
78 | });//post
79 |
80 | //Extract the Response Body in JSON format
81 | const response_createOrder_json = await response_createOrder.json();
82 | console.log('response_createOrder_json: '+response_createOrder_json);
83 | console.log('Assertion for Response body - message');
84 | expect((response_createOrder_json.message === 'Order Placed Successfully')).toBeTruthy();
85 |
86 | console.log(response_createOrder_json);
87 | console.log(response_createOrder_json.message);
88 | //Extract the order ID
89 | const orderID_from_createOrderAPI = response_createOrder_json.orders[0];
90 | console.log('orderID_from_createOrderAPI: '+orderID_from_createOrderAPI);
91 | //return orderID_from_createOrderAPI;
92 |
93 | response.orderID = orderID_from_createOrderAPI;
94 | return response;
95 | }
96 | /*************** Create Order - END ********************/
97 |
98 |
99 | }//class
100 |
101 | module.exports={APIUtils};
--------------------------------------------------------------------------------
/utils/CommonUtils.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | class CommonUtils{
14 |
15 | async waitForSomeTime(timeInSeconds) {
16 | console.log('Additional Wait for '+timeInSeconds+' seconds.');
17 | await new Promise(resolve => setTimeout(resolve, (timeInSeconds*1000)));
18 | }
19 |
20 | }//class
21 |
22 | module.exports={CommonUtils};
23 |
24 | //This is required so that other classes can also use ProductsPage.js file
25 | //export default new CommonUtils
--------------------------------------------------------------------------------
/utils/test-base.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author Rajat Verma
3 | * https://www.linkedin.com/in/rajat-v-3b0685128/
4 | * https://github.com/rajatt95
5 | * https://rajatt95.github.io/
6 | *
7 | * Course: Playwright JS Automation Testing from Scratch with Framework (https://www.udemy.com/course/playwright-tutorials-automation-testing/)
8 | * Tutor: Rahul Shetty (https://www.udemy.com/user/rahul445/)
9 | */
10 |
11 | /******************************************************** */
12 |
13 | const base = require('@playwright/test');
14 |
15 | exports.customtest = base.test.extend(
16 | {
17 | testData_Login : {
18 | username : "testtmail95@gmail.com",
19 | password : "HiRahul@123"
20 | }
21 | }
22 | )
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------