Bee UI Automation Framework Overview and Test Case Design
Bee is a Youzan QA UI automation framework built on Selenium and Selenide that abstracts element loading and locating, provides pageObject and service layers, supports macOS Chrome, includes retry and unified locator mechanisms, and integrates with TestNG, Jenkins, and ReportNG for reliable web and WAP test case design.
Bee is a UI automation tool developed by Youzan QA that simplifies the interfaces provided by open‑source tools to facilitate the design of UI automation test cases for both web and WAP platforms.
The framework is built on Selenium and Selenide, with a second‑level encapsulation of their APIs to address element loading, element locating, and other common issues, making test case design easier. Selenide handles web pages while Selenium is used for WAP pages.
Bee adopts a Selenide + Selenium mode because Selenide alone cannot support WAP pages. Selenium can be seamlessly integrated, allowing the framework to embed Selenium for WAP automation while keeping the smoother element handling of Selenide for web pages.
Supported environments currently include macOS and Chrome, and the framework is extensible.
Test Case Design
Test cases call service‑layer and pageObject‑layer interfaces. Services encapsulate common business functions (e.g., login, product creation), while pageObjects encapsulate individual page elements. A typical seckill test case chains login, product creation, and activity creation through these interfaces.
The flexibility of test case design depends on the granularity of pageObject encapsulation—the smaller the granularity, the easier it is to assemble new test flows. TestNG is used for test execution.
Framework Structure
The project follows a pageObject pattern and consists of the following key modules:
dataprovider – defines data models and initializes test data.
driver – second‑level encapsulation of Selenium/Selenide APIs, providing element operations and common utilities such as keyboard simulation.
listeners – monitors test results and implements retry logic for failed cases (up to three retries).
model – defines data models for separating test data from test logic.
pageObject – encapsulates page elements and their operations, adding fault‑tolerance algorithms when needed.
service – provides reusable business functions (e.g., login, product creation) to avoid duplication.
Interface Optimization
To reduce false failures caused by slow page loading, the driver layer implements a wait‑until‑element‑appears logic using Selenide:
private boolean checkElementLoad(By elementLocator, long timeout) {
try {
Selenide.$(elementLocator).waitUntil(Condition.appears, timeout);
return true;
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}Additional helper methods provide unified element locating and retry mechanisms.
Unified Element Locator
The framework parses a string description of an element to automatically determine whether it is an ID, CSS selector, or XPath, shielding test designers from low‑level locator details.
Failure Retry Mechanism
A listener detects failed test results caused by external factors (e.g., network issues) and automatically retries the test up to three times, improving report reliability.
Element Locating Strategies
Common locating methods include ID, name, CSS, and XPath. The framework prefers ID/name for stability, CSS when IDs/names are unavailable, and XPath as a last resort, with recommendations for simplifying XPath expressions.
CI Integration
After test case design, Bee can be integrated into a CI pipeline using Jenkins and ReportNG. The typical steps are:
Set up a Jenkins server.
Provision a node for running UI automation tests.
Configure the node in Jenkins.
Create a Jenkins job with plugins such as Git, Execute Shell, Editable Email Notification, and Publish HTML Reports.
Common Errors and Solutions
Page not scrolling – use void scrollToElement(String element, String... elementType) .
Input fields not operable – use void triggerInput(String element, String... elementType) .
Button click fails – use void clickByText(String text) .
Browser driver incompatibility after browser upgrade – update the driver.
Invisible elements – use void clickByJs(String element, String... elementType) .
Conclusion
Bee extends open‑source tools with additional driver‑level optimizations, while data, service, and test layers still have room for improvement. UI automation can be achieved via recording or code implementation, each with its own trade‑offs. Ongoing development aims to enhance stability and usability.
Youzan Coder
Official Youzan tech channel, delivering technical insights and occasional daily updates from the Youzan tech team.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.