{"id":24382957,"url":"https://github.com/thanasornsawan/playwright_automation_everything","last_synced_at":"2026-02-12T23:31:34.126Z","repository":{"id":270319376,"uuid":"909736399","full_name":"Thanasornsawan/playwright_automation_everything","owner":"Thanasornsawan","description":"This repo contains database testing, api testing, web testing and github action cicd to send notification to slack","archived":false,"fork":false,"pushed_at":"2025-02-04T09:46:12.000Z","size":27518,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-21T11:06:39.592Z","etag":null,"topics":["api","automated-testing","database","graphql","playwright","playwright-javascript","qa-automation","testing","web"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Thanasornsawan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-29T16:21:39.000Z","updated_at":"2025-02-11T20:23:55.000Z","dependencies_parsed_at":"2025-02-04T09:35:49.734Z","dependency_job_id":null,"html_url":"https://github.com/Thanasornsawan/playwright_automation_everything","commit_stats":null,"previous_names":["thanasornsawan/practice_playwright","thanasornsawan/playwright_automation_everything"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Thanasornsawan/playwright_automation_everything","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thanasornsawan%2Fplaywright_automation_everything","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thanasornsawan%2Fplaywright_automation_everything/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thanasornsawan%2Fplaywright_automation_everything/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thanasornsawan%2Fplaywright_automation_everything/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Thanasornsawan","download_url":"https://codeload.github.com/Thanasornsawan/playwright_automation_everything/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thanasornsawan%2Fplaywright_automation_everything/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261110613,"owners_count":23111064,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","automated-testing","database","graphql","playwright","playwright-javascript","qa-automation","testing","web"],"created_at":"2025-01-19T10:11:10.243Z","updated_at":"2026-02-12T23:31:34.098Z","avatar_url":"https://github.com/Thanasornsawan.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Self-practice playwright\n\n# Playwright web testing\n\n\u003cdetails\u003e\n    \u003csummary\u003eClick to see detail about web testing\u003c/summary\u003e\n\n## Full automate E2E test cases\nThis practice use website https://practicesoftwaretesting.com/ for testing. \u003cbr/\u003e\n\nThe file structue for tool demo web test cases:\n\n```\nproject-root/\n│   ├── web/\n│       └── pages/\n|            |- tool_shop/\n│               ├── basePage.js\n│               ├── cartPage.js\n│               ├── invoiceDetailPage.js\n│               ├── loginPage.js\n│               ├── myInvoicesPage.js\n│               ├── navBarPage.js\n│               ├── productDetailPage.js\n│               ├── registerPage.js\n│               ├── searchPage.js\n│       └── features/\n|            |- tool_shop/\n│               ├── productFeature.js\n│   ├── utils/\n│       └── pdfUtils.js\n│       └── otpUtils.js\n│   ├── data/\n│       └── tool_shop/\n|            |- userData.json\n│   ├── tests/\n│       └── tool_shop/\n|            |- cart.spec.js\n|            |- e2e.spec.js\n|            |- product.spec.js\n|            |- search.spec.js\n```\n\n![tool result](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/tool_demo_result.png?raw=true)\n\n## Re-use login state by login API before jump to any pages\nThis practice use website https://ecommerce-playground.lambdatest.io/index.php for testing. \u003cbr/\u003e\n\n\u003cdetails\u003e\n    \u003csummary\u003eClick to see detail about using login state by login API\u003c/summary\u003e\nAt first, we intercept network and check endpoint for login API and payload and then make API request in ``LambdaTestApiUtils.js`` file \u003cbr/\u003e\nand then we use ``await page.context().addCookies(apiCookies);`` for add cookie from login API before proceed to any page. \u003cbr/\u003e\nIn the test script ``lambdatest_product_detail.spec.js``, we only test add product to cart, verify toast popup and total qty in cart\u003cbr/\u003e\n\n![lambda ui](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/lambda_product_detail_ui.png?raw=true)\n![lambda result](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/lambda_result.png?raw=true)\n\n\u003c/details\u003e\n\n## Re-use login state by use local storage file before jump to any pages\nThis practice use website https://opensource-demo.orangehrmlive.com for testing. \u003cbr/\u003e\n\n\u003cdetails\u003e\n    \u003csummary\u003eClick to see detail about using local storage file login\u003c/summary\u003e\nAt first, we use admin account go to PIM menu to create different role accounts (In our case is testerQA1, testerQA2) \u003cbr/\u003e\n\n![orangehrm admin](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/orangehrm_admin.png?raw=true)\n\nThen, we try use employee role account to access privilege page that only admin can do. We can see alert message below.\n\n![orangehrm employee](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/orangehrm_employee.png?raw=true)\n\nFirst step, we run ``npx playwright test tests/orangehrm/save_states.spec.js --reporter=list`` to make all 3 accounts login \u003cbr/\u003e\nthe same time with ``Promise.all()`` and saves all login-related data (cookies, localStorage) to thier state file \u003cbr/\u003e\nThen, in role_test.spec.js, we use the state file\n\n```javascript\n   const adminTest = test.extend({\n   storageState: '.auth/state-admin.json'\n});\n```\n\n**Using adminTest instead of test:** \u003cbr/\u003e\n``adminTest('Admin can access Employee List', ...)`` looks similar to regular test() but with one key difference\u003cbr/\u003e\n- Every time you use adminTest, Playwright automatically loads the admin's login state before running the test\n- You don't need to manually log in anymore - the state file handles that\n- ``test.extend()`` in Playwright, creating a customized version of the test function\u003cbr/\u003e\nThink of it as saying \"I want all tests using this function to have these special settings\"\u003cbr/\u003e\n\n![orangehrm result](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/orangehrm_result.png?raw=true)\n\n\u003c/details\u003e\n\u003c/details\u003e\n\u003cbr/\u003e\n\n# TDD testing with Playwright\n\n\u003cdetails\u003e\n    \u003csummary\u003eClick to see all TDD testing\u003c/summary\u003e\n\n## Database setup\n**if you use mac M1, you might have problem build docker oracle same me, recommend to use colima start docker**\n\u003cbr/\u003e\n\n```sh\nbrew install colima \ncolima start --arch x86_64 --memory 4\ndocker-compose up -d\n```\n\n\u003cbr/\u003e\nRefer blog about [Running Oracle Database on Docker on Apple M1 Chip](https://oralytics.com/2022/09/22/running-oracle-database-on-docker-on-apple-m1-chip/)\n\nNow, you can see postgresql and oracle database running inside Colima like this \u003cbr/\u003e\n\n![docker run](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/docker_run.png?raw=true)\n\n**How to connect and setup sample data via oracle db** \u003cbr/\u003e\n\n\u003cdetails\u003e\n    \u003csummary\u003eClick to see how to setup oracle db and make sameple data\u003c/summary\u003e\n\n![oracle query](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/oracle_query.png?raw=true)\n![oracle query2](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/sample_data.png?raw=true)\n\u003c/details\u003e\n\u003cbr/\u003e\n\n**How to connect and setup sample data via postgresql db** \u003cbr/\u003e\n\u003cdetails\u003e\n    \u003csummary\u003eClick to see how to setup postgresql db and make sameple data\u003c/summary\u003e\n\n![postgresql setup](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/postgresql_connect.png?raw=true)\n![postgresql query](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/postgresql_data.png?raw=true)\n\u003c/details\u003e\n\u003cbr/\u003e\n\n**How to setup sample data via mongo db** \u003cbr/\u003e\n\n\u003cdetails\u003e\n    \u003csummary\u003eClick to see how to setup mongodb sample data\u003c/summary\u003e\n\n![mongo query](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/mongo_query.png?raw=true)\n\u003c/details\u003e\n\u003cbr/\u003e\n\n**How to setup sample data via mysql db** \u003cbr/\u003e\n\u003cdetails\u003e\n    \u003csummary\u003eClick to see how to setup mysql sample data\u003c/summary\u003e\n\n![mysql query](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/mysql_query.png?raw=true)\n![mysql query2](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/mysql_result.png?raw=true)\n![mysql query3](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/mysql_query_result.png?raw=true)\n![mysql query4](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/query_price_condition.png?raw=true)\n\u003c/details\u003e\n\n\u003c/details\u003e\n\u003cbr/\u003e\n\n# Report integration\n\n\u003cdetails\u003e\n    \u003csummary\u003eClick to see all reports integration detail\u003c/b\u003e\u003c/summary\u003e\n\n## Report integrate with TestRail\nusing testrail-reporter, see full documentation [testrail-reporter here](https://github.com/zealous-tech/testrail-reporter/tree/main)\u003cbr/\u003e\n\n**Result after run test case, result sent to TestRail** \u003cbr/\u003e\n\u003cdetails\u003e\n    \u003csummary\u003e\u003cb\u003eClick to see all TestRail results\u003c/b\u003e\u003c/summary\u003e\n\n![testrail result](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/testrail_result.png?raw=true)\n![testrail_pass result](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/testrail_pass.png?raw=true)\n![testrail_fail result](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/testrail_fail.png?raw=true)\n\u003c/details\u003e\n\n## Report integrate with Qase\nusing qase-playwright, see full documentation [qase playwright here](https://github.com/qase-tms/qase-javascript/tree/main/qase-playwright#configuration)\u003cbr/\u003e\n\n**Result after run test case, result sent to Qase** \u003cbr/\u003e\n\u003cdetails\u003e\n    \u003csummary\u003e\u003cb\u003eClick to see all Qase results\u003c/b\u003e\u003c/summary\u003e\n\n![qase_dashboard result](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/testrun_dashboard_qase.png?raw=true)\n![qase result](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/qase_result.png?raw=true)\n\u003c/details\u003e\n\n## Report integrate with Allure\n\u003cdetails\u003e\n    \u003csummary\u003e\u003cb\u003eClick to see all Allure results\u003c/b\u003e\u003c/summary\u003e\n\n```sh\nnpx allure generate allure-results -o allure-report --clean\nnpx allure open allure-report\n```\n\n![allure open](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/allure_open.png?raw=true)\n![allure dashboard](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/allure_dashboard.png?raw=true)\n\u003c/details\u003e\n\n**Run test oracle db with playwright and allure report**\n```sh\nnpx playwright test tests/database_testcase/oracle_user.spec.js --reporter=allure-playwright\n```\n![run allure](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/run_test_allure_report.png?raw=true)\n\n## Setup .env configuration\n```sh\nQASE_TESTOPS_API_TOKEN=**your_playwright_token_app_on_qase**\nQASE_TESTOPS_PROJECT=**your_project_code**\nTESTRAIL_API_TOKEN=**your_testrail_token***\nTESTRAIL_USER=**your_email_account_testrail***\nTESTRAIL_BASE_URL=https://**your_testrail_domain**.testrail.io\n```\n\n**Get your qase token from app menu here** \u003cbr/\u003e\n![qase token](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/api_key_qase.png?raw=true)\n\n**Get your TestRail api token from your setting menu here** \u003cbr/\u003e\n![testrail token](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/api_key_testrail.png?raw=true)\n\n**command to run project with qase report**\n```sh\nQASE_MODE=testops npx playwright test\n```\n\u003c/details\u003e\n\u003cbr/\u003e\n\n# CICD integration\n\n\u003cdetails\u003e\n    \u003csummary\u003e\u003cb\u003eClick to see cicd detail\u003c/b\u003e\u003c/summary\u003e\n## Azure Devops CICD pipeline send slack notification to slack\nI wrote step by step on this blog [Playwright with Azure Devops Pipeline (Self-hosted) and Slack notification](https://medium.com/@wisdomgoody/playwright-with-azure-devops-pipeline-self-hosted-and-slack-notification-e15f5cb96cc1)\n\n## Github CICD send notification to slack\n**Step 1: Set Up Slack Incoming Webhook**\n1. Go to your Slack workspace.\n2. Navigate to Apps → Search for \"Incoming Webhooks.\"\n3. Set up a new webhook for the channel you want to send notifications to.\n4. Copy the webhook URL.\n\n**Step 2: Store Slack Webhook URL as a GitHub Secret**\n1. Go to your GitHub repository.\n2. Navigate to Settings → Secrets and variables → Actions → New repository secret.\n3. Add a secret:\n- Name: SLACK_WEBHOOK_URL\n- Value: Paste the Slack webhook URL.\n\n![github secret](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/github_secret.png?raw=true)\n![github cicd](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/github_cicd.png?raw=true)\n![slack not](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/slack_noti.png?raw=true)\n\n\u003c/details\u003e\n\u003cbr/\u003e\n\n# Playwright API testing\n\n\u003cdetails\u003e\n    \u003csummary\u003e\u003cb\u003eClick to see API testing detail\u003c/b\u003e\u003c/summary\u003e\n\n## API testing with Node.js (express server)\n\n\u003cdetails\u003e\n    \u003csummary\u003eClick to see detail API testing with Node.js server\u003c/summary\u003e\n\n**Setup .env configuration**\n```sh\nDB_USER=**your_db_user_same_like_docker_setup**\nDB_PASSWORD=**your_db_password_same_like_docker_setup**\nDB_NAME=ecommerce\nDB_HOST=localhost\nDB_PORT=5432\nJWT_SECRET=**your_API_SECRET_KEY**\nAPI_SERVER_PORT=3000\nDATABASE_URL=postgres://your_db_user:your_db_password@localhost:5432/ecommerce\n```\n\nAfter postgresql db on docker running, we can create more database and grant privilege on that database like this \u003cbr/\u003e\n** if you noticed my ``docker-compose.yml`` file, the postgresql db was setup with ``db_name: testdb`` for database testing.\n\n```sh\nCREATE DATABASE ecommerce;\nGRANT ALL PRIVILEGES ON DATABASE ecommerce TO testuser;\n```\n\nInstall all dependencies need for run API server (Nodejs express) with permanent database sequelize\n```sh\nnpm install express sequelize pg pg-hstore jsonwebtoken bcrypt express-validator express-rate-limit helmet dotenv\n```\n\nThe file structue for setup API server:\n\n```\nproject-root/\n├── models/\n│   ├── index.js\n│   ├── user.js\n│   ├── profile.js\n│   ├── product.js\n│   ├── order.js\n│   ├── orderItem.js\n│   └── review.js\n├── routes/\n│   ├── middleware/\n│   │   ├── auth.js\n│   │   └── validators.js\n│   │   └── xml-parser.js\n│   ├── utils/\n│   │   └── validators.js\n│   ├── admin.routes.js\n│   ├── auth.routes.js\n│   ├── order.routes.js\n│   ├── products.routes.js\n│   └── user.routes.js\n│   └── reviews.routes.js\n│   └── advance-xml.routes.js\n│   └── form-image.routes.js\n├── .env\n└── server.js\n```\n\neach models file refer to table name in postgresql, it is database schema for setup via sequelize nodejs \u003cbr/\u003e\nand server.js is file that contains all API endpoint from routes folder for testing. You can run by this command: \u003cbr/\u003e\n\n```sh\nnode server.js\n```\n\nYou can also test API manually via Postman before make the test script\n\n![server run2](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/server_run2.png?raw=true)\n![postman](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/postman.png?raw=true)\n\nThe file structue for API test cases:\n\n```\nproject-root/\n├── api/\n│   ├── adminPage.js\n│   ├── apiHelper.js\n│   ├── authPage.js\n│   ├── orderPage.js\n│   ├── productPage.js\n│   ├── userProfilePage.js\n│   ├── formImagetransactionPage.js\n│   ├── XMLTransactionPage.js\n│   ├── data/\n│       └── api/\n|            |- json_payload.json\n│       └── images/\n|            |- small_image.jpg\n|            |- invalid_image.jpg\n|            |- large_image.jpg\n│   ├── tests/\n│       └── api/\n|            |- user_redirection_access.spec.js\n|            |- admin_inventory.spec.js\n|            |- user_order_products.spec.js\n|            |- complex_jsonpath_tests.spec.js\n|            |- advance_xml.spec.js\n|            |- upload_form_data.spec.js\n```\n\nNote: \n- ``user_order_products.spec.js`` focus on API testing with all methods (GET, POST, PUT, PATCH, DELTE) with authenticate user JWT token ``(use db)``\n- ``user_redirection_access.spec.js`` focus on privilege usage that only admin can access and verify all unauthorised status code ``(use db)``\n- ``admin_inventory.spec.js`` focus on business logic fill stocks with define threshold (positive, negative value, invalid) ``(use db)``\n- ``complex_jsonpath_tests.spec.js`` focus on how to filter specific value from complex json body to verify \n- ``advance_xml.spec.js`` focus on how to filter xml and prase xml strcuture to verify value in API response \n- ``upload_form_data.spec.js`` focus on how to validate file size, upload image file, file type and request body as form-data ``(use memory storage multer library)``\n\nResult after run test each files:\n![user order](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/user_order_product.png?raw=true)\n![user redirection](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/user_redirection.png?raw=true)\n![admin inventory](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/admin_inventory.png?raw=true)\n![complex inventory](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/complex_json_result.png?raw=true)\n![xml result](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/xml_result.png?raw=true)\n![form result](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/form_up_result.png?raw=true)\n\n\u003c/details\u003e\n\u003cbr/\u003e\n\n## API testing with Apollo server (Graphql)\n\n\u003cdetails\u003e\n    \u003csummary\u003eClick to see detail API testing with Apollo server\u003c/summary\u003e\n\nThe file structue for API test cases:\n\n```\nproject-root/\n├── api/\n│   ├── bookPage.js\n│   ├── data/\n│       └── queries/\n│           └── createBook.js\n│           └── deleteBook.js\n│           └── filterBook.js\n│           └── getBook.js\n│           └── updateBook.js\n│   ├── book_payload.json\n├── tests/\n│   ├── api/\n│   │   ├── book_management/\n│   │   │   ├── auth/ \n│   │   │   │   └── auth.spec.js      \n│   │   │   ├── crud/\n│   │   │   │   └── crud.spec.js          \n│   │   │   ├── validation/\n│   │   │   │   └── validation.spec.js    \n│   │   │   ├── filtering/\n│   │   │   │   └── filtering.spec.js     \n│   │   │   ├── error/\n│   │   │   │   └── error.spec.js         \n│   │   │   └── utils/\n│   │   │       └── test.setup.js\n```\n\nThe file structue for setup API server:\n\n```\nproject-root/\n├── src/\n│   ├── middleware/\n│   │   └── authMiddleware.js   # control all operation to use API key\n│   ├── models/\n│   │   └── Book.js             # Book entity\n│   ├── resolvers/\n│   │   └── bookResolvers.js    # GraphQL resolvers\n│   ├── schema/\n│   │   └── typeDefs.js         # GraphQL schema definitions\n│   ├── services/\n│   │   └── BookService.js      # Business logic\n│   ├── types/\n│   │   └── errors.js           # define error code  \n│   └── server.js\n```\n\ncommand to start server:\n```sh\nnode src/server.js\n```\n\n![apollo server](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/apollo_server.png?raw=true)\n\nResult after run test:\n![graphql result](https://github.com/Thanasornsawan/Practice_Playwright/blob/main/pictures/graphql_result.png?raw=true)\n\u003c/details\u003e\n\u003c/details\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthanasornsawan%2Fplaywright_automation_everything","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthanasornsawan%2Fplaywright_automation_everything","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthanasornsawan%2Fplaywright_automation_everything/lists"}