Git Product home page Git Product logo

carina's Introduction

Alt text

Carina Automation Framework

Carina is a Java-based test automation framework that unites all testing layers: Mobile applications (web, native, hybrid), WEB applications, REST services, Databases.

  • Carina framework is built on top of most popular open-source solutions like Selenium, Appium, TestNG allowing to reduce dependence on specific technology stack.

  • Carina supports all popular browsers (IE, Safari, Chrome, Firefox) and mobile devices (iOS/Android). Special feature for mobile domain: it reuses test automation code between IOS/Android up to 70-80%.

  • As far as our framework is built in Java, it is cross-platform. Tests may be easily executed both on Unix or Windows OS. All you need is JDK 8 installed.

  • Framework supports different types of databases - both relational and nonrelational (MySQL, SQL Server, Oracle, PostgreSQL), providing amazing experience of DAO layer implementation using MyBatis ORM framework.

  • API testing is based on Freemarker template engine. It enables great flexibility in generating REST requests and responses are dynamically changed by incoming arguments.

Alt text

TRY DEMO PROJECT NOW

Сontents

Initial setup

Generating project

The easiest way to initialize new project is to use Carina archetype, you will get correct project structure along with test samples:

mvn archetype:generate -DarchetypeGroupId=com.qaprosoft \
                       -DarchetypeArtifactId=carina-archetype \
                       -DarchetypeVersion=1.0 \
                       -DgroupId=<your_groupId> \ 
                       -DartifactId=<your_artifactId> \ 
                       -Dname="<you_proj_name>" \
                       -Durl=<your_proj_url> \
                       -Dversion=<your_proj_version>

If any attribute contains spaces, it should be set in quotes (e.g.: -Dname="Hello World"). In above Maven command you have to specify 5 attributes while the first 3 should be left unchanged. Let's go through these attributes:

Attribute Meaning Example
-DgroupId Company domain in reverce order com.qaprosoft
-DartifactId Java project name carina-qa
-Dname Name with more details "Carina Test Automation"
-Durl Company URL http://qaprosoft.com
-Dversion Project version 1.0

Import to Eclipse

If generation is successfully complete, you would see a new project folder with a name equal to the artifactId attribute specified during generation, so navigate to that folder (where pom.xml is located) and execute the following Maven task:

mvn clean eclipse:eclipse

By executing this command, Maven should resolve all dependencies, downloading required libraries to your local repository and generating Eclipse classpath. Before importing new project to Eclipse, you should link your IDE to your Maven repository by executing the following task:

mvn -Dworkspace=<path_to_workspace> eclipse:configure-workspace

Here you have to specify the absolute path to the Eclipse workspace. After that, restart Eclipse IDE. Now you can import generated projects such as "Existing Java Project" into Eclipse IDE. Generate Eclipse workspace using command:

mvn clean eclipse:eclipse

Now you are ready to import project into Eclipse.

Eclipse view

Project structure

Carina test project is structured as a standard Maven project:

carina-demo
|-- pom.xml
|-- src/test/java        
|-- src/test/resources
    |-- api
    |-- testng_suites
    |-- xls
|-- src/main/java
|-- src/main/resources
    |-- l18n
  • src/test/java - contains test classes organized using TestNG annotations

src/test/java

  • src/test/resources - contains TestNG xml files, API templates and XLS data providers

src/test/resources

  • src/main/java - contains page object classes, API domains and additional utilities

src/main/java

  • src/main/resources - contains l18n bundles, configuration properties files and MyBastis profiles if needed

src/main/resources

Configuration and execution

There are multiple properties files located in src/main/resources:

  • _api.properties - API test endpoints reference
  • _config.properties - global test configuration
  • _database.properties - database connection properties
  • _email.properties - emailable reports config
  • _testdata.properties - test user credentials

All properties may be retrieved in test using R class:

R.API.get("GetUserMethods")
R.CONFIG.get("browser")
R.DATABASE.get("db.url")
R.EMAIL.get("title")
R.TESTDATA.get("user.email")

Default config properties can be obtained by

Configuration.get(Parameter.EXTRA_CAPABILITIES)

All project configuration properties are located in _config.properties file. In the table below we are providing description for most of the parameters:

