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

detox-getprops

v0.1.2

Published

Fetch element props using Detox

Downloads

10,871

Readme

detox-getprops

Allows fetching an element text / properties using Detox.

The standard Detox API allows fetching element text / attributes on iOS using the getAttributes method, but Android currently has no standard way of fetching element text. This package works on both.

Installation:

npm install --save-dev detox detox-getprops

Usage:

const { getText } = require('detox-getprops');

const text = await getText(element(by.id('heading')));
expect(text).toEqual('Step One');

See also a full example in its own repo.

Good to know

This is a horrible hack/workaround inspired by this Stack Overflow answer.

It searches for text that is not present in the element, catches the resulting exception, and parses the platform-dependent error message for the element properties.

This package should not be used once Detox #2083 is resolved.

Methods

getText

getText returns a promise for the text from a <Text> element. Usage example await getText(element(by.id('heading'))).

Using getText on a non-<Text> element is platform-dependent: on iOS it returns the text content of the sub-elements, on Android it returns undefined.

getProps

getProps returns a promise for some properties of the element (which can also be a non-<Text> element). Usage example await getProps(element(by.id('myview'))).

The properties are highly platform-dependent. The only common fields are type (the underlying component type), device (either android or ios) and text (the text content returned by getText).

Example Android output:

{
    id: '15',
    visibility: 'VISIBLE',
    width: '954',
    height: '85',
    'has-focus': 'false',
    'has-focusable': 'false',
    'has-window-focus': 'true',
    'is-clickable': 'false',
    'is-enabled': 'true',
    'is-focused': 'false',
    'is-focusable': 'false',
    'is-layout-requested': 'false',
    'is-selected': 'false',
    'layout-params': 'android.view.ViewGroup$LayoutParams@92e27dd',
    tag: 'heading',
    'root-is-layout-requested': 'false',
    'has-input-connection': 'false',
    x: '63.0',
    y: '84.0',
    text: 'Step One',
    'input-type': '0',
    'ime-target': 'false',
    device: 'android',
    type: 'ReactTextView'
}

Example iOS output:

{
    AX: 'Y',
    'AX.id': 'heading',
    'AX.label': 'Step One',
    'AX.frame': '{{24, 260}, {366, 29.5}}',
    'AX.activationPoint': '{207, 274.75}',
    'AX.traits': 'UIAccessibilityTraitStaticText',
    'AX.focused': 'N',
    frame: '{{24, 0}, {366, 29.5}}',
    device: 'ios',
    type: 'RCTTextView',
    text: 'Step One'
}

The properties are what they are. Don't ask for more.

License

ISC license.