Can anyone please help me with Approach to validate the Search Results in e-commerce website? Suppose I entered any keyword in the search bar and N number of records is displayed post clicking search button. Now if I need to validate all the items displayed in the search result what should be the approach? Do I need to reiterate all the items and then compare each string with Expected output?
What are you trying to "validate"? The HTML output, or the data structure itself? You mentioned Selenium, but usually driving a browser is the slowest way to test something. I'm a WordPress developer, so the best tool for my e-commerce sites is Codeception. In Codeception you could test this in at least two basic ways:
Acceptance Test - You could use Selenium webdriver, but I'd recommend PhantomJS, because it is a lot faster. This method would involve driving the browser [or the virtual browser], and confirming the site is doing what you expect it to do.
Unit Test - Assuming that you understand how the platform you're coding for works, at some point in the stack there is some kind of class that can return what you're looking for as a testable object. Usually unit testing is exponentially faster than acceptance testing, since you only test the absolute smallest thing you can think of.
These two approaches might be associated with Behavior Driven Development and Test Driven Development. BDD is often thought of as an "outside in" methodology, which lends itself to browser based acceptance tests. TDD is usually incremental and small, and unit focused. It's faster, but lacks context.
There isn't a right way. My experience is that browser based testing is easier to understand, because you already know how to use a browser. As you gain experience, you'll drive the screws down deeper, and API and unit testing will be the way to go.
I have some experience with e-commerce and search. At first, we also wanted to automate search results on GUI level, but after some analysis, we found out that it is not delivering information what we need. We had daily releases on PROD, our customer changed products frequently (nightly import), no point to test search results on the TEST-machine and not business friendly to maintain fake products on PROD. At the end, we built checks for indexing job.