<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Thusitha Bandara on Medium]]></title>
        <description><![CDATA[Stories by Thusitha Bandara on Medium]]></description>
        <link>https://medium.com/@thusithatab?source=rss-d89e76f1caab------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*RaovtothGQAeTE4E</url>
            <title>Stories by Thusitha Bandara on Medium</title>
            <link>https://medium.com/@thusithatab?source=rss-d89e76f1caab------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 20:48:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thusithatab/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Making Pytest Playwright tests to re-run on failure]]></title>
            <link>https://medium.com/@thusithatab/making-pytest-playwright-tests-to-re-run-on-failure-80f145c1255e?source=rss-d89e76f1caab------2</link>
            <guid isPermaLink="false">https://medium.com/p/80f145c1255e</guid>
            <dc:creator><![CDATA[Thusitha Bandara]]></dc:creator>
            <pubDate>Fri, 24 Oct 2025 11:24:30 GMT</pubDate>
            <atom:updated>2025-10-24T11:24:30.222Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, I will explain how we can make Pytest Playwright tests to attempt several times before reporting the test as a failure.</p><p>Why?</p><p>In UI automated testing world, flakiness is a notorious problem. Rerunning a failed test is one way of mitigating the risk of a UI test is failing due to flakiness. Also, it can be used as a way to identify what are the flaky tests and then apply proper fixes to those tests.</p><p>How?</p><p>If you are using Pytest framework in your Python Playwright tests, all you have to do is add the ‘<a href="https://pypi.org/project/pytest-rerunfailures/">pytest-rerunfailures</a>’ plugin.</p><p>example:</p><p>Let’s take a look at the following example.</p><p>I have a sample project which I have used Poetry for dependency management.</p><p>So, in my ‘pyproject.toml’ file, I have updated the <a href="https://pypi.org/project/pytest-rerunfailures/">pytest-rerunfailures</a> as a dependency.</p><pre>dependencies = [<br>    &quot;playwright (&gt;=1.55.0,&lt;2.0.0)&quot;,<br>    &quot;pytest-rerunfailures (&gt;=12.0)&quot;<br>]</pre><p>Then, execute the following command to download and update the project with the dependency packages.</p><pre>poetry update</pre><p>Now, I have written a sample playwright test that fails intentionally.</p><pre>import re<br>from playwright.sync_api import Page, expect<br><br>def test_to_fail(page: Page):<br>    page.goto(&quot;https://playwright.dev/&quot;)<br>    expect(page).to_have_title(re.compile(&quot;Fail&quot;))</pre><p>Now, let’s execute this sample test with the following command to make it attempt to run two more times once the first attempt has failed.</p><pre>pytest --reruns 2</pre><p>If we want to make the tests rerun on failure by default (without specifying it in the command line), then we can do it by adding the following line to the pytest.ini file.</p><pre>[pytest]<br>reruns = 2</pre><p>Now, we do not need to specify the number of times in the command line. Every time when we run the tests using ‘pytest’ command, any test that fails, it will rerun the number of times specified in the <em>pytest.ini</em> file.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80f145c1255e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>