The first step is to segregate the different test cases that are to be automated. Following this, you must prepare test data as per the needs of the test cases. Reusable functions need to be written which are frequently used in those test cases. Later test scripts are prepared by using reusable functions and applying loops and conditions wherever necessary.