Convert Figma logo to code with AI

alibaba logouirecorder

UI Recorder is a multi-platform UI test recorder.

2,061
396
2,061
99

Top Related Projects

30,518

A browser automation framework and ecosystem.

46,847

Fast, easy and reliable testing for anything that runs in a browser.

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

88,205

JavaScript API for Chrome and Firefox

18,791

Cross-platform automation framework for all kinds of apps, built on top of the W3C WebDriver protocol

Quick Overview

UIRecorder is an open-source UI automation testing tool developed by Alibaba. It allows users to record and playback UI interactions, generate test scripts, and perform cross-browser testing. UIRecorder aims to simplify the process of creating and maintaining UI tests for web applications.

Pros

  • Easy to use with a user-friendly interface for recording and editing test cases
  • Supports multiple browsers and platforms, including mobile devices
  • Generates test scripts in popular languages like JavaScript and Java
  • Integrates well with continuous integration and testing frameworks

Cons

  • Limited documentation and community support compared to more established tools
  • May struggle with complex, dynamic web applications
  • Occasional stability issues and bugs reported by users
  • Steeper learning curve for advanced features and customizations

Code Examples

// Record a test case
const recorder = new UIRecorder();
recorder.start();
// Perform UI interactions
recorder.stop();
// Play back a recorded test case
const player = new UIPlayer();
player.load('test_case.json');
player.play();
// Generate a test script
const generator = new ScriptGenerator();
generator.setLanguage('javascript');
generator.generate('test_case.json', 'output_script.js');

Getting Started

  1. Install UIRecorder:

    npm install -g uirecorder
    
  2. Start recording a test case:

    uirecorder start
    
  3. Perform your UI interactions in the browser

  4. Stop recording:

    uirecorder stop
    
  5. Run the generated test script:

    npm test
    

Competitor Comparisons

30,518

A browser automation framework and ecosystem.

Pros of Selenium

  • Widely adopted and supported across multiple programming languages
  • Extensive documentation and large community for support
  • Supports a broader range of browsers and platforms

Cons of Selenium

  • Steeper learning curve, especially for non-programmers
  • Requires more manual coding for test creation and maintenance
  • Can be slower in execution compared to specialized tools

Code Comparison

UIRecorder (JavaScript):

module.exports = function(){
    return this.wait('input.search-input', 30000)
    .click('input.search-input')
    .sendKeys('UIRecorder')
    .pressKey('Enter');
}

Selenium (Python):

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

driver = webdriver.Chrome()
search_input = driver.find_element_by_css_selector('input.search-input')
search_input.click()
search_input.send_keys('Selenium')
search_input.send_keys(Keys.ENTER)

Summary

While Selenium offers more flexibility and widespread support, UIRecorder provides a simpler approach for creating UI tests, especially for those with less programming experience. Selenium's versatility comes at the cost of a steeper learning curve and more manual coding, whereas UIRecorder focuses on ease of use for web application testing.

46,847

Fast, easy and reliable testing for anything that runs in a browser.

Pros of Cypress

  • More comprehensive testing framework with built-in assertion library and debugging tools
  • Faster test execution due to running directly in the browser
  • Larger community and ecosystem with extensive documentation and plugins

Cons of Cypress

  • Limited cross-browser support (primarily focused on Chrome-based browsers)
  • Steeper learning curve for developers new to JavaScript-based testing
  • Lack of native support for multi-tab testing

Code Comparison

UIRecorder:

module.exports = function(browser, recorder) {
    recorder.add('click', '#loginButton', {});
    recorder.add('sendKeys', '#username', 'testuser');
    recorder.add('sendKeys', '#password', 'password123');
    recorder.add('click', '#submitButton', {});
}

Cypress:

describe('Login Test', () => {
  it('should log in successfully', () => {
    cy.visit('/login');
    cy.get('#loginButton').click();
    cy.get('#username').type('testuser');
    cy.get('#password').type('password123');
    cy.get('#submitButton').click();
  });
});

