Salman Ali's Work | ContraWork by Salman Ali
Salman Ali

Salman Ali

AI-Augmented SQA Engineer with over 4 years of experience.

    5
    Followers
Followed by Ahmad F, Sabin M, and GALLERY L
Cover image for šŸ­. š—Ŗš—µš—®š˜ š—œš˜€ š—®š—» š—”š˜€š˜€š—²š—æš˜š—¶š—¼š—»?
An
šŸ­. š—Ŗš—µš—®š˜ š—œš˜€ š—®š—» š—”š˜€š˜€š—²š—æš˜š—¶š—¼š—»? An assertion is the check you make after something happens. In a manual test you do a step, then you look at the screen and compare it with the expected result. If you click Save and the page still says the invoice is not saved, the test fails. The click is not the result. Playwright Test writes that check with expect(). You give expect a locator, which is a description of an element, and then a matcher. A matcher is the condition you want to be true. toHaveText checks exact text. toBeVisible checks that an element is shown. These locator checks are web-first assertions. A web-first assertion retries until the condition is true or time runs out. This project sets that limit to five seconds in playwright.config.ts. You can reverse a matcher with not. expect(status).not.toHaveText('Invoice failed') fails when that wrong sentence is present. Use not when the result you need is the absence of a message. šŸ®. š—Ŗš—µš˜† š——š—¼ š—Ŗš—² š—”š—²š—²š—± š—œš˜? Pressing the button on a coffee machine is an action. Looking in the cup to see that coffee is there is the assertion. If you only press the button, you cannot tell a full cup from an empty one. Clicking Save invoice asks the page to save. It does not prove the save worked. A test that ends on the click can pass while the status still says "Not saved". The expected result has to be its own check. šŸÆ. š—œš—ŗš—½š—¹š—²š—ŗš—²š—»š˜š—®š˜š—¶š—¼š—» Start with the check alone. The matcher requires the words "Invoice saved". getByRole('status') finds the message a person would read after saving. expect and toHaveText form the web-first check. Playwright keeps looking until the text matches or five seconds pass. The practical test opens the local demo, confirms the starting message, clicks, and checks the new message. goto('/assertions') uses baseURL from the Playwright config. goto opens the page. The first toHaveText records the start, "Not saved", so a later pass cannot come from text that was already there. click is only the action. The second toHaveText is the result of that action. The script does not also check that the text is not "Invoice failed". The exact success message already answers that question. šŸ°. š—˜š˜…š—½š—²š—°š˜š—²š—± š—„š—²š˜€š˜‚š—¹š˜ A passing run starts at "Not saved", clicks Save invoice, and ends with "Invoice saved". A failing run means one of those texts did not match before the five-second assertion timeout. šŸ±. š—§š—®š—øš—²š—®š˜„š—®š˜†š˜€ • click performs an action. expect() checks the result. • A matcher such as toHaveText states the expected result. • Web-first assertions retry until they pass or the timeout ends. • Use not when the result is the absence of a specific message. š—œš—»š˜š—²š—æš˜ƒš—¶š—²š˜„ š—¾š˜‚š—²š˜€š˜š—¶š—¼š—»: What is the difference between clicking Save and asserting the status text? š—”š—»š˜€š˜„š—²š—æ: The click performs the action. The assertion checks the expected result. Without that check, a test can pass when the save changed nothing the user can see. šŸ². š—„š—²š—³š—²š—æš—²š—»š—°š—²š˜€ • https://playwright.dev/docs/test-assertions • https://playwright.dev/docs/api/class-locatorassertions
1
2
35
Cover image for Boost your career as a
Boost your career as a QA engineer with personalized 1-on-1 guidance! Whether you are looking to master modern test automation, scale up your workflows with AI testing tools, or navigate job transitions, let's connect. Book a session with me on Topmate (https://topmate.io/muhammad_salman_ali10/1131173) and get actionable insights to level up your software quality journey. Link : https://topmate.io/muhammad_salman_ali10/1131173 #QAEngineer #SoftwareTesting #TestAutomation #CareerGuidance #TechMentorship #ContraCommunity
0
3
Cover image for AI-Augmented Test Development Workflow
AI-Augmented Test Development Workflow
1
0
63
Cover image for Enterprise CRM Automation | Selenium + Java + TestNG
Enterprise CRM Automation | Selenium + Java + TestNG
0
54