Returns a context for the given element which can be used for querying child elements.

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

Usage

                    browser.within('#element').click('button');
                

Example

describe('example using within()', function() {

  it('click a button within the element', async function(browser) {
    const context = browser.within('#weblogin');
    await context.click('button');
  });
})

Parameters

Name Type description
selector string | object

The selector (CSS/Xpath) used to locate the element. Can either be a string or an object which specifies element properties.