The code comparison shows that Cypress offers a more intuitive and readable syntax for writing tests, with built-in commands like visit and type. UIRecorder's code is more focused on recording user actions, which can be beneficial for quickly creating test scripts based on manual interactions.

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

Pros of Playwright

  • Cross-browser support for Chromium, Firefox, and WebKit
  • Powerful API for automating modern web applications
  • Strong TypeScript support and auto-generated types

Cons of Playwright

  • Steeper learning curve for beginners
  • Requires Node.js environment to run tests

Code Comparison

Playwright:

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await browser.close();
})();

UIRecorder:

var recorder = require('uirecorder');
recorder.run(__dirname, {
    webdriver: 'chrome',
    browserSize: '1024x768'
});

Key Differences

  • Playwright offers a more comprehensive and flexible API for web automation
  • UIRecorder focuses on record-and-playback functionality
  • Playwright supports multiple browsers, while UIRecorder primarily targets Chrome
  • UIRecorder has a simpler setup process for beginners
  • Playwright provides better support for modern web technologies and frameworks

Both tools have their strengths, with Playwright being more suitable for complex automation scenarios and UIRecorder offering an easier entry point for simple test recording and playback.

88,205

JavaScript API for Chrome and Firefox

Pros of Puppeteer

  • More powerful and flexible, allowing for complex browser automation tasks
  • Better integration with modern web technologies and JavaScript ecosystems
  • Extensive API for fine-grained control over browser actions

Cons of Puppeteer

  • Steeper learning curve, especially for non-developers
  • Requires more manual scripting for test case creation
  • Less focus on visual UI recording and playback

Code Comparison

UIRecorder example:

module.exports = function(browser, recorder) {
    recorder.add('click', '#loginButton');
    recorder.add('sendKeys', '#username', 'testuser');
    recorder.add('sendKeys', '#password', 'password123');
    recorder.add('click', '#submitButton');
}

Puppeteer example:

await page.click('#loginButton');
await page.type('#username', 'testuser');
await page.type('#password', 'password123');
await page.click('#submitButton');

Key Differences

UIRecorder focuses on simplifying UI testing through visual recording and playback, making it accessible for non-technical users. Puppeteer, on the other hand, provides a comprehensive API for browser automation, offering more control and flexibility but requiring more programming knowledge.

UIRecorder is better suited for quick, straightforward UI tests, while Puppeteer excels in complex scenarios, performance testing, and advanced web scraping tasks. The choice between the two depends on the specific project requirements and the team's technical expertise.

18,791

Cross-platform automation framework for all kinds of apps, built on top of the W3C WebDriver protocol

Pros of Appium

  • Cross-platform support for iOS, Android, and Windows
  • Supports multiple programming languages (Java, Python, Ruby, etc.)
  • Large community and extensive documentation

Cons of Appium

  • Steeper learning curve, especially for beginners
  • Setup process can be complex and time-consuming
  • May have slower execution times compared to native automation tools

Code Comparison

UIRecorder (JavaScript):

module.exports = function(action, testVars){
    action.click('#loginButton');
    action.sleep(1000);
    action.sendKeys('#username', testVars.username);
    action.sendKeys('#password', testVars.password);
    action.click('#submitButton');
}

Appium (Python):

from appium import webdriver

driver = webdriver.Remote("http://localhost:4723/wd/hub", desired_caps)
driver.find_element_by_id("loginButton").click()
driver.implicitly_wait(1)
driver.find_element_by_id("username").send_keys(username)
driver.find_element_by_id("password").send_keys(password)
driver.find_element_by_id("submitButton").click()

Both UIRecorder and Appium offer powerful automation capabilities, but they cater to different use cases. UIRecorder focuses on web automation with a user-friendly interface, while Appium provides a more versatile solution for mobile and desktop application testing across multiple platforms and programming languages.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

UI Recorder


logo.png

NPM version License NPM count NPM count TesterHome

