Skip to content

Commit 5089532

Browse files
authored
Develop (#67) (#68)
* Develop (#67) * Framework refactored. * Updated config. * Added funding details. * Update issue templates * Issue 55 (#62) * Added annotation @find and modified login page for new page factory. * Updated page factory annotation. * Updated config for headless mode. * Updated:- Listener to log exceptions correctly. - Added logging to page factory. * Updasted dependencies and fixed dependency breaking changes. * Reverted page factory changes. * Driver and DriverAction interfaces further modularized. * Added support for Selenium WebDriver 4.0-alpha 2 * Updating Readme. * Updated Readme, some work is pending. * Updated Readme and removed unnecessary comments from test. * Updated Readme. * Added iFrame support. * Updated readme as per suggesstion. * Updated for getting first frame. * Released v-2.0.0 * Updated Readme.
1 parent 9b0a68a commit 5089532

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2031
-499
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
patreon: wasiqb # Replace with a single Patreon username
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Browser [e.g. chrome, safari]
29+
- Version [e.g. 22]
30+
31+
**Smartphone (please complete the following information):**
32+
- Device: [e.g. iPhone6]
33+
- OS: [e.g. iOS8.1]
34+
- Browser [e.g. stock browser, safari]
35+
- Version [e.g. 22]
36+
37+
**Additional context**
38+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

README.md

Lines changed: 273 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,273 @@
1-
# coteafs-selenium
1+
<p align="center">
2+
<a href="">
3+
<img src="assets/coteafs-selenium-logo.png" width=300 padding=10 />
4+
</a>
5+
</p>
6+
7+
<h1 align="center">Selenium WebDriver wrapper Framework which supports Automation of most of the web browsers.</h1>
8+
9+
[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)][home]
10+
[![CircleCI](https://circleci.com/gh/WasiqB/coteafs-selenium.svg?style=svg)][circleci]
11+
[![Test Coverage](https://sonarcloud.io/api/project_badges/measure?project=com.github.wasiqb.coteafs%3Aselenium&metric=coverage)][coverage]
12+
[![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=com.github.wasiqb.coteafs%3Aselenium&metric=alert_status)](https://sonarcloud.io/dashboard?id=com.github.wasiqb.coteafs%3Aselenium)
13+
[![Maintainability](https://sonarcloud.io/api/project_badges/measure?project=com.github.wasiqb.coteafs%3Aselenium&metric=sqale_rating)](https://sonarcloud.io/component_measures?id=com.github.wasiqb.coteafs%3Aselenium&metric=Maintainability)
14+
[![Reliability](https://sonarcloud.io/api/project_badges/measure?project=com.github.wasiqb.coteafs%3Aselenium&metric=reliability_rating)](https://sonarcloud.io/component_measures?id=com.github.wasiqb.coteafs%3Aselenium&metric=Reliability)
15+
[![Security](https://sonarcloud.io/api/project_badges/measure?project=com.github.wasiqb.coteafs%3Aselenium&metric=security_rating)](https://sonarcloud.io/component_measures?id=com.github.wasiqb.coteafs%3Aselenium&metric=Security)
16+
[![Vulnerability](https://sonarcloud.io/api/project_badges/measure?project=com.github.wasiqb.coteafs%3Aselenium&metric=vulnerabilities)](https://sonarcloud.io/component_measures?id=com.github.wasiqb.coteafs%3Aselenium&metric=new_vulnerabilities)
17+
[![Duplicate Code](https://sonarcloud.io/api/project_badges/measure?project=com.github.wasiqb.coteafs%3Aselenium&metric=duplicated_lines_density)](https://sonarcloud.io/component_measures?id=com.github.wasiqb.coteafs%3Aselenium&metric=Duplications)
18+
[![Maven Central](https://img.shields.io/maven-central/v/com.github.wasiqb.coteafs/selenium.svg)][maven]
19+
[![Github Releases](https://img.shields.io/github/downloads/WasiqB/coteafs-selenium/total.svg)](https://github.com/WasiqB/coteafs-selenium/releases)
20+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
21+
22+
> **Detailed documentation on main project site is under development.**
23+
24+
## :question: What is this Framework about?
25+
26+
This is a Selenium WebDriver wrapper Framework which enables robust, maintainable and easy to write test scripting. _**It supports latest Selenium WebDriver 4.0 (Alpha)**_ and is ready for main Selenium upgrade.
27+
28+
## :bulb: What features does this framework offer?
29+
30+
Nobody uses anything without knowing what it offers. Some of the key features which this framework offers are as follows:
31+
32+
- Latest Selenium WebDriver 4.0 (Alpha 2)
33+
- On-demand highlighting of Elements
34+
- On-demand delay of test execution by allowing predefined delays
35+
- On-demand headless mode
36+
- Parallel execution of tests on different browsers
37+
- Support Chrome, Firefox, IE and Edge
38+
- CI / CD ready
39+
40+
## :smile: How it is easy to write Tests with this Framework?
41+
42+
Writing tests involves the following steps:
43+
44+
1. :wrench: Config file
45+
1. :page_facing_up: Page object
46+
1. :runner: Page Action
47+
1. :ballot_box_with_check: Tests
48+
49+
### :wrench: Config file.
50+
51+
Config file is by default searched in `src/test/resources` folder. The name of the config file is by default considered as `selenium-config.yaml`. But the same can be overridden by using System property `coteafs.selenium.config` where you can specify the new config file for the test.
52+
53+
#### Sample Config file
54+
55+
`src/test/resources/selenium-config.yaml`
56+
57+
```yaml
58+
browser: CHROME # CHROME, EDGE, FIREFOX, IE.
59+
url: http://demo.guru99.com/V4/ # Application URL.
60+
headless_mode: false # true, for headless, else false.
61+
params: # test specific map.
62+
user: <test-specific-user>
63+
password: <test-specific-password>
64+
playback: # Playback settings.
65+
screen_state: NORMAL # FULL_SCREEN, MAXIMIZED, NORMAL
66+
highlight: true # true, to highlight elements, else false.
67+
screen_resolution: # Screen resolution settings.
68+
width: 1280 # Screen width.
69+
height: 768 # Screen height.
70+
delays: # On demand delay settings.
71+
implicit: 60 # Implicit waits in seconds.
72+
explicit: 60 # Explicit waits in seconds.
73+
before_key_press: 0 # delay before key press in milliseconds.
74+
after_key_press: 0 # delay after key press in milliseconds.
75+
before_mouse_move: 0 # delay before mouse move in milliseconds.
76+
after_mouse_move: 0 # delay after mouse move in milliseconds.
77+
before_click: 0 # delay before mouse click in milliseconds.
78+
after_click: 0 # delay after mouse click in milliseconds.
79+
page_load: 60 # page load timeout in seconds.
80+
script_load: 60 # script load timeout in seconds.
81+
highlight: 500 # highlight delay in milliseconds.
82+
screenshot: # Screenshot settings.
83+
path: ~/screenshots # default screenshot path.
84+
prefix: SCR # screenshot file prefix.
85+
extension: jpeg # screenshot file extension.
86+
capture_on_error: false # screenshot on error.
87+
```
88+
89+
> **Note:** If you find any config not working, feel free to raise an [issue][].
90+
91+
### :page_facing_up: Page objects
92+
93+
To know how to write tests, it's best to see the example as it is self explanatory. Lets have a look at the Login page of Guru99 demo site.
94+
95+
> Remember, `BrowserPage` class needs to be extended for every page and also a flavour of inheritance can be added as per requirement.
96+
97+
#### Sample Page object
98+
99+
```java
100+
package com.github.wasiqb.coteafs.selenium.pages;
101+
102+
import org.openqa.selenium.By;
103+
104+
import com.github.wasiqb.coteafs.selenium.core.BrowserPage;
105+
import com.github.wasiqb.coteafs.selenium.core.element.IElementActions;
106+
import com.github.wasiqb.coteafs.selenium.core.element.IMouseActions;
107+
import com.github.wasiqb.coteafs.selenium.core.element.ITextboxActions;
108+
109+
public class LoginPage extends BrowserPage {
110+
public ITextboxActions password () {
111+
return form ().find (By.name ("password"));
112+
}
113+
114+
public IMouseActions signIn () {
115+
return form ().find (By.name ("btnLogin"));
116+
}
117+
118+
public ITextboxActions userId () {
119+
return form ().find (By.name ("uid"));
120+
}
121+
122+
private IElementActions form () {
123+
return onElement (By.name ("frmLogin"));
124+
}
125+
}
126+
```
127+
128+
### :runner: Page Action
129+
130+
This is a new concept, here you can define actions specific to each page. This approach abstracts out the page action flows and helps in modularising the classes. So whenever the flow of the page changes, you need to change only at single place.
131+
132+
> For every page action you need to extend `AbstractPageAction`. Since it is a generic class, you need to pass the action class name as it's generic type.
133+
> Also, `perform` method needs to be implemented for every action class.
134+
135+
#### Sample page action
136+
137+
```java
138+
package com.github.wasiqb.coteafs.selenium.pages.action;
139+
140+
import com.github.wasiqb.coteafs.selenium.core.page.AbstractPageAction;
141+
import com.github.wasiqb.coteafs.selenium.pages.LoginPage;
142+
import com.github.wasiqb.coteafs.selenium.pages.MainPage;
143+
144+
public class LoginPageAction extends AbstractPageAction <LoginPageAction> {
145+
@Override
146+
public void perform () {
147+
final LoginPage login = new LoginPage ();
148+
login.userId ()
149+
.enterText (value ("UserId"));
150+
login.password ()
151+
.enterText (value ("Password"));
152+
login.signIn ()
153+
.click ();
154+
155+
final MainPage main = new MainPage ();
156+
main.managerIdBanner ()
157+
.verifyText ()
158+
.endsWith ("Manger Id : " + value ("UserId"));
159+
}
160+
}
161+
```
162+
163+
### :white_check_mark: Tests
164+
165+
Test which are written using this framework are slightly different than usual. In the tests, Page actions is used instead of page objects. This can be demonstrated as shown below:
166+
167+
#### Sample Test
168+
169+
> Every test class extends `BrowserTest` class.
170+
171+
```java
172+
package com.github.wasiqb.coteafs.selenium;
173+
174+
import static com.github.wasiqb.coteafs.selenium.config.ConfigUtil.appSetting;
175+
176+
import org.testng.annotations.BeforeClass;
177+
import org.testng.annotations.Test;
178+
179+
import com.github.wasiqb.coteafs.selenium.core.BrowserTest;
180+
import com.github.wasiqb.coteafs.selenium.pages.MainPage;
181+
import com.github.wasiqb.coteafs.selenium.pages.action.LoginPageAction;
182+
183+
public class SeleniumTest extends BrowserTest {
184+
private MainPage main;
185+
186+
@BeforeClass
187+
public void setupMethod () {
188+
this.main = new MainPage ();
189+
this.main.onDriver ()
190+
.navigateTo (appSetting ().getUrl ());
191+
}
192+
193+
@Test
194+
public void testSignIn () {
195+
final LoginPageAction login = new LoginPageAction ();
196+
login.addInputValue ("UserId", appSetting ().getParams ()
197+
.get ("user"))
198+
.addInputValue ("Password", appSetting ().getParams ()
199+
.get ("password"))
200+
.perform ();
201+
}
202+
}
203+
```
204+
205+
## :pushpin: Usage?
206+
207+
You can use the following dependency into your `pom.xml` to use this library.
208+
209+
```xml
210+
<dependency>
211+
<groupId>com.github.wasiqb.coteafs</groupId>
212+
<artifactId>selenium</artifactId>
213+
<version>2.0.0</version>
214+
</dependency>
215+
```
216+
217+
## :question: Need Assistance?
218+
219+
- Directly chat with me on my [site][] and I'll revert to you as soon as possible.
220+
- Discuss your queries by writing to me @ [wasbhamla2005@gmail.com][mail]
221+
- If you find any issue which is bottleneck for you, [search the issue tracker][tracker] to see if it is already raised.
222+
- If not raised, then you can create a [new issue][issue] with required details as mentioned in the issue template.
223+
224+
## :star2: What you do if you like the project?
225+
226+
- Spread the word with your network.
227+
- **Star** the project to make the project popular.
228+
- Stay updated with the project progress by **Watching** it.
229+
- **Contribute** to fix open issues, documentations or add new features. To know more, see our [contributing][] page.
230+
- I would be delighted if you can **Sponsor** this project and provide your support to open source development by clicking on the Sponsor button on the top of this repository.
231+
232+
## :white_check_mark: Contributors
233+
234+
<div>
235+
<ul>
236+
<li>
237+
<a href="https://github.com/WasiqB">
238+
<img alt="Wasiq Bhamla: Framework developer and maintainer." src="https://github.com/WasiqB.png" width=100 height=100 />
239+
</a>
240+
</li>
241+
<li>
242+
<a href="https://github.com/mfaisalkhatri">
243+
<img alt="Mohammad Faisal Khatri: Framework Tester." src="https://github.com/mfaisalkhatri.png" width=100 height=100 />
244+
</a>
245+
</li>
246+
</ul>
247+
</div>
248+
249+
## :ticket: Versioning ideology
250+
251+
<p align="left">
252+
<a href="http://semver.org/">
253+
<img src="assets/semver.png" width=300 />
254+
</a>
255+
</p>
256+
257+
## :copyright: Wasiq Bhamla
258+
259+
<p align="left">
260+
<a href="http://www.apache.org/licenses/LICENSE-2.0">
261+
<img src="http://www.apache.org/img/asf_logo.png" width=300 />
262+
</a>
263+
</p>
264+
265+
[home]: https://github.com/wasiqb/coteafs-selenium
266+
[circleci]: https://circleci.com/gh/WasiqB/coteafs-selenium
267+
[coverage]: https://sonarcloud.io/component_measures?id=com.github.wasiqb.coteafs%3Aselenium&metric=Coverage
268+
[maven]: https://maven-badges.herokuapp.com/maven-central/com.github.wasiqb.coteafs/selenium
269+
[site]: https://wasiqb.github.io
270+
[tracker]: https://github.com/WasiqB/coteafs-selenium/issues?q=something
271+
[issue]: https://github.com/WasiqB/coteafs-selenium/issues/new
272+
[contributing]: .github/CONTRIBUTING.md
273+
[mail]: mailto:wasbhamla2005@gmail.com

assets/coteafs-selenium-logo.png

19.5 KB
Loading

assets/semver.png

196 KB
Loading

pom.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
55
<artifactId>selenium</artifactId>
6-
<version>1.0.0-beta4</version>
6+
<version>2.0.0</version>
77
<name>coteafs-selenium</name>
8-
<description>A Tester friendly framework for Web App Automation using Selenium</description>
8+
<description>Selenium WebDriver wrapper framework for clean and maintainable tests.</description>
99
<url>https://github.com/WasiqB/coteafs-selenium</url>
1010

1111
<parent>
1212
<groupId>com.github.wasiqb.coteafs</groupId>
1313
<artifactId>parent</artifactId>
14-
<version>2.1.0</version>
14+
<version>2.2.0</version>
1515
</parent>
1616

1717
<scm>
@@ -26,13 +26,13 @@
2626
</ciManagement>
2727

2828
<properties>
29-
<coteafs.config.version>1.7.0</coteafs.config.version>
30-
<coteafs.error.version>1.6.0</coteafs.error.version>
31-
<coteafs.logger.version>1.7.0</coteafs.logger.version>
32-
<selenium-version>3.141.59</selenium-version>
29+
<coteafs.config.version>1.8.0</coteafs.config.version>
30+
<coteafs.error.version>1.7.0</coteafs.error.version>
31+
<coteafs.logger.version>1.8.0</coteafs.logger.version>
32+
<selenium-version>4.0.0-alpha-2</selenium-version>
3333
<commons.io.version>2.6</commons.io.version>
34-
<webdrivermanager-version>3.4.0</webdrivermanager-version>
35-
<faker.version>0.17.2</faker.version>
34+
<webdrivermanager-version>3.6.1</webdrivermanager-version>
35+
<faker.version>0.18</faker.version>
3636
</properties>
3737

3838
<dependencies>

src/main/java/com/github/wasiqb/coteafs/selenium/config/ApplicationSetting.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import java.util.HashMap;
1919
import java.util.Map;
2020

21+
import com.github.wasiqb.coteafs.selenium.core.enums.AvailableBrowser;
22+
2123
/**
2224
* @author Wasiq Bhamla
2325
* @since Apr 8, 2018 2:41:06 PM

src/main/java/com/github/wasiqb/coteafs/selenium/config/PlaybackSetting.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
package com.github.wasiqb.coteafs.selenium.config;
1717

18+
import com.github.wasiqb.coteafs.selenium.core.enums.ScreenState;
19+
1820
/**
1921
* @author Wasiq Bhamla
2022
* @since Apr 8, 2018 2:45:29 PM

0 commit comments

Comments
 (0)