All Projects → react-native-windows → selenium-appium

react-native-windows / selenium-appium

Licence: MIT license
selenium-webdriver+appium: A bridge to make selenium-webdriver to drive appium to do native app testing

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to selenium-appium

spydriver
🕵️ Lightweight utility to intercept WebDriver and WebElement method calls.
Stars: ✭ 24 (-31.43%)
Mutual labels:  selenium-webdriver, automation-test
page-modeller
⚙️ Browser DevTools extension for modelling web pages for automation.
Stars: ✭ 66 (+88.57%)
Mutual labels:  pageobject, selenium-webdriver
resgen
Keep track of jobs you've applied to, automate resume & cover letter creation; generate PDFs from .odt templates on the fly while scraping the job post and tracking employer status.
Stars: ✭ 31 (-11.43%)
Mutual labels:  selenium-webdriver, automation-selenium
OneFramework
Automation for iOS, Android, & Web Apps with one codebase. Like it, Star it & spread the word !!!
Stars: ✭ 46 (+31.43%)
Mutual labels:  pageobject, selenium-webdriver
Codeceptjs
Supercharged End 2 End Testing Framework for NodeJS
Stars: ✭ 3,592 (+10162.86%)
Mutual labels:  pageobject, selenium-webdriver
Scrape Linkedin Selenium
`scrape_linkedin` is a python package that allows you to scrape personal LinkedIn profiles & company pages - turning the data into structured json.
Stars: ✭ 239 (+582.86%)
Mutual labels:  selenium-webdriver
Instagram-Like-Comment-Bot
📷 An Instagram bot written in Python using Selenium on Google Chrome. It will go through posts in hashtag(s) and like and comment on them.
Stars: ✭ 53 (+51.43%)
Mutual labels:  selenium-webdriver
Cdp4j
cdp4j - Chrome DevTools Protocol for Java
Stars: ✭ 232 (+562.86%)
Mutual labels:  selenium-webdriver
Steward
PHP libraries that makes Selenium WebDriver + PHPUnit functional testing easy and robust
Stars: ✭ 215 (+514.29%)
Mutual labels:  selenium-webdriver
wdio-automation
Functional test automation with wdio + page objects + selenium standalone + docker
Stars: ✭ 24 (-31.43%)
Mutual labels:  pageobject
SeleniumWebDriverWithCSharp
BDD with Selenium Webdriver and Specflow using C#
Stars: ✭ 22 (-37.14%)
Mutual labels:  selenium-webdriver
aquality-selenium-java
Aquality Selenium is a library built over Selenium WebDriver tool that allows to automate work with web browsers. Selenium WebDriver requires some skill and experience. So, Aquality Selenium suggests simplified and most importantly safer and more stable way to work with Selenium WebDriver.
Stars: ✭ 41 (+17.14%)
Mutual labels:  pageobject
Lambdium
headless chrome + selenium webdriver in AWS Lambda using the serverless application model
Stars: ✭ 246 (+602.86%)
Mutual labels:  selenium-webdriver
pdf-crawler
SimFin's open source PDF crawler
Stars: ✭ 100 (+185.71%)
Mutual labels:  selenium-webdriver
Ocaramba
C# Framework to automate tests using Selenium WebDriver
Stars: ✭ 234 (+568.57%)
Mutual labels:  selenium-webdriver
appium-driver-codeception
Appium Driver for codeception
Stars: ✭ 19 (-45.71%)
Mutual labels:  automation-test
Jest Webdriver
Connect Jest tests to Selenium WebDriver
Stars: ✭ 229 (+554.29%)
Mutual labels:  selenium-webdriver
clearth
Test automation tool for Clearing, Settlement and Back-Office Systems
Stars: ✭ 26 (-25.71%)
Mutual labels:  automation-test
behat-3-kickstart
Behat 3/Mink and Guzzle for API testing. Code follows PageObjects approach. Saucelabs integration.
Stars: ✭ 13 (-62.86%)
Mutual labels:  pageobject
QVisual
Tinkoff tool to control quality by visual testing
Stars: ✭ 47 (+34.29%)
Mutual labels:  selenium-webdriver

selenium-appium

