Skip to content

Commit

Permalink
Develop (#67) (#68)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
WasiqB authored Jul 7, 2019
1 parent 9b0a68a commit 5089532
Show file tree
Hide file tree
Showing 61 changed files with 2,031 additions and 499 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
patreon: wasiqb # Replace with a single Patreon username
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
274 changes: 273 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,273 @@
# coteafs-selenium
<p align="center">
<a href="">
<img src="assets/coteafs-selenium-logo.png" width=300 padding=10 />
</a>
</p>

<h1 align="center">Selenium WebDriver wrapper Framework which supports Automation of most of the web browsers.</h1>

[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)][home]
[![CircleCI](https://circleci.com/gh/WasiqB/coteafs-selenium.svg?style=svg)][circleci]
[![Test Coverage](https://sonarcloud.io/api/project_badges/measure?project=com.github.wasiqb.coteafs%3Aselenium&metric=coverage)][coverage]
[![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)
[![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)
[![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)
[![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)
[![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)
[![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)
[![Maven Central](https://img.shields.io/maven-central/v/com.github.wasiqb.coteafs/selenium.svg)][maven]
[![Github Releases](https://img.shields.io/github/downloads/WasiqB/coteafs-selenium/total.svg)](https://github.com/WasiqB/coteafs-selenium/releases)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

> **Detailed documentation on main project site is under development.**
## :question: What is this Framework about?

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.

## :bulb: What features does this framework offer?

Nobody uses anything without knowing what it offers. Some of the key features which this framework offers are as follows:

- Latest Selenium WebDriver 4.0 (Alpha 2)
- On-demand highlighting of Elements
- On-demand delay of test execution by allowing predefined delays
- On-demand headless mode
- Parallel execution of tests on different browsers
- Support Chrome, Firefox, IE and Edge
- CI / CD ready

## :smile: How it is easy to write Tests with this Framework?

Writing tests involves the following steps:

1. :wrench: Config file
1. :page_facing_up: Page object
1. :runner: Page Action
1. :ballot_box_with_check: Tests

### :wrench: Config file.

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.

#### Sample Config file

`src/test/resources/selenium-config.yaml`

```yaml
browser: CHROME # CHROME, EDGE, FIREFOX, IE.
url: http://demo.guru99.com/V4/ # Application URL.
headless_mode: false # true, for headless, else false.
params: # test specific map.
user: <test-specific-user>
password: <test-specific-password>
playback: # Playback settings.
screen_state: NORMAL # FULL_SCREEN, MAXIMIZED, NORMAL
highlight: true # true, to highlight elements, else false.
screen_resolution: # Screen resolution settings.
width: 1280 # Screen width.
height: 768 # Screen height.
delays: # On demand delay settings.
implicit: 60 # Implicit waits in seconds.
explicit: 60 # Explicit waits in seconds.
before_key_press: 0 # delay before key press in milliseconds.
after_key_press: 0 # delay after key press in milliseconds.
before_mouse_move: 0 # delay before mouse move in milliseconds.
after_mouse_move: 0 # delay after mouse move in milliseconds.
before_click: 0 # delay before mouse click in milliseconds.
after_click: 0 # delay after mouse click in milliseconds.
page_load: 60 # page load timeout in seconds.
script_load: 60 # script load timeout in seconds.
highlight: 500 # highlight delay in milliseconds.
screenshot: # Screenshot settings.
path: ~/screenshots # default screenshot path.
prefix: SCR # screenshot file prefix.
extension: jpeg # screenshot file extension.
capture_on_error: false # screenshot on error.
```
> **Note:** If you find any config not working, feel free to raise an [issue][].
### :page_facing_up: Page objects
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.
> Remember, `BrowserPage` class needs to be extended for every page and also a flavour of inheritance can be added as per requirement.

#### Sample Page object

```java
package com.github.wasiqb.coteafs.selenium.pages;
import org.openqa.selenium.By;
import com.github.wasiqb.coteafs.selenium.core.BrowserPage;
import com.github.wasiqb.coteafs.selenium.core.element.IElementActions;
import com.github.wasiqb.coteafs.selenium.core.element.IMouseActions;
import com.github.wasiqb.coteafs.selenium.core.element.ITextboxActions;
public class LoginPage extends BrowserPage {
public ITextboxActions password () {
return form ().find (By.name ("password"));
}
public IMouseActions signIn () {
return form ().find (By.name ("btnLogin"));
}
public ITextboxActions userId () {
return form ().find (By.name ("uid"));
}
private IElementActions form () {
return onElement (By.name ("frmLogin"));
}
}
```

### :runner: Page Action

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.

> 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.
> Also, `perform` method needs to be implemented for every action class.

#### Sample page action

```java
package com.github.wasiqb.coteafs.selenium.pages.action;
import com.github.wasiqb.coteafs.selenium.core.page.AbstractPageAction;
import com.github.wasiqb.coteafs.selenium.pages.LoginPage;
import com.github.wasiqb.coteafs.selenium.pages.MainPage;
public class LoginPageAction extends AbstractPageAction <LoginPageAction> {
@Override
public void perform () {
final LoginPage login = new LoginPage ();
login.userId ()
.enterText (value ("UserId"));
login.password ()
.enterText (value ("Password"));
login.signIn ()
.click ();
final MainPage main = new MainPage ();
main.managerIdBanner ()
.verifyText ()
.endsWith ("Manger Id : " + value ("UserId"));
}
}
```

### :white_check_mark: Tests

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:

#### Sample Test

> Every test class extends `BrowserTest` class.

```java
package com.github.wasiqb.coteafs.selenium;
import static com.github.wasiqb.coteafs.selenium.config.ConfigUtil.appSetting;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.github.wasiqb.coteafs.selenium.core.BrowserTest;
import com.github.wasiqb.coteafs.selenium.pages.MainPage;
import com.github.wasiqb.coteafs.selenium.pages.action.LoginPageAction;
public class SeleniumTest extends BrowserTest {
private MainPage main;
@BeforeClass
public void setupMethod () {
this.main = new MainPage ();
this.main.onDriver ()
.navigateTo (appSetting ().getUrl ());
}
@Test
public void testSignIn () {
final LoginPageAction login = new LoginPageAction ();
login.addInputValue ("UserId", appSetting ().getParams ()
.get ("user"))
.addInputValue ("Password", appSetting ().getParams ()
.get ("password"))
.perform ();
}
}
```

## :pushpin: Usage?

You can use the following dependency into your `pom.xml` to use this library.

```xml
<dependency>
<groupId>com.github.wasiqb.coteafs</groupId>
<artifactId>selenium</artifactId>
<version>2.0.0</version>
</dependency>
```

## :question: Need Assistance?

- Directly chat with me on my [site][] and I'll revert to you as soon as possible.
- Discuss your queries by writing to me @ [[email protected]][mail]
- If you find any issue which is bottleneck for you, [search the issue tracker][tracker] to see if it is already raised.
- If not raised, then you can create a [new issue][issue] with required details as mentioned in the issue template.

## :star2: What you do if you like the project?

- Spread the word with your network.
- **Star** the project to make the project popular.
- Stay updated with the project progress by **Watching** it.
- **Contribute** to fix open issues, documentations or add new features. To know more, see our [contributing][] page.
- 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.

## :white_check_mark: Contributors

<div>
<ul>
<li>
<a href="https://github.com/WasiqB">
<img alt="Wasiq Bhamla: Framework developer and maintainer." src="https://github.com/WasiqB.png" width=100 height=100 />
</a>
</li>
<li>
<a href="https://github.com/mfaisalkhatri">
<img alt="Mohammad Faisal Khatri: Framework Tester." src="https://github.com/mfaisalkhatri.png" width=100 height=100 />
</a>
</li>
</ul>
</div>

## :ticket: Versioning ideology

<p align="left">
<a href="http://semver.org/">
<img src="assets/semver.png" width=300 />
</a>
</p>

## :copyright: Wasiq Bhamla

<p align="left">
<a href="http://www.apache.org/licenses/LICENSE-2.0">
<img src="http://www.apache.org/img/asf_logo.png" width=300 />
</a>
</p>

[home]: https://github.com/wasiqb/coteafs-selenium
[circleci]: https://circleci.com/gh/WasiqB/coteafs-selenium
[coverage]: https://sonarcloud.io/component_measures?id=com.github.wasiqb.coteafs%3Aselenium&metric=Coverage
[maven]: https://maven-badges.herokuapp.com/maven-central/com.github.wasiqb.coteafs/selenium
[site]: https://wasiqb.github.io
[tracker]: https://github.com/WasiqB/coteafs-selenium/issues?q=something
[issue]: https://github.com/WasiqB/coteafs-selenium/issues/new
[contributing]: .github/CONTRIBUTING.md
[mail]: mailto:[email protected]
Binary file added assets/coteafs-selenium-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/semver.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>selenium</artifactId>
<version>1.0.0-beta4</version>
<version>2.0.0</version>
<name>coteafs-selenium</name>
<description>A Tester friendly framework for Web App Automation using Selenium</description>
<description>Selenium WebDriver wrapper framework for clean and maintainable tests.</description>
<url>https://github.com/WasiqB/coteafs-selenium</url>

<parent>
<groupId>com.github.wasiqb.coteafs</groupId>
<artifactId>parent</artifactId>
<version>2.1.0</version>
<version>2.2.0</version>
</parent>

<scm>
Expand All @@ -26,13 +26,13 @@
</ciManagement>

<properties>
<coteafs.config.version>1.7.0</coteafs.config.version>
<coteafs.error.version>1.6.0</coteafs.error.version>
<coteafs.logger.version>1.7.0</coteafs.logger.version>
<selenium-version>3.141.59</selenium-version>
<coteafs.config.version>1.8.0</coteafs.config.version>
<coteafs.error.version>1.7.0</coteafs.error.version>
<coteafs.logger.version>1.8.0</coteafs.logger.version>
<selenium-version>4.0.0-alpha-2</selenium-version>
<commons.io.version>2.6</commons.io.version>
<webdrivermanager-version>3.4.0</webdrivermanager-version>
<faker.version>0.17.2</faker.version>
<webdrivermanager-version>3.6.1</webdrivermanager-version>
<faker.version>0.18</faker.version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import java.util.HashMap;
import java.util.Map;

import com.github.wasiqb.coteafs.selenium.core.enums.AvailableBrowser;

/**
* @author Wasiq Bhamla
* @since Apr 8, 2018 2:41:06 PM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.github.wasiqb.coteafs.selenium.config;

import com.github.wasiqb.coteafs.selenium.core.enums.ScreenState;

/**
* @author Wasiq Bhamla
* @since Apr 8, 2018 2:45:29 PM
Expand Down
Loading

0 comments on commit 5089532

Please sign in to comment.