Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Selenium by (5k points)

Laravel and Selenium both use PHPUnit's assertions. In both Laravel and Selenium you write code to make tests (instead of choosing things to do in GUI; e.g. open: google.com, write in: name->queryInput text:"test search", click: name->searchButton). Both Laravel and Selenium can visit webpages, submit forms and check the results. You can automate tests both in Laravel and Selenium by adding PHPUnit command to cron.

So why should I use Selenium for testing in Laravel?

What I can make of it is that Selenium allows choosing a browser in which the pages will be opened. So if your test passes using only Laravel testing it may fail for some browsers, like, say, Internet Explorer.

1 Answer

0 votes
by (10.2k points)

The request will be internally emulated by Laravel integrated tests and may use some advantages (like Disabling Middleware, Mocking, Spying, etc) for making sure that you are isolating a particular problem (Test Case). The goal is to test the application without introducing third party components side effects into the battlefield, this would be: the client browsers, external services, etc. These types of tests are really fast, lightweight, and very suitable for testing API calls.

Therefore Selenium is exactly for covering all those cases, in which you actually want to cover those scenarios affected by third-party components side effects, like JavaScript in either Chrome, IE, Firefox, etc, even in the different versions of those. This can be understood as an attempt to be as close as possible to the real world scenario, where the client browser actually may interfere with the expected behavior of your application. Also, it's possible to trigger screenshots if you want to visually validate CSS or interactive components. It is important to mention that because of this browser hook, these tests are way slower to execute.

So, it is not that both need to be used exclusively. They work similarly but provide different capabilities. You can have a set of Laravel integration tests, and a set of Selenium tests for those things that matter to you.

Related questions

0 votes
1 answer
0 votes
1 answer
asked Oct 6, 2020 in Selenium by dev_sk2311 (42.8k points)
0 votes
1 answer
asked Nov 6, 2020 in Selenium by dev_sk2311 (42.8k points)
0 votes
1 answer

Browse Categories

...