<?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 Ayobami Opeyemi. on Medium]]></title>
        <description><![CDATA[Stories by Ayobami Opeyemi. on Medium]]></description>
        <link>https://medium.com/@barmmie_?source=rss-da31b5d659e5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*eSsEL69BtmE163pXTRNd6Q.jpeg</url>
            <title>Stories by Ayobami Opeyemi. on Medium</title>
            <link>https://medium.com/@barmmie_?source=rss-da31b5d659e5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 22:09:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@barmmie_/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[5 useful tricks for Laravel Dusk]]></title>
            <link>https://medium.com/@barmmie_/5-useful-tricks-for-laravel-dusk-a3b0a32f6692?source=rss-da31b5d659e5------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3b0a32f6692</guid>
            <category><![CDATA[tdd]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[dusk]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[webdriver]]></category>
            <dc:creator><![CDATA[Ayobami Opeyemi.]]></dc:creator>
            <pubDate>Wed, 01 May 2019 18:55:50 GMT</pubDate>
            <atom:updated>2019-05-02T11:35:45.493Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://laravel.com/docs/5.8/dusk">Laravel Dusk</a> is an expressive, easy-to-use, powerful browser automation and testing tool for Laravel. With Dusk you can programmatically test javascript driven applications. Occasionally while writing browser tests with Laravel dusk, I have often run into some limitations. In this article, I will share instances of these situations and how I was able to get past said limitations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HCBU57ty5tokdEznLTPjQg.jpeg" /><figcaption>Source: <a href="https://devdojo.com/course/laravel-dusk">https://devdojo.com/course/laravel-dusk</a></figcaption></figure><h3><strong>1. Filling hidden fields</strong></h3><p>When testing certain JS components (e.g Autocomplete, Datepickers) It can be strenuous writing actions to simulate DOM clicks/interactions with said components. Since most of these components eventually save the eventual value to a hidden field. It can be more expedient to fill in the hidden field directly with the value. This prevents flaky tests and ensures that we are not testing things we do not own/control (third party components).</p><p>While Laravel dusk does not provide us with a method like $browser-&gt;fillHidden($field, $value), we can create it ourselves using <a href="https://laravel.com/docs/5.8/dusk#browser-macros">Dusk Browser Macros</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e72866403ba4fb8a3e2b383cfbf69aec/href">https://medium.com/media/e72866403ba4fb8a3e2b383cfbf69aec/href</a></iframe><h3><strong>2. Mocking HTML Geolocation</strong></h3><p>I once had to test a page that needed to provide Geolocation results to the HTML site so it could display some results. There was no direct mock method available so I had to override the getCurrentPosition method which would eventually be called by the page.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff79bd60c15d56b98e929f88a18ef61a/href">https://medium.com/media/ff79bd60c15d56b98e929f88a18ef61a/href</a></iframe><h3><strong>3. Using XPath selectors</strong></h3><p>Occasionally I’d run into situations where I’m unable to use CSS selectors to locate an element. These often happen with dynamic tables or in my case with a third party js component which I couldn’t modify. Laravel Dusk, however, doesn’t support XPath selectors directly and often requires accessing the underlying WebDriver instance.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2569b29582f4cab9f0db71595e48e17/href">https://medium.com/media/f2569b29582f4cab9f0db71595e48e17/href</a></iframe><p><em>The only slight [inconsequential] annoyance to this approach is that it might require you to break the fluent method calls on the </em><em>$browser.</em></p><h3><strong>4. Full Page screenshots</strong></h3><p>Laravel dusks provide us with screenshots of our failed tests and these can be very helpful to know why our tests don’t pass. However, sometimes the error or the element in question might be below the fold.</p><p>To create full page screenshots in Laravel Dusk we have to create a captureFailuresFor() method in our tests\DuskTestCase.php which would override the one originally defined in Laravel\Dusk\Concerns\ProvidesBrowser</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a48cc03acf1a723e397c6da250aee33e/href">https://medium.com/media/a48cc03acf1a723e397c6da250aee33e/href</a></iframe><p>Now, whenever we call $browser-&gt;screenshot(&#39;$shotname&#39;) or when there’s an error. we’d get a full page screenshot</p><h3><strong>5. Accessing browser error logs</strong></h3><p>Ok. This is not a limitation, just something interesting I found. We can access browser console logs by calling $browser-&gt;driver-&gt;manage()-&gt;getLog(‘browser’)</p><p>This will return an array of logs in the browser’s console. It can be useful for testing for example that there are no javascript errors on the page.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/784d8af4bea49e5aea507819395c74ae/href">https://medium.com/media/784d8af4bea49e5aea507819395c74ae/href</a></iframe><p><em>Be warned though, it doesn’t contain the output of </em><em>console.log calls</em></p><h4>Conclusion</h4><p>Thanks for reading this, hopefully, you found one or more tip(s) useful.</p><p><em>p.s Please let me know if you notice any errors or inaccuracies in the post and I’d be happy correct it immediately.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3b0a32f6692" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>