Carina is 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 the top of most popular open-source solutions like Selenium, Appium, TestNG which reduces dependability on specific technology stack.
-
Carina covers 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 by 70-80%.
-
As far as our framework is build in Java, it is cross-platform. Tests may be easily executed both on Unix or Windows machines 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 dynamically changed by incoming arguments.
- Initial setup
- Project structure
- Configuration and execution
- Web UI automation
- Web services API automation
- Mobile automation
- Database access setup
- Data-providers usage
- Git configuration
- License
- Install and configure JDK 1.8+
- Install and configure Apache Maven 3.5.2+
- Download and start latest Selenium standalone server
- Download the latest version of Eclipse and install TestNG plugin
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 quoted(e.g.: -Dname="Hello World"). In the Maven command listed above, 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 |
If generation finishes successfully, you should 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
Using this command, Maven should resolve all dependencies, downloading required libraries to your local repository and generating Eclipse classpath. Before importing a new project to Eclipse, you must link your IDE with 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 may 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.
Carina test project is structured as 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/resources - contains TestNG xml files, API templates and XLS data-providers
- src/main/java - contains page object classes, API domains and additional utilities
- src/main/resources - contains l18n bundles, configuration properties files and MyBastis profiles if needed
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")
All project configuration properties are located in _config.properties file. In the table below we are providing description for most of 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} | u1@gmail.com,u2@gmail.com |
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} | carina.qareport@qaprosoft.com |
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
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 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 in the following way:
Configuration.getEnvArg("url")
As a result you switch between environments just changing env argument in _config.properties file.
There are a few options to execute the test, you may run test suite from Eclipse IDE or initiate test execution from the console using the Maven Surefire plugin built into the Carina framework. Before running tests make sure you 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
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
TODO
TODO
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 |
#=============== 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
#=====================================================#
#=================== iOS Mobile ======================#
capabilities.autoAcceptAlerts=true
capabilities.app=/opt/apk/my-apk.app
capabilities.automationName=XCUITest
capabilities.newCommandTimeout=180
capabilities.platformName=IOS
#=====================================================#
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 all old methods of WebElement and new more comfortable Carina methods.
The simpliest 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 criterions is standart:
- 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;
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 |
You can simple transform ExtendedWebElement to WebElement using getElement() method. After this it's possible to operate with standart WebElement methods.
Point point = element.getElement().getLocation();
Dimension dim = element.getElement().getSize();
TODO
TODO
1). Fork repository https://github.com/qaprosoft/carina
to your own user.
2). Clone your fork to your local machine:
git clone git@github.com: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 git@github.com: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 - Apache Software License v2.0
Documentation and Site - Creative Commons Attribution 4.0 International License