Why do all this work of creating a framework? Why not just record a test using the Selenium IDE? And why do we have to write all this code?
There are a few reasons why recording isn't a long-term solution for automation. One of the major reasons is brittle tests. So, if you have decided that you were going to just record your tests, and you weren't going to use some kind of framework, then your tests would directly depend on your web application. So, what happens now if your web app changes in some way. Let's say that the structure of the application changes significantly, or even just minor little changes. Well, if you have a large number of tests, and all those tests depend on, let's say, a particular element on that page being named a certain thing, and that changes, all of those tests are now going to break. Now you're going to have to modify that code in every one of those tests. That's really the big disadvantage of recording because a recording is going to grab the elements, as we've seen, by the most efficient way that it can find throughout the element, which is not abstracting away the idea of graphing an element. Now let's think about what happens when we put an automation framework in place. The only modification done is in the abstraction layer. It's primarily giving an abstraction from the actual web application. What is observed is that the recording starts out to be much faster than developing a framework. It's very easy to get going with an automation framework by just starting off by doing some recording. But what ends up happening is because of that test brittleness, and because the tests you record start to get more and more complex, the time it takes to record starts to go up significantly, and you're not able to reuse a lot of what you've already recorded, so you really don't gain any benefit.