Pinscher Testing

“How can I best get up the mountain?” – Just climb upwards, and don’t think about it! Friedrich Nietzsche

Month: April 2016

Testing with NightwatchJS and PhantomJS

Nightwatch.js, based on Node.js, is an End-to-End (E2E) testing solution for browser and web app. Use the power of API Selenium WebDriver to perform commands and assertions on the elements of the DOM.

nightwatchjs site
PhantomJS is a scriptable headless WebKit with API JavaScript. Fast, native to various Web standards: DOM handling, CSS selectors, JSON, Canvas, and SVG.

phantomjs site






An example of step_definition.js ->

module.exports = function() {

    this.Given(/^I open site_example's page$/, function() {
        	.resizeWindow(1024, 768)
            .waitForElementVisible("body", 1000);

    this.When(/^I search for iPhone$/, function() {
        	.waitForElementVisible("//input[@id='short_gsa_search_box']", 1000)
        	.setValue("//input[@id='short_gsa_search_box']", "iphone")

    this.Then(/^the page title is as expected$/, function() {
        this.assert.containsText("//*[@id='c118109']/div[2]/div/span[1]", "Hai cercato: iphone");


nightwatch.conf.js ->

module.exports = {
    "src_folders" : [require('nightwatch-cucumber')()],
    "output_folder" : "reports",
    "custom_commands_path" : "",
    "custom_assertions_path" : "",
    "globals_path" : "",
    "live_output" : false,
    "parallel_process_delay" : 10,
    "disable_colors": false,
    "test_workers" : false,

    "selenium" : {
        "start_process" : false,
        "server_path" : "lib/selenium-server-standalone-2.52.0.jar",
        "log_path" : "logs",
        "host" : "",
        "port" : 6666,
        "cli_args" : {
            "" : "",
            "webdriver.firefox.profile" : ""

    "test_settings" : {
        "default" : {
            "launch_url" : "http://ip_nightwatch_pc",
            "selenium_host" : "ip_nightwatch_pc",
            "selenium_port" : 6666,
            "silent" : true,
            "disable_colors": true,
            "screenshots" : {
                "enabled" : false,
                "path" : ""
			"desiredCapabilities" : {
				"browserName" : "phantomjs",
				"phantomjs.cli.args" : ["--ignore-ssl-errors=true"],
  				"" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36",
  				"phantomjs.binary.path" : "/Users/jenkins/Desktop/nightwatchjs_job_jenkins/phantomjs-2.1.1-macosx/bin/phantomjs",
  				"javascriptEnabled" : true,
  				"acceptSslCerts" : true


package.json ->

  "name": "nightwatchjs",
  "version": "1.0.0",
  "description": "",
  "main": "nightwatch.conf.js",
  "dependencies": {
    "cucumber": "^0.9.5"
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  "author": "",
  "license": "ISC"


feature_example.feature ->

Feature: Homepage Search

Scenario: Searching Homepage

    Given I open example_site's page
    When I search for iPhone
    Then the page title is as expected


Job Jenkins Nightwatch.js on Excute Command bash

  • export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
  • cd /Users/jenkins/workspace/PhantomJS\ Cucumber-Nightwatchjs\ Tests
  • /Users/jenkins/workspace/PhantomJS\ Cucumber-Nightwatchjs\ Tests/node_modules/nightwatch/bin/nightwatch


Happy Testing with Ghosts! XD

Run Selenium Grid on Safari browser

To run your tests on Safari browser need to download selenium-safari-driver-last_version.jar

Selenium Grid Node start with:

java -jar selenium-server-standalone-last_version.jar -role node -nodeConfig nodeconfig.json -Dwebdriver.safari.driver=selenium-safari-driver-last_version.jar

Set nodeconfig.json:

        "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
        "maxSession": 5,
        "port": 4448,
        "register": true,
        "registerCycle": 5000,
        "hubPort": 4444
        "hubHost": "ip_hub"


How to add the WebDriver extension to Safari (Safari extz)

You have to unpack the selenium-safari-driver.jar in selenium folder, copy the files SafariDriver.safariextz downloaded selenium-safari-extension and double click on it.
At this point you will open the extensions preferences safari and you will see the active and installed WebDriver.

Happy testing on Safari!;)

Lint your Swift with Tailor

Tailor is a static analysis and lint tool for source code written in Apple’s Swift programming language. It analyzes your code to ensure consistent styling and help avoid bugs.

Tailor supports Swift 2 out of the box and helps enforce style guidelines outlined in the The Swift Programming Language, GitHub, Ray Wenderlich, and Coursera style guides.


I have integrated Tailor with Jenkins in a job “iOS Tailor Testing – App Example”
tailor –format=json . | tailorf >> tailor_report.html

tailorf is a python formatter created to convert json tailor output in html report.

Structure Project tailorf






Source code of tailorf:

tailor.html ->

<!DOCTYPE html>
    <title>Tailor Report</title>
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

    <!-- Optional theme -->
    <link rel="stylesheet" href="" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">

    <!-- Latest compiled and minified JavaScript -->
    <script src="" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>

<div class="container">




<table class="table table-condensed">

            {% for key, value in data.summary.iteritems() %}

<tr>{{ key }}: {{ value }}</tr>

            {% endfor %}


    {% for file in data.files %}


{{ basename_function(file.path, prefix) }}

<table class="table table-condensed table-bordered">




<td><strong>Location - line/column</strong></td>

<td><strong>Error message</strong></td>


        {% for error in file.violations %}


                <mark>{{ error.severity }}</mark>

<td>{{ error.rule }}</td>

<td>{{ error.location.line }}/{{ error.location.column }}</td>

<td><em>{{ error.message }}</em></td>


        {% endfor %}

    {% endfor %}

</html> ->

import json
import os
import sys

from jinja2 import Environment, PackageLoader

def __basename_function(path, prefix):
    return os.path.relpath(path, prefix)

def format(file=sys.stdin):
    env = Environment(loader=PackageLoader('tailorf', 'templates'))
    env.globals['basename_function'] = __basename_function
    data = json.load(file)
    paths = [file["path"] for file in data["files"]]
    prefix = os.path.commonprefix(paths)
    template = env.get_template('tailor.html')
    print template.render(data=data, prefix=prefix)


requirements.txt ->


setup.cfg ->
description-file = ->
================ ->

from setuptools import setup

    description='Format tailor json output to HTML',
    author='Giuseppe Cilia',
    keywords=['formatter', 'tailor', 'html'],
    package_data={'tailorf': ['templates/*.html']},
        'console_scripts': [
            'tailorf = tailorf:format',


How to install tailorf?
sudo pip install tailorf








SonarQube and Jenkins for Windows Phone App

We have talked many time in many posts of SonarQube but, how to integrate a project for Windows Phone APP and Jenkins for continuous automatic static testing?


in SonarQube.Analysis.xml insert the ip of server, user and password: http://sonar_server_ip:9000
sonar.login: admin
sonar.password: admin

1. Open a Developer Command Prompt for VS2015 from the Start menu.
2. Navigate to the folder containing the project that you want to analyze.
3. Run the following commands:
path=%path%;C:\Sq\MSBuild.SonarQube.Runner-1.0.1 (env variable added)
MSBuild.SonarQube.Runner begin /n:AppExample /v:1.0 /k:blm
MSBuild.SonarQube.Runner end

AppExample is the name of project visualized in Sonar Server Dashboard.

To integrate SonarQube and Jenkins need write the follow code in an Execute Windows batch command:
C:\Sq\MSBuild.SonarQube.Runner-2.0\MSBuild.SonarQube.Runner.exe begin /n:AppWallet /v:1.0 /k:blm
nuget restore WalletApp.sln
MSBuild /t:Clean,Build /p:Configuration=Release
C:\Sq\MSBuild.SonarQube.Runner-2.0\MSBuild.SonarQube.Runner.exe end

Happy Testing;)

Run Selenium Grid on Microsoft Edge browser

To run your tests on Microsoft Edge browser need to download IEDriverServer.exe and MicrosoftWebDriver.exe

Microsoft WebDriver download

IEDriverServer.exe 64 bit Windows IE

IEDriverServer.exe 32 bit Windows IE


Selenium Grid Node start with:

java -jar selenium-server-standalone-last_version.jar -role node -nodeConfig nodeconfig.json -Dwebdriver.edge.driver=”C:\Program Files (x86)\Microsoft Web Driver\MicrosoftWebDriver.exe”

Set nodeconfig.json:

    "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
    "maxSession": 5,
    "port": 4447,
    "register": true,
    "registerCycle": 5000,
    "hubPort": 4444
    "hubHost": "ip_hub"


Happy testing on Microsoft Edge!;)

SonarQube and Jenkins

SonarQube is an open platform to manage code quality. As such, it covers the 7 axes of code quality:

  1. Architecture and Design
  2. Duplications
  3. Unit Tests
  4. Complexity
  5. Potential bugs
  6. Coding rules

SonarQube has got a very efficient way of navigating, a balance between high-level view, dashboard, TimeMachine and defect hunting tools. This enables to quickly uncover projects and/or components that are in Technical Debt to establish action plans.

More than 20 programming languages are covered through plugins.

Get Started in Two Minutes.

  • After download of SonarQube server, sonarqube-downloads
  • #On Windows, execute – C:\sonarqube\bin\windows-x86-xx\StartSonar.bat
    #On other operating system, execute – /etc/sonarqube/bin/[OS]/ console
    SonarQube host url = http://localhost:9000
  • Install a Database (we choose MySql on Mac OS)
    brew install mysql
    mysql.server restart (or from System Preference -> MySQL -> Start MySQL Server)
    create user ‘sonarqube’@’localhost’ identified by ‘sonarqube’;
    create database sonarqube;
    grant all privileges on sonarqube.* to ‘sonarqube’@’localhost’; (assign to user create the DB)
    use sonarqube; (check)
    show tables; (check)
  • Install SonarQube Plugin (* purchase plugins)
  • On Jenkins install the plugin for SonarQube
    sonarqube-jenkins-plugin so to set SonarQube Runner and SonarQube on Jenkins Configuration
  • In let’s set the values for the DB created to SonarQube
  • Continue in SonarQube and Gradle for Android (an example)










Happy Automatic Static Testing with SonarQube;)

SonarQube and Gradle for Android

SonarQube is an open platform to manage code quality. As such, it covers the 7 axes of code quality:
1. Architecture and Design
2. Duplications
3. Unit Tests
4. Complexity
5. Potential bugs
6. Coding rules

Gradle is an open source build automation system that builds upon the concepts of Apache Ant and Apache Maven and introduces a Groovy-based domain-specific language (DSL) instead of the XML form used by Apache Maven of declaring the project configuration. Gradle uses a directed acyclic graph (“DAG”) to determine the order in which tasks can be run.
Gradle was designed for multi-project builds which can grow to be quite large, and supports incremental builds by intelligently determining which parts of the build tree are up-to-date, so that any task dependent upon those parts will not need to be re-executed.

To integrate SonarQube and Gradle in an Android project you need set the build.grade file of the feature in this way:

buildscript {
    repositories {
    dependencies {
        classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:1.2'
subprojects {
    apply plugin: "sonar-runner"
    sonarRunner {
        sonarProperties {
            properties["sonar.sources"] += "src/main/java"

task clean(type: Delete) {

allprojects {
    repositories {

and build.gradle file of the app in this way:

apply plugin: "sonar-runner"

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"
dataBinding {
        	enabled = true
sonarRunner {
        sonarProperties {
            property "", "http://localhost:9000"
            property "sonar.projectKey", "org.sonarqube:java-gradle-simple"
            property "sonar.projectName", "App Demo SonarQube"
            property "sonar.projectDescription", "App Demo SonarQube Description"
            property "sonar.projectVersion", "1.0"
            property "sonar.projectBaseDir", "app/src/main/java"
            property "", "build/sonar"
            property "sonar.scm.provider", "git"

Happy Static Testing with SonarQube!;)

Smartphone Test Farm for iOS

Apple with Xcode 7 introduces UI Testing as new features of the existing XCTest framework.

The UI Testing advantages are:
– Easy UI recording
– Performance Test
– Code Coverage


With UI Testing it is possible to run tests on physical devices and simulators.
Instead of running the tests in series to n devices connected to the MAC through this script you will be able to run the tests in parallel on n device attached (in the example we perform the tests in parallel on four devices at a time).
We must create in this specific case four job for the execution of tests on the devices.

Jenkins job “Smartphone Test Farm iOS”


set -e

job_name="iOS UI Testing Tests - App Example"

function log {
echo "[$(date)] $1"

#Read attached devices
devices=$(instruments -s devices | grep -v Simulator | cut -f2 -d\[ | cut -f1 -d\] | grep -v - | tail -n +2)

if test -z "$devices"; then
log "Warning! no devices found"
exit 1
for i in $devices; do

job_id=$(( $j % ${num_jobs} ))

log "Doing device id: $i"
curl -X POST "https://jenkins_url/job/${job_name}_${job_id}/build" --data-urlencode json="{\"parameter\": {\"name\":\"devices\",\"value\":\"${i}\"}}"
j=$(($j + 1));

log "Invocked jenkins without errors"


#N Jenkins job to execution of tests “iOS UI Testing Tests – App Example”

scan –scheme “example_scheme” –destination ‘id=’${devices}

scan is part of fastlane: connect all deployment tools into one streamlined workflow.
scan uses the latest APIs and tools to make running tests plain simple and offer a great integration into your existing workflow, like fastlane or Jenkins.

STF – Smartphone Test Farm for Android

STF (or Smartphone Test Farm) is a web application for debugging smartphones, smartwatches and other gadgets remotely, from the comfort of your browser.

1. git clone
2. brew install rethinkdb graphicsmagick zeromq protobuf yasm pkg-config
3. npm install -g stf
4. git config –global url. git://
5. npm install
6. npm link
7. rethinkdb
8. stf local –public-ip http://IP_address
9. http://IP_address:7100/#!/devices

Happy Testing with STF!;)


Winium – Windows Phone Testing

Winium, as Appium, is an open source test automation tool, Selenium-based tool, for testing Windows Phone Apps on Emulators.
Winium is an alternative to Coded UI, test automation tool of Visual Studio Enterprise.

In the project that you want to test you just need to add the reference to Winium.StoreApps.InnerServer, run the following command in the Package Manager Console of Visual Studio:
Install-Package Winium.StoreApps.InnerServer

At the source code following add lines to be called on the UI thread after visual root is initialized:

For each element that you want test need to add this instruction:
AutomationProperties.AutomationId = “loginpage” AutomationProperties.Name = “loginpage” (for example you want to scroll login page).

If you want to write tests in Python you need to install Python and Selenium Package:
pip install selenium (selenium-python-installation)

Download and Start Winium Server (Winium.StoreApps.Driver.exe):

and run tests. (python

Test Register Form with Winium, example:

# coding: utf-8
import unittest
import os

from selenium.webdriver import Remote
from import By
from selenium.webdriver.common.keys import Keys

class TestMainPage(unittest.TestCase):
desired_capabilities = {
"app": os.getenv('APPX', '') #we take appx from env and from a job on jenkins (see under test)

def setUp(self):
self.driver = Remote(command_executor="http://localhost:9999",

def test_content(self):
driver = self.driver

#close keyboard
login_page = driver.find_element_by_id('loginPage')

button_register = driver.find_element_by_id('RegisterBtn')

#step 1
name = driver.find_element_by_id('name')
name = driver.find_element_by_id('surname')
credential_page = driver.find_element_by_id('credentialPage')
button_next = driver.find_element_by_id('nextbutton')

#step 2
phone = driver.find_element_by_id('phone')
email = driver.find_element_by_id('email')
contact_page = driver.find_element_by_id('contactPage')
button_next = driver.find_element_by_id('nextbutton')

#step 3
otp = driver.find_element_by_id('otp')
otp_page = driver.find_element_by_id('otpPage')
button_next = driver.find_element_by_id('nextbutton')

#step 4
#switch on/off
privacy = driver.find_element_by_id('privacy')
button_next = driver.find_element_by_id('nextbutton')

#step 5
password = driver.find_element_by_id('password')
conferma_password = driver.find_element_by_id('confermapassword')
password_page = driver.find_element_by_id('passwordPage')
button_next = driver.find_element_by_id('nextbutton')

def tearDown(self):

if __name__ == '__main__':


Jenkins job to creation APPX (execute windows batch command):
nuget restore ExampleApp.sln
MSBuild /t:Clean,Build /p:Configuration=Release


Happy testing on Windows Phone Apps!;)

Powered by WordPress & Theme by Anders Norén