Retrieve the value of a CSS property for a given DOM element.

For more info on working with DOM elements in Nightwatch, refer to the Finding & interacting with DOM Elements guide page.

Usage

                    browser.element(selector).getCssProperty(name)
                

Example

export default {
  demoTest({ element }) {
    element('#main ul li a.first')
      .getCssProperty('display')
      .assert.valueEquals('block');
  },

  async demoTestAsync({ element }) {
    const result = await element('#main ul li a.first').getCssProperty('display');
    console.log('display', result);
  }
}
export default {
  demoTest(browser: NightwatchAPI): void {
    browser.element('#main ul li a.first').getCssProperty('display')
      .assert.valueEquals('block');
  },
  async demoTestAsync(browser: NightwatchAPI): Promise<void> {
    const result = await browser.element('#main ul li a.first').getCssProperty('display');
    console.log('display', result);
  }
}

Parameters

Name Type description
cssProperty string

The CSS property to inspect.

Returns

Type description
ScopedValue<string>

The container with a value of the css property

W3C WebDriver spec