You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+78Lines changed: 78 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -105,3 +105,81 @@ The project is structured as follows:
105
105
├─ login.csv
106
106
└─ products.csv
107
107
```
108
+
109
+
## Basic Usage
110
+
111
+
-### Configuration
112
+
The project uses a [*config.properties*](./src/test/resources/config.properties) file to manage global configurations such as browser type and base url.
113
+
114
+
1. To add a new property, register a new entry in this file.
115
+
```
116
+
key=value
117
+
```
118
+
119
+
Then, add a method in the [*Configuration*](./src/main/java/io/github/tahanima/config/Configuration.java) interface in the below format.
120
+
```java
121
+
@Key("key")
122
+
dataType key();
123
+
```
124
+
125
+
For example, let's say I want to add a new property named `context` with the value `dev`. In the `config.properties` file, I'll add:
126
+
```
127
+
context=dev
128
+
```
129
+
130
+
In the `Configuration` interface, I'll add:
131
+
```java
132
+
@Key("context")
133
+
String context();
134
+
```
135
+
136
+
To use your newly created property, you need to use the below import statement.
Then, you can call `config().key()` to retrieve the value of your newly created property. For the example I've provided, I need to call `config().context()`.
142
+
143
+
2. You can supply the properties present in the `config.properties` file as system properties in your test via gradle.
144
+
```bash
145
+
./gradlew test -Dkey1=value1 -Dkey2=value2
146
+
```
147
+
148
+
- ### Test Data
149
+
The project uses *csv* file to store test data and [*univocity-parsers*](https://github.com/uniVocity/univocity-parsers) to retrieve the data and map it to a Java bean.
150
+
151
+
To add configurations for new test data, add a new Java bean in the [*data*](./src/main/java/io/github/tahanima/data) package. For example, let's say I want to add test data for a `User` with the attributes `First Name` and `Last Name`. The code for this is as follows:
Note that the class extends from BaseData and thus, inherits the attribute `Test Case ID`.
173
+
174
+
Now, in the [*testdata*](./src/test/resources/testdata) folder you can add a csv file `user.csv` for `User` with the below contents and use it in your tests.
175
+
```
176
+
Test Case ID,First Name,Last Name
177
+
TC-1,Tahanima,Chowdhury
178
+
```
179
+
For reference, check [this](./src/main/java/io/github/tahanima/data/LoginData.java), [this](./src/test/resources/testdata/login.csv) and [this](./src/test/java/io/github/tahanima/e2e/LoginE2ETest.java).
180
+
181
+
-### Page Objects and Page Component Objects
182
+
The project uses [*Page Objects* and *Page Component Objects*](https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/) to capture the relevant behaviors of a web page. Check the [*ui*](./src/main/java/io/github/tahanima/ui) package for reference.
183
+
184
+
-### Tests
185
+
The project uses *TestNG* as the test runner. Check [this implementation](./src/test/java/io/github/tahanima/e2e/LoginE2ETest.java) for reference.
0 commit comments