AgileTestware

Selenium & Appium Integration

Report Selenium WebDriver and Appium test results to HP ALM via Bumblebee.

Overview

Selenium and Appium tests are typically written using JUnit or TestNG as the test runner. The ALM integration works through the test runner — configure the JUnit or TestNG integration, and Selenium/Appium results flow through automatically.

Java + JUnit + Selenium

Maven Setup

<dependencies>
  <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>4.15.0</version>
  </dependency>
  <dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter</artifactId>
    <version>5.10.0</version>
    <scope>test</scope>
  </dependency>
</dependencies>

Write tests using JUnit 5 — results are automatically included in Surefire XML reports:

public class LoginTest {
    private WebDriver driver;
 
    @BeforeEach
    void setUp() {
        driver = new ChromeDriver();
    }
 
    @Test
    void testSuccessfulLogin() {
        driver.get("https://example.com/login");
        // test implementation
    }
 
    @AfterEach
    void tearDown() {
        driver.quit();
    }
}

Follow the JUnit Integration guide to configure Bumblebee.

Java + TestNG + Selenium

public class LoginTest {
    private WebDriver driver;
 
    @BeforeMethod
    public void setUp() {
        driver = new ChromeDriver();
    }
 
    @Test
    public void testSuccessfulLogin() {
        driver.get("https://example.com/login");
        // test implementation
    }
 
    @AfterMethod
    public void tearDown() {
        driver.quit();
    }
}

Follow the TestNG Integration guide.

Appium (Mobile Testing)

Appium tests use the same JUnit/TestNG runner pattern. The only difference is the driver initialization:

Android Example (JUnit 5)

public class MobileLoginTest {
    private AppiumDriver driver;
 
    @BeforeEach
    void setUp() {
        DesiredCapabilities caps = new DesiredCapabilities();
        caps.setCapability("platformName", "Android");
        caps.setCapability("app", "/path/to/app.apk");
        driver = new AndroidDriver(new URL("http://localhost:4723"), caps);
    }
 
    @Test
    void testLoginFlow() {
        // test implementation
    }
 
    @AfterEach
    void tearDown() {
        driver.quit();
    }
}

Surefire will generate XML reports for these tests identically to standard JUnit tests. Configure Bumblebee following the JUnit Integration guide.

Test Screenshots in ALM

To attach screenshots to failing ALM test runs, configure the Bumblebee plugin to include attachments:

<almMappings>
  <attachments>
    <attachment>
      <pattern>target/screenshots/*.png</pattern>
      <description>Test screenshot</description>
    </attachment>
  </attachments>
</almMappings>

Configure your test to save screenshots on failure:

@AfterEach
void saveScreenshotOnFailure(TestInfo testInfo) {
    if (testFailed) {
        TakesScreenshot ts = (TakesScreenshot) driver;
        File screenshot = ts.getScreenshotAs(OutputType.FILE);
        Files.copy(screenshot.toPath(),
            Paths.get("target/screenshots/" + testInfo.getDisplayName() + ".png"));
    }
}

On this page