selenium-appium is selenium-webdriver extension to make selenium-webdriver to drive Appium to run automation for native, hybrid and mobile web and desktop apps.

NPM version Monthly Downloads Build Status

Break changes

  1. [email protected] The default URL is changed from http://localhost:4723/wd/hub to http://localhost:4723. The goal is to remove appium from the project and use winappdriver to launch and stop WinAppDriver

Features

  1. A bridge to make selenium-webdriver to drive appium for native app automation. Implement Mobile JSON Wire Protocol Specification locator which selenium-webdriver doesn't support.
  2. Supports PageObject Pattern for selenium-webdriver
  3. Supports iOS, Andriod, Windows which Appium supports.
  4. Supports Typescript
  5. Avoid webdriver.wait(until.elementLocated()).click() pattern and replaced it with By2.click()

Installation

npm i selenium-appium --save-dev

By2 example

  • By2 is a subclass of selenium-webdriver.By. So you can use it anywhere which selenium-webdriver provides.
  • Also By2 implements the WebElement interface, so you can call click and other element operation directly.
  • No webdriver.wait needed. Instead of findElement, By2 itself loop until element is located before actual click happens.
    test("By2 used in selenium-webdriver.WebDriver", async () => {
        const webdriver = await new Builder()
            .usingServer(url)
            .withCapabilities(capabilities)
            .build();
        const element = await webdriver.wait(until.elementLocated(By2.nativeName('One')));
        await element.click();
        await webdriver.quit();
    });

    test("By2 Supports multiple webdriver2", async () => {
        const webdriver = new WebDriver2();
        await webdriver.startWithCapabilities(capabilities)
        await By2.nativeName('One', webdriver).click();
        await webdriver.quit();
    });


    test("By2 deduced WebDriver2 for single WebDriver2", async () => {
        await driver.startWithCapabilities(capabilities)
        await By2.nativeName('One').click();
        await driver.quit();
    });

driver example

  • driver is a wrapper of WebDriver which selenium-webdriver provides.
  • Implements all functions of WebDriver of selenium-webdriver.
  • It provides the default driver for By2.
  • It delayed the creation of WebDriver, and implement the interface of WebDriver.

There are two ways to initialize the driver: startWithWebDriver or startWithWebDriver.

startWithWebDriver allows you to attach the driver to existing WebDriver if capability is not enough for your testing.

    test("simple webdriver2, and driver create from WebDriver", async () => {
        const webdriver = await new Builder()
            .usingServer(url)
            .withCapabilities(capabilities)
            .build();
        await driver.startWithWebDriver(webdriver);
        await By2.nativeName('One').click();
        await webdriver.quit();
    });

    test("Multiple webdriver2", async () => {
        const webdriver = new WebDriver2();
        await webdriver.startWithCapabilities(capabilities)
        await By2.nativeName('One', webdriver).click();
        await webdriver.quit();
    });


    test("Simple Webdriver2, and Driver create from capabilities", async () => {
        await driver.startWithCapabilities(capabilities)
        await By2.nativeName('One').click();
        await driver.quit();
    });

PageObject example

PageObject reduces the amount of duplicated code and easy to maintain.

  1. get in typescript would make you always get new instance of By2. For example, get resultTextBox()
  2. waitForPageLoaded pairs with isPageLoaded. You only need to overload isPageLoaded. waitForPageLoaded would poll until isPageLoaded is true or timeout.
  3. In practice, we only need simple instance of PageObject since it doesn't save state, and all state could be query by By2 from remote app.

PageObject

import { PageObject, By2 } from "selenium-appium";

class CalculatorPage extends PageObject {
  isPageLoaded() {
    return this.minusButton.isDisplayed();
  }

  get resultTextBox() { return By2.nativeAccessibilityId('CalculatorResults');}
  get equalButton() { return By2.nativeAccessibilityId('equalButton'); }
  get clearButton() { return By2.nativeName('Clear'); }
  get plusButton() { return By2.nativeName('Plus'); }
  get divideButton() { return By2.nativeAccessibilityId('divideButton'); }
  get multiplyButton() { return By2.nativeXpath("//Button[@Name='Multiply by']") }
  get minusButton() { return By2.nativeXpath("//Button[@AutomationId=\"minusButton\"]"); }
 

