Rayrun
← Back to Discord Forum

Is it recommended to use Expect from the test package while scraping?

altairsama69posted in #help-playwright
Open in Discord

Hey folks,

i was going through the playwright docs and they advise against manually checking for stuff like text content, count etc ans instead use assertions for them. Is this approach just for testing purposes only or is this something that's recommended for scraping too?

This thread is trying to answer question "Is it recommended to use assertions from the test package while scraping, as advised for testing in the Playwright documentation?"

2 replies

The recommendation to use assertions rather than manual checking is primarily focused on testing scenarios in the context of Playwright. Assertions provide a more structured and automated way to verify expected outcomes, making the test scripts more reliable and maintainable.

For web scraping purposes, the approach might differ based on your specific use case. When scraping, you are essentially extracting information from a webpage, and the focus might be more on parsing and extracting data rather than extensive testing scenarios.

However, if your web scraping involves verifying specific conditions or extracting structured data, incorporating a similar approach with assertions could enhance the reliability of your scraping scripts. Assertions can help ensure that the expected elements are present or that the extracted data meets certain criteria.

altairsama69
altairsama69

yeah, I mostly want it for verifying if the data I am getting is indeed good and the assertions look really clean to me instead of having to do this manually, I just wasnt sure if there were any implications I should be aware of. Thanks for the clarification!

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.