Attribute Meaning Default value Example
url Base application URL {must_override} http://qaprosoft.com
browser Browser for testing chrome chrome / firefox / safari / iexplore
selenium_host Selenium server host {must_override} http://localhost:4444/wd/hub
app_version Application version/build number for reporting n/a 1.2.5
locale Locale for using L10N feature. Enabled when enable_l10n=true en_US en_GB,de_DE,fr_FR
language Language for i18n defature. Enabled when enable_i18n=true en_US en_GB,de_DE,fr_FR
implicit_timeout Implicit timeout in seconds to wait for element 10 Integer
retry_internal Timeout interval between calling HTML DOM for the element.
Note: in ms. For mobile automation specify number from 500-1500 range
2 Integer
auto_screenshot Global switch for taking screenshots. When disabled only failures will be captured true Boolean
keep_all_screenshots Keep screenshots artifacts even for passed tests. false
report_url Direct HTTP link to Jenkins workspace report folder. Automatically specified by CI n/a http://localhost:8888/job/my_project/1/eTAF_Report
max_screen_history Max number of reports in history 10 Integer
jira_url JIRA base URL for direct links with bugs description n/a https://jira.carina.com/browse/
email_list Comma-separated list of emails for reports {must_override} [email protected],[email protected]
sender_email Email account for reports sending.
Note: Gmail smtp settings are used by default. Update _email.properties to use your own SMTP server
{must_override} [email protected]
sender_pswd Email password for reports sending {must_override} pwd123

Most of the properties may be read in the following way:

Configuration.get(Parameter.URL) // returns string value
Configuration.getBoolean(Parameter.AUTO_SCREENSHOT) // returns boolean value
Configuration.getInt(Parameter.SMALL_SCREEN_WIDTH) // returns integer value
Configuration.getDouble(Parameter.BROWSER_VERSION) // returns double value

Environment specific configuration

In some cases it is required to support multiple environments for testing. Let's assume we have STAG and PROD environments which have different application URLs. In this case we need to specify the following properties in _config.properties:

env=DEMO
STAG.url=http://stag-app-server.com
PROD.url=http://prod-app-server.com

And get env-specific argument in test the following way:

Configuration.getEnvArg("url")

As a result you switch between environments just changing env argument in _config.properties file.

Execution

There are a several options to execute the test: you may run test suite from Eclipse IDE or initiate test execution from the console using Maven Surefire plugin built into Carina framework. Before running tests make sure you have downloaded Selenium standalone server jar file and started it by the following command:

java -jar selenium-server-standalone-3.6.0.jar

To run the test suite from Eclipse IDE, just select the required TestNG xml file: Right click > Run As > TestNG suite

Execution from Eclipse IDE

To run the same test suite from the console, navigate to the test project root (where pom.xml is located) and execute the following command:

mvn clean -Dsuite=api test

Web UI automation

In the table below we are providing description for most important WEB parameters:

Attribute Meaning Default value Example
browser Browser for testing chrome chrome / firefox / safari / iexplore
selenium_host Selenium server host {must_override} http://localhost:4444/wd/hub
driver_mode Rule for defining WebDriver lifecycle. method_mode method_mode / class_mode / suite_mode

Web services API automation

TODO

Mobile automation

We could provide any Appium capabilty in _config.properties file using capabilities.< name >=< value > format. In the table below we are providing description for the most popular mobile capabilities:

Attribute Meaning Default value Example
capabilities.deviceName Device name for report n/a Sumsung_Galaxy_J5
capabilities.deviceType The only custom carina capability to detmine type of device n/a phone/tablet/tv...
capabilities.platformName Name of mobile platform n/a Android/iOS/AndroidTV/tvOS
capabilities.platformVersion Version of mobile platform n/a 6.0.1
capabilities.automationName Name of programm using for automation n/a Appium/uiautomator2/XCUITest
capabilities.app Path to application (apk/app/ipa) which is tested, Can be provided as a pattern from AWS S3 storage with automatic downloading... n/a D:/application.apk
capabilities.newCommandTimeout New implicit timeout in seconds to wait for element for mobile automation n/a 180
capabilities.udid Unique Device ID n/a 759b543c

For Android:

