Before investing in a company, it's always good to take a look at the fundamentals and ensure that the company is not in trouble. This can easily become a tedious task especially when reviewing multiple establishments. This program helps to gather the fundamentals of companies by scraping the necessary web elements and printing them in the console.
These instructions will get you a copy of this project up and running on your local machine for development and testing purposes
- Java SE
- Java SDK
- Eclipse
Option 1: Through terminal / cmd
git clone https://github.com/0lu99/YahooFinanceScraper_Java.git
Option 2: Through Eclipse IDE
- Maven - Build automation tool
- Cucumber - To help assist BDD through its language parser, Gherkin
- Selenium - Collection of tools to automate web browser actions
A feature file consists of a high level description of the scenario that's to be tested. It's written in a language called Gherkin making it easy to understand from all perspectives. I have made use of a scenario outline which allows me to execute the same test scenario for multiple sets of data which I provide through a table
The feature file can be found at .../Features/
Page object model is a common design pattern when writing automation scripts that's used to create an object repository for elements on a web page. It is used to store these web elements as variables as well as creating methods that will peform actions using those elements. The main advantages of using this pattern is that is helps to reduce duplication and increaes reusability by making use of the same web element in different classes and it also helps test maintainance. If each web page throughout the test journey has their own page object model, it'll be easier to keep track of where everything is.
For this project I make use of 2 POM classes, one for the page where the user will search for the stock and the second for the page the user will get the stock info from.
To support Page Object Model Page Facotry, an extension to Page Object is used to help initialise the web element variables like so:
@FindBy (xpath = "//li[7]//a[1]//span[1]")
@CacheLookup
WebElement financialsTab;
The POM classes can be found at ...Java/src/test/java/pageObjects/
This is where the code to carry out the autonomous actions are written. The steps in the cucumber feature file are directly mapped to the step definitions that in turn executes a block of code that gets executed when each scenario is ran.
The step definition class can be found at ...Java/src/test/java/stepDefinitions/
The test runner class defines the location of the feature file and 'glues' it up with the step definition class. It also provides the metadata information that's needed to suucessfully execute the tests.
The test runner class can be found at ...Java/src/test/java/testRunner/
As mentioned, this project makes use of Scenario Outline - a Gherkin reference - which will iterate through the same process until it has taken each row in the Examples section beneath it into account. In order to search for the individual stocks of your choice, all you need to do is edit/add stocks to the examples table within the feature file:
For the purpose of the length of the GIF, this scenario shows the event a user wants to get information for Microsoft (MSFT):