  private async pressKeys(keys: string) {
    for (var key of keys) {
      await By2.nativeAccessibilityId('num' + key + 'Button').click();
    }
  }
  async divid(a: string, b: string): Promise<string> {
    await this.pressKeys(a);
    await this.divideButton.click();
    await this.pressKeys(b);
    await this.equalButton.click();
    return await this.getCalculatorResultText();
  }

  async multiply(a: string, b: string): Promise<string> {
    await this.pressKeys(a);
    await this.multiplyButton.click();
    await this.pressKeys(b);
    await this.equalButton.click();
    return await this.getCalculatorResultText();
  }

  async plus(a: string, b: string): Promise<string> {
    await this.pressKeys(a);
    await this.plusButton.click();
    await this.pressKeys(b);
    await this.equalButton.click();
    return await this.getCalculatorResultText();
  }

  async minus(a: string, b: string): Promise<string> {
    await this.pressKeys(a);
    await this.minusButton.click();
    await this.pressKeys(b);
    await this.equalButton.click();
    return await this.getCalculatorResultText();
  }

  private async getCalculatorResultText(): Promise<string> {
    return (await this.resultTextBox.getText()).replace('Display is', '').trim();
  } 
}

export default new CalculatorPage();

use the PageObject

  beforeEach(async () => {
    await CalculatorPage.waitForPageLoaded();
    await CalculatorPage.clearButton.clear();
  });
  test('Addition', async () => {
    // Find the buttons by their names and click them in sequence to perform 1 + 7 = 8
    expect(await CalculatorPage.plus('1', '7')).toBe('8');
  });

  test('Division', async () => {
    // Find the buttons by their accessibility ids and click them in sequence to perform 88 / 11 = 8
    expect(await CalculatorPage.divid('88', '11')).toBe('8');
  });

  test('Multiplication', async () => {
    // Find the buttons by their names using XPath and click them in sequence to perform 9 x 9 = 81
    expect(await CalculatorPage.multiply('9', '9')).toBe('81');
  });

  test('Subtraction', async () => {
    // Find the buttons by their accessibility ids using XPath and click them in sequence to perform 9 - 1 = 8
    expect(await CalculatorPage.minus('9', '1')).toBe('8');
  });

Configuration example

There are two global timers: waitforPageTimeout and waitforTimeout.

waitforTimeout is used by By2. When call any WebElement function of By2, it loops until the element is located

waitforPageTimeout is used by PageObject. It defined the default timeout for waitForPageLoaded.

    Config.setWaitForPageTimeout(100);
    expect(Config.getWaitForPageTimeout()).toBe(100);
Config.setWaitForTimeout(100);
expect(Config.getWaitForTimeout()).toBe(100);

driver.seleniumDriver

driver.seleniumDriver returns the instance of actual WebDriver.

Note

Because of typescript error, unlike By.name, By2 only replaced it with By2.name2.

Why selenium-appium

selenium-appium projected is created when I prototype automation for react-native Windows testing. Appium is an open source, cross-platform test automation tool for native, hybrid and mobile web and desktop apps. We support simulators (iOS), emulators (Android), and real devices (iOS, Android, Windows, Mac).

Selenium is a browser automation library. Most often used for testing web-applications.

selenium-webdriver is the offical WebDriver Javascript binding from selenium project.

Although WebDriverIO provides webdriver for Appium, it has some restrictions:

  1. Selenium has very large user base in browser automation, but WebDriverIO API is different from selenium javascript API
  2. [Already fixed] WebDriverIO has problem to support WinAppDriver, for example, webdriverio/webdriverio#4369

Unfortunately selenium-webdriver doesn't support Mobile JSON Wire Protocol Specification. And that's why selenium-appium project is created.

Note

To know more about how to integrate JavaScript test runner and WinAppDriver for UI automation, please refer to:

  1. Jest + selenium-webdriver + WinAppDriver
  2. Jasmine + WebDriverIO + WinAppDriver. This part is obselete, please refer to WinAppDriver + WebDriverIO example for newer change.

License

The selenium-appium and all newly contributed code is provided under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].