Once downloaded and installed, we have to perform a few simple steps to create our framework. Going to the menu option ‘Terminal->New Terminal’, you’ll open a new instance of a terminal that we can use to get started and set up our framework from scratch. If you’re already thinking this is a bit too technical having to use a terminal instead of creating files, don’t worry, it’s very simple.
The first terminal command you’re going to use is:
Next, we use another very short and sweet command:
npm init -y
The ‘-y’ part is optional, and feel free to run the command without as it’s useful to know what is going on in the background when this command runs.
It will ask you to give your project a name and a version number, which are required fields. It will also ask for optional author information, but you don’t have to enter anything for these. By using ‘-y’, you’re telling the init command to use default values and create a package.
Next, to keep this framework similar to our C# framework, we’re going to install Selenium WebDriver and ChromeDriver. Again, couldn’t be more simple, we’re going to use npm and use the following commands
npm install selenium-webdriver --save-dev npm install chromedriver --save-dev
Once these are installed, you can go back to your package.json file and see a new section called dependencies. In here you’ll see the Selenium-WebDriver and ChromeDriver packages and their version numbers. This means you now have these packages installed and ready to go to start writing tests.
But you know me, I like to keep articles small and easy to digest so that you’re not getting overwhelmed. While that may not seem like much to do, it’s a huge change from how you might be used to doing things if you’re coming from a C# background. So it may be worth you running through those steps a few times, so you’re comfortable in what is being done and why we’re doing them. Mess around with using default values and not, so you can see the differences and how they impact your project and packages.json file.