#=============== Android Mobile ======================#
capabilities.deviceName=Samsung_Galaxy_J5
capabilities.app=s3://qaprosoft.com/android/myapk.*-release.apk
capabilities.skipUnlock=true
capabilities.noSign=true
capabilities.automationName=uiautomator2
capabilities.newCommandTimeout=180
capabilities.platformName=ANDROID
capabilities.autoGrantPermissions=true
#=====================================================#

For iOS:

#=================== iOS Mobile ======================#
capabilities.autoAcceptAlerts=true
capabilities.app=/opt/apk/my-apk.app
capabilities.automationName=XCUITest
capabilities.newCommandTimeout=180
capabilities.platformName=IOS
#=====================================================#

ExtendedWebElement

ExtendedWebElement is an extended version of selenium WebElement which you can find in org.openqa.selenium package. The best thing in using ExtendedWebElement is that you can use both old methods of WebElement and new more convenient Carina methods.

The easiest way to find ExtendedWebElement is using annotation @FindBy. The @FindBy annotation is used to locate one or more ExtendedWebElements using a single criterion. The list of criteria is standard:

  • className
  • css
  • how...using
  • id
  • linkText
  • name
  • partialLinkText
  • tagName
  • xpath
    @FindBy(name = "Hybrid")
    private ExtendedWebElement hybridUnits;

    @FindBy(id = "com.ua.record.debug:id/spinner_text")
    private List <ExtendedWebElement> unitsVersions;

ExtededWebElement's methods

Most usable methods are reperesented in the table bellow:

Method Return type Description
getName() String Get the name of this element
getText() String Get the visible innerText of this element
getAttribute() String Get the value of a the given attribute of this element
click() void Click on element
doubleClick() void Double click on element
isElementPresent() boolean Is element present or not?
isElementPresent(long timeout) boolean Is element present or not during the timeout in seconds?
isElementNotPresent(long timeout) boolean Is element not present during the timeout in seconds?
isElementWithTextPresent(String text) boolean Is element with text present or not?
isElementWithTextPresent(String text, long timeout) boolean Is element with text present or not during the timeout in seconds?
clickIfPresent boolean Click on element if it's presented, return true if click is performed
type(String text) void Clear the value of field and simulate typing the text
scrollTo() void Scroll page until the element could be located
check() void If element is checkable it will be checked
uncheck() void If element is checkable it will be unchecked
isCheck() boolean If element is checkable return is the element checked or not
tapWithCoordinates(double x, double y) void Tap on screen using the given cordinates

How to use WebDriver methods?

You can simply transform ExtendedWebElement to WebElement using getElement() method. After this it's possible to operate with standard WebElement methods.

   Point point = element.getElement().getLocation();
   Dimension dim = element.getElement().getSize();

Database access setup

TODO

Data providers usage

TODO

Git configuration

1). Fork repository https://github.com/qaprosoft/carina to your own user.

2). Clone your fork to your local machine:

git clone [email protected]:your_fork_url/carina.git

3). git remote add origin <your_fork_url> (can be already added)

4). git fetch origin

5). git remote add upstream [email protected]:qaprosoft/carina.git

6). git fetch upstream

7). git checkout -b work_local_branch upstream/master

And then after adding files (git add ...) use git commit (add description) and thenpush:

git push origin work_local_branch:work_remote_branch

And on https://github.com/qaprosoft/carina you will see possibility to "Compare & Pull Request"

Code formatter

We propose to use our configured java code formatter for Eclipse. It is available here https://github.com/qaprosoft/carina/carina_formatter.xml

To use same formatter in IntelliJ IDEA you should installEclipse Code Formatter

And configure it.

License

Code - Apache Software License v2.0

Documentation and Site - Creative Commons Attribution 4.0 International License

carina's People

Contributors

akupriyanov avatar crazypear avatar dariayakubovich avatar dmitry-minchuk avatar hursevich avatar igorv22 avatar imikulich avatar kolyakrasnik avatar maksimsarychau avatar mikalaib avatar mikalaibiazruchka avatar nazarenkav avatar patotskiy avatar pkebets avatar sergeizagriychuk avatar siarhei-babich avatar tamikana avatar tsvrko avatar vdelendik avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.