UI Recorder is multi-platform UI test case recorder like Selenium IDE but more powerful than Selenium IDE!

UI Recorder is easy to use, even zero cost.

  1. Official Site: https://www.yuque.com/artist/uirecorder/
  2. Language Switch: English, 中文
  3. Change log: CHANGE
  4. Video Tutorial:PC中文教程

Features

  1. Support all user operation: key event, mouse event, alert, file upload, drag, svg, shadow dom
  2. Support mobile native APP(Android, iOS) recorde, powered by Macaca
  3. No interference when recording: the same as self test
  4. Record test file saved in local
  5. Support kinds of expect: val,text,displayed,enabled,selected,attr,css,url,title,cookie,localStorage,sessionStorage
  6. Support image diff
  7. Support powerful var string
  8. Support common test case: one case call another
  9. Support parallel test
  10. Support i18n: en, zh-cn, zh-tw
  11. Support screenshots after each step
  12. Support HTML report & JUnit report
  13. Support multi systems: Windows, Mac, Linux
  14. Test file base on NodeJs: jWebDriver

Contributors


itestauipi


Stngle


yaniswang


xudafeng


undead25


stevobm


micosty


ali-lion


alibaba-oss


felizalde


portokallidis


snapre


paradite


WingOfTime


zquancai

This project follows the git-contributor spec, auto updated at Sat Apr 30 2022 21:11:26 GMT+0800.

Screenshots

shot1

shot2

shot3

shot4

Video demo

video1

video2

Quick start

Install

  1. Install NodeJs (version >= v7.x)

    https://nodejs.org/

    sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share} (Mac, Linux)

  2. Install chrome

    https://www.google.com/chrome/

  3. Install UI Recorder

    npm install uirecorder mocha -g

PC record

  1. Init test project

    Create new folder

    uirecorder init

  2. Start record test case

    edit hosts file

    uirecorder sample/test.spec.js

  3. Start WebDriver Server

  4. Run test case

    Run all case: source run.sh ( Linux|Mac ) or run.bat ( Windows )

    Run single case: source run.sh sample/test.spec.js ( Linux|Mac ) or run.bat sample/test.spec.js ( Windows )

  5. Get reports & screenshots

    ./reports/index.html

    ./reports/index.xml (JUnit)

    ./reports/index.json

    ./screenshots/

More Platform Support

Macaca

  1. Install & start macaca server:

    Install Macaca

    Connect your mobile or open emulator

    macaca server --port 4444

  2. Init test project

    Create new folder

    uirecorder init --mobile

  3. Start record test case

    uirecorder --mobile sample/test.spec.js

  4. Run test case

    Run all case: source run.sh ( Linux|Mac ) or run.bat ( Windows )

    Run single case: source run.sh sample/test.spec.js ( Linux|Mac ) or run.bat sample/test.spec.js ( Windows )

  5. Get reports & screenshots

    ./reports/index.html

    ./reports/index.xml (JUnit)

    ./reports/index.json

    ./screenshots/

Documentation Translations

  1. 中文使用手册

QA

How to debug test code

  1. Install Visual Studio Code & open Visual Studio Code
  2. Open the project root folder by vs code
  3. Open test file, add break point
  4. press F5 key to start, press F10 key to run next line

How to deploy WebDriver Server

  1. How to run selenium standalone server?

    npm run server

  2. Selenium Grid: https://github.com/SeleniumHQ/selenium/wiki/Grid2

  3. F2etest: https://github.com/alibaba/f2etest

How to change webdriver host & port by env temporary, debug for local?

  1. export webdriver=127.0.0.1:4444 or set webdriver=127.0.0.1:4444 (Windows)

Tip: port is not required, For example: export webdriver=127.0.0.1

How to dock Jenkins?

  1. Add commands

     source ./install.sh
     source ./run.sh
    
  2. Add reports

    JUnit: reports/index.xml

    HTML: reports/index.html

