npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

appium-geckodriver

v1.4.0

Published

Appium driver for Gecko-based browsers and web views

Downloads

346,884

Readme

Appium Geckodriver

NPM version Downloads

Release

This is Appium driver for automating Firefox on different platforms, including Android. The driver only supports Firefox and Gecko-based web views (Android only) automation using W3C WebDriver protocol. Under the hood this driver is a wrapper/proxy over geckodriver binary. Check the driver release notes and the official documentation to get more details on the supported features and possible pitfalls.

Note

Since version 1.0.0 Gecko driver has dropped the support of Appium 1, and is only compatible to Appium 2. Use the appium driver install gecko command to add it to your Appium 2 dist.

Requirements

It is mandatory to have both Firefox browser installed and the geckodriver binary downloaded on the platform where automated tests are going to be executed. Firefox could be downloaded from the official download site and the driver binary could be retrieved from the GitHub releases page. The binary must be put into one of the folders included to PATH environment variable. On macOS it also might be necessary to run xattr -cr "<binary_path>" to avoid notarization issues.

Since driver version 1.4.0 the geckodriver binary deployment could be automated via the install-geckodriver driver script.

Then you need to decide where the automated test is going to be executed. Gecko driver supports the following target platforms:

  • macOS
  • Windows
  • Linux
  • Android (note that android cannot be passed as a value to platformName capability; it should always equal to the host platform name)

In order to run your automated tests on an Android device it is necessary to have Android SDK installed, so the destination device is marked as online in the adb devices -l command output.

Doctor

Since driver version 1.3.0 you can automate the validation for the most of the above requirements as well as various optional ones needed by driver extensions by running the appium driver doctor gecko server command.

Capabilities

Gecko driver allows defining of multiple criterions for platform selection and also to fine-tune your automation session properties. This could be done via the following session capabilities:

Capability Name | Description --- | --- platformName | Gecko Driver supports the following platforms: mac, linux, windows. The fact your test must be executed on Android is detected based on moz:firefoxOptions entry values. Values of platformName are compared case-insensitively. browserName | Any value passed to this capability will be changed to 'firefox'. browserVersion | Provide the version number of the browser to automate if there are multiple versions installed on the same machine where the driver is running. appium:automationName | Must always be set to Gecko. appium:noReset | Being set to true adds the --connect-existing argument to the server, that allows to connect to an existing browser instance instead of starting a new browser instance on session startup. appium:marionettePort | Selects the port for Geckodriver’s connection to the Marionette remote protocol. The existing Firefox instance must have Marionette enabled. To enable the remote protocol in Firefox, you can pass the -marionette flag. Unless the marionette.port preference has been user-set, Marionette will listen on port 2828, which is the default value for this capability. appium:systemPort | The number of the port for the driver to listen on. Must be unique for each session. If not provided then Appium will try to detect it automatically. appium:verbosity | The verbosity level of driver logging. By default minimum verbosity is applied. Possible values are debug or trace. appium:androidStorage | See https://firefox-source-docs.mozilla.org/testing/geckodriver/Flags.html#code-android-storage-var-android-storage-var-code moz:firefoxOptions | See https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities/firefoxOptions acceptInsecureCerts | See https://www.w3.org/TR/webdriver/#capabilities pageLoadStrategy | See https://www.w3.org/TR/webdriver/#capabilities proxy | See https://www.w3.org/TR/webdriver/#capabilities setWindowRect | See https://www.w3.org/TR/webdriver/#capabilities timeouts | See https://www.w3.org/TR/webdriver/#capabilities unhandledPromptBehavior | See https://www.w3.org/TR/webdriver/#capabilities

Scripts

install-geckodriver

This script is used to install the given or latest stable version of Geckodriver server from the GitHub releases page. Run appium driver run gecko install-geckodriver <optional_version>, where optional_version must be either valid Geckodriver version number or should not be present (the latest stable version is used then). By default, the script will download and unpack the binary into /usr/local/bin/geckodriver on macOS and Linux or into %LOCALAPPDATA%\Mozilla\geckodriver.exe on Windows. You must also make sure the %LOCALAPPDATA%\Mozilla (Windows) or /usr/local/bin/ (Linux & macOS) folder is present in the PATH environment variable before starting an actual automation session. The deployment script should also show a warning message if it is unable to find the parent folder in the PATH folders list.

Example

# Python3 + PyTest
import pytest
import time

from appium import webdriver
# Options are available in Python client since v2.6.0
from appium.options.gecko import GeckoOptions
from selenium.webdriver.common.by import By


def generate_options():
    common_caps = {
        # It does not really matter what to put there, although setting 'Firefox' might cause a failure
        # depending on the particular client library
        'browserName': 'MozillaFirefox',
        # Should have the name of the host platform, where the geckodriver binary is deployed
        'platformName': 'mac',
    }
    android_options = GeckoOptions().load_capabilities(common_caps)
    android_options.firefox_options = {
        'androidDeviceSerial': '<device/emulator serial>',
        # These capabilities depend on what you are going to automate
        # Refer Mozilla documentation at https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities/firefoxOptions for more details
        'androidPackage': 'org.mozilla.firefox',
    }
    desktop_options = GeckoOptions().load_capabilities(common_caps)
    return [android_options, desktop_options]


@pytest.fixture(params=generate_options())
def driver(request):
    # The default URL is http://127.0.0.1:4723/wd/hub in Appium1
    drv = webdriver.Remote('http://127.0.0.1:4723', options=request.param)
    yield drv
    drv.quit()


class TimeoutError(Exception):
    pass


def wait_until_truthy(func, timeout_sec=5.0, interval_sec=0.5):
    started = time.time()
    original_error = None
    while time.time() - started < timeout_sec:
        original_error = None
        try:
            result = func()
            if result:
                return result
        except Exception as e:
            original_error = e
        time.sleep(interval_sec)
    if original_error is None:
        raise TimeoutError(f'Condition unmet after {timeout_sec}s timeout')
    raise original_error


def test_feature_status_page_search(driver):
    driver.get('https://webkit.org/status/')

    # Enter "CSS" into the search box.
    # Ensures that at least one result appears in search
    # !!! Remember there are no ID and NAME locators in W3C standard
    # These two have been superseded by CSS ones
    search_box = driver.find_element_by_css('#search')
    search_box.send_keys('CSS')
    value = search_box.get_attribute('value')
    assert len(value) > 0
    search_box.submit()
    # Count the visible results when filters are applied
    # so one result shows up in at most one filter
    assert wait_until_truthy(
        lambda: len(driver.execute_script("return document.querySelectorAll('li.feature:not(.is-hidden)')")) > 0)


def test_feature_status_page_filters(driver):
    driver.get('https://webkit.org/status/')

    assert wait_until_truthy(
        lambda: len(driver.execute_script("return document.querySelectorAll('.filter-toggle')")) == 7)

    # Make sure every filter is turned off.
    for checked_filter in filter(lambda f: f.is_selected(), filters):
        checked_filter.click()

    # Make sure you can select every filter.
    for filt in filters:
        filt.click()
        assert filt.is_selected()
        filt.click()

Development

# clone repo, then in repo dir:
npm install
npm run lint
npm run test