Wednesday 9 September 2015

Mobile Automation: Appium + Selenide (example with Calculator app, Android)

Mobile Automation: Appium + Selenide (example with Calculator app, Android)


How To:


1. add selenide.jar to the project

2. set your driver with WebDriverRunner.setWebDriver(your_driver);

3. write the test with selenide syntax sugar:

Example: standard android Calculator app.

capabilities.setCapability(MobileCapabilityType.APP_PACKAGE, "com.android.calculator2");


capabilities.setCapability(MobileCapabilityType.APP_ACTIVITY, "com.android.calculator2.Calculator");



package test;

import org.openqa.selenium.By;
import org.testng.annotations.*;

import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.Condition.text;

import utilits.TestBase;


public class CalculatorTest extends TestBase {


@Test
public void testCalculator(){

    $(By.name("2")).click();
    $(By.name("+")).click();
    $(By.name("4")).click();
    $(By.name("=")).click();

    $(By.className("android.widget.EditText")).shouldHave(text("6"));
  }

}



Link to gist

Tuesday 1 September 2015

9. Reporting: Selenide + Allure

Reporting:  Selenide + Allure


Concise UI tests require nice Allure reports :)

1. Selenide + Allure + TestNg

2. Selenide + Allure + JUnit  





1. Selenide + Allure + TestNg


Here is an example of test project from 8. Page Object (but using TestNG instead of Junit) with Allure reports. 


Clone a repository from selenide-allure-testng and go to project folder.

To run tests and generate Allure report:

$ mvn clean test
$ mvn site

Report folder:  /target/site/allure-maven-plugin/

To see a report:

$ mvn jetty:run

open http://localhost:8080 in your browser



2. Selenide + Allure + JUnit


Here is an official example from Selenide:
https://github.com/selenide-examples/selenide-allure-junit