How to filter unstable path

  1. Because some attribute values are random or unstable, we can't record a stable CSS selector
  2. We can filter the attributes with a blacklist. You can type uirecorder init and then input the blacklist from the command line

Tip: blacklist is a regex, you can use it like this: /attr_\d+/

How to record common test case?

  1. Record commons/login.mod.js

  2. Record sample/test.spec.js

    1. please input login.mod.js in recorder start page or jump test case in page
    2. After login.mod.js loaded, then recorder other steps
  3. source run.sh ( Linux|Mac ) or run.bat ( Windows )

How to record file upload?

  1. UI Recorder only support native file compont
  2. direct click <input type="file"> or click <button role="upload">Upload file</button>, the placeholder button must mark as upload with role or data-role
  3. File must save to uploadfiles/ directory

How to use vars

edit config.json

{
    "recorder": {
        ...
    },
    "webdriver": {
        ...
    },
    "vars": {
        "productId": "123456",
        "productName": "mp3"
    }
}
  1. start with url: http://xxx.com/product?id={{productId}}
  2. add new var with tool panel
  3. update var with tool panel
  4. jump url with tool panel: http://xxx.com/product?id={{productId}}
  5. insert vars string with tool panel: {{productName}} or aaa{{productName}}bbb
  6. expect to var string: {{productName}} or aaa{{productName}}bbb

Tip: All var string also support js template string, For example: {{productName}}, ${new Date().getTime()}, ${parseInt(testVars.a)+parseInt(testVars.b)}

How to add hover multiple or add expect after a hover?

  1. Press down Ctrl or Command button
  2. Click Add Hover Button, enter hover mode
  3. Release Ctrl or Command button
  4. Click the dom you want to hover (can add multiple)
  5. Click Add Expect Button
  6. Click the dom you want to expect
  7. Press Esc button or click End Hover Button, exit hover mode

How to expect the value after js eval in front browser?

  1. Add Expect, select type jscode

  2. sync mode: return document.title

  3. function mode:

     function(){
         var str = "aaa";
         return str;
     }
    
  4. async mode:

     function(done){
         setTimeout(function(){
             done(123);
         }, 100);
     }
    

How to hide doms before expect?

  1. uirecorder init
  2. Input css selector when init Hide before expect
  3. uirecorder start
  4. UIRecorder will hide matched doms before expect, then you can expect the dom behind the mask div

How to record option click?

Some steps is not very important, but occasionally displayed, this steps will expect to success always.

  1. Press 'Alt' button
  2. Click the target DOM

How to use image diff?

  1. Install GraphicsMagick

    brew install graphicsmagick (Mac)

    sudo apt-get install graphicsmagick (Linux)

    http://www.graphicsmagick.org/download.html (Windows)

  2. Add expect with imgdiff

    select expect type: imgdiff

    select target element

  3. Rebuild the baseline image

    source run.sh sample/test.spec.js --rebuilddiff (Mac | Linux)

    run.bat sample/test.spec.js --rebuilddiff (Windows)

Can't do when recording

  1. don't change url in location bar
  2. don't change focus by TAB key
  3. don't use dblclick, WebDriver no support
  4. don't select text by mouse, WebDriver no support
  5. don't focus to background window manualy
  6. don't click useless DOM, only record key steps

How develop test friendly code?

  1. please dont't use random id or name
  2. please name a id for DOM area
  3. add label for form
  4. please listen click event instead of mousedown

How to set udid to mobile test?

  1. export devices=xxx1,xxx2 (windows: set devices=xxx1,xxx2)
  2. source run.sh ( Linux|Mac ) or run.bat ( Windows )

How to save raw cmds json?

  1. uirecorder start --raw
  2. After test saved, then you can get 2 files: sample/test.spec.js, sample/test.spec.json

Other Tips

  1. Mac system: localhost must place in hosts

License

UIRecorder is released under the MIT license.

Thanks

NPM DownloadsLast 30 Days