|
1 | | -# redx-demo |
| 1 | +# redx-demo |
| 2 | +### Purpose |
| 3 | +The purpose of this project is to automate UI tests of the website, https://www.theredx.com/ using Java & Selenium with Maven. |
| 4 | + |
| 5 | +## |
| 6 | +### FRAMEWORK INFORMATION |
| 7 | +This framework uses the following: |
| 8 | + |
| 9 | +#### Languages |
| 10 | +- Java - version 12 |
| 11 | + |
| 12 | +#### Dependencies |
| 13 | +These should all be part of the pom.xml file. |
| 14 | +- Maven.compiler - version 1.2 |
| 15 | +- Selenium - version 3.141.59 |
| 16 | +- Test NG - version 6.14.3 |
| 17 | +- Surefire - version 3.0.0-M5 |
| 18 | + |
| 19 | +#### Design Pattern |
| 20 | +- Page Object Model |
| 21 | + |
| 22 | +## |
| 23 | +###GETTING STARTED |
| 24 | +You will need the following on your computer in order to work on this project: |
| 25 | +* Java - Using version 12 for this project |
| 26 | +* Maven - Check out the Maven section below for more info on installing it |
| 27 | + |
| 28 | +1. Open the terminal |
| 29 | +2. Navigate to the directory you want to store this project |
| 30 | +3. Run this command ```git clone https://github.com/vernko/redx-demo.git``` |
| 31 | +4. Once it has cloned the repo, you should see something like ```redx-demo git:(main)``` |
| 32 | +5. Now you know you have the code for the repo on your machine |
| 33 | +6. Open this project in the code editor of your choice |
| 34 | +(for java, IntelliJ is really nice, recommend downloading the free community version at https://www.jetbrains.com/idea/download/) |
| 35 | +7. Once you have the project open, check & make sure you have the right version |
| 36 | + |
| 37 | +## |
| 38 | +### NAMING CONVENTIONS |
| 39 | +- Packages - camelCase (typically only one word though) |
| 40 | +- Classes - PascalCase |
| 41 | +- Methods - camelCase |
| 42 | + |
| 43 | +## |
| 44 | +### ORGANIZATION - PAGE OBJECTS |
| 45 | +#### Page Object Classes |
| 46 | +You'll find any Page Objects under the "main" directory in the "pages" package. |
| 47 | + |
| 48 | +Essentially, for each page you create a new class. You can use that class object anywhere in the automation. |
| 49 | +We use these classes to put any selenium-based operations such as: |
| 50 | +- Locators |
| 51 | +- Clicks |
| 52 | +- Sending keys/inputs |
| 53 | + |
| 54 | +Add methods & locators related to that page inside this class. |
| 55 | + |
| 56 | +I prefer to organize these in a hybrid alphabetical/functionality order. |
| 57 | +- If there is no related functionality, order it alphabetically. |
| 58 | +- If there is related functionality, put that in order of occurrence. |
| 59 | + |
| 60 | +## |
| 61 | +### ORGANIZATION - TESTS |
| 62 | + |
| 63 | +You'll find any tests under the "test" directory. |
| 64 | +- Each page is a separate test package. |
| 65 | +- Each package has a test class to hold all the tests |
| 66 | +- All tests are separate methods within the test class. |
| 67 | + |
| 68 | +## |
| 69 | +### CREATING TESTS |
| 70 | +This framework uses TestNG. If you aren't familiar with TestNG. Check out the TestNG section below for more info. |
| 71 | + |
| 72 | +With TestNG, every test is its own method with the notation of ```@Test```. |
| 73 | + |
| 74 | +Just like with methods in a Page Object class, organize these in a hybrid alphabetical/functionality order. |
| 75 | +- If there is no related functionality, order it alphabetically. |
| 76 | +- If there is related functionality, put that in order of occurrence. |
| 77 | + |
| 78 | +#### Test Structure |
| 79 | +- A descriptive name for the test |
| 80 | +- Test data/info needed for validation of tests |
| 81 | +- Clean descriptive steps (aka methods from page object class) |
| 82 | +- Assertion - whatever you are validating to ensure the test passes as you expect. |
| 83 | + |
| 84 | +#### Assert |
| 85 | +TestNG provides an "Assert" class with a variety of asserts including: |
| 86 | +- assertEquals |
| 87 | +- assertTrue |
| 88 | +- assertFalse |
| 89 | +- assertNotEquals |
| 90 | + |
| 91 | +#### Example of Creating a New Test |
| 92 | +If you need to create new tests related to a group of test already created, go to that test class, and add the new test there. |
| 93 | + |
| 94 | +If you need to create a test that does not relate to a current test. Add a new package for that particular page, then add the new test. |
| 95 | + |
| 96 | +For example, if you need to add a test for filling in the contact info on the About Me page. We might do something like this. |
| 97 | +1. Go to test -> java |
| 98 | +2. Create a ```aboutMe``` package |
| 99 | +3. Create a ```AboutMeTests``` class under the ```aboutMe``` package. |
| 100 | +4. Make sure ```AboutMeTests``` extends the correct class, in this case that would be ```BaseTests```. |
| 101 | +5. Add a new test, named something like ```testCanSumbitContactForm``` |
| 102 | +6. Add test steps |
| 103 | +7. Assert that form was submitted |
| 104 | +``` |
| 105 | +@Test |
| 106 | +public void testCanSubmitContactForm(){ |
| 107 | +# Go to About Me |
| 108 | +# Fill out contact form |
| 109 | +# Submit that form |
| 110 | +# Assert form was submitted |
| 111 | +} |
| 112 | +``` |
| 113 | +## |
| 114 | +### RUNNING TESTS |
| 115 | +#### Individual Tests |
| 116 | +From IDE |
| 117 | +1. Go to the test class of the test you want to run |
| 118 | +2. Find the test (aka test method) you want to run |
| 119 | +3. Click the play button next to the test |
| 120 | + |
| 121 | +From Command Line |
| 122 | + |
| 123 | +To run tests from the command line, you'll need to have ```mvn``` installed on your device. |
| 124 | +Once you have maven installed on your device, run ```mvn -v```. This verifies maven installed. |
| 125 | + |
| 126 | +- Test Class - run all the tests in an entire class |
| 127 | + |
| 128 | +```mvn test -Dtest=ClassName``` |
| 129 | + |
| 130 | +- Individual Tests |
| 131 | + |
| 132 | +```mvn test -Dtest=ClassName#testMethodName``` |
| 133 | + |
| 134 | +#### Automation Suite |
| 135 | +There are 2 ways to run the entire suite for automation |
| 136 | + |
| 137 | +XML File |
| 138 | +1. Find the "aumniAutomationSuite.xml" file |
| 139 | +2. Run the suite of tests. |
| 140 | + |
| 141 | +Command Line |
| 142 | + |
| 143 | +```mvn test``` |
| 144 | + |
| 145 | + |
| 146 | +## |
| 147 | +### ADDITIONAL RESOURCES |
| 148 | +#### Maven |
| 149 | +If you don't have maven installed on your device, check out this article to help install it on your device. |
| 150 | +[Install Maven](https://www.baeldung.com/install-maven-on-windows-linux-mac) |
| 151 | + |
| 152 | +For mac users, you can install maven view Homebrew by running this command ```brew install maven``` |
| 153 | + |
| 154 | +## |
| 155 | +#### Test NG |
| 156 | +Below are some good resources to help with Test NG if you have never used it before. |
| 157 | + |
| 158 | +TestNG's official site - [TestNG](https://testng.org/doc/) |
| 159 | + |
| 160 | +A good tutorial [Test Automation University](https://testautomationu.applitools.com/) - [Intro to TestNG](https://testautomationu.applitools.com/introduction-to-testng/index.html) |
| 161 | + |
| 162 | +## |
| 163 | +#### Page Object Model |
| 164 | +The article below from BrowserStack provides good info about the POM - [Article on POM](https://www.browserstack.com/guide/page-object-model-in-selenium) |
0 commit comments