nightwatchJS ---element用法

.element()

Search for an element on the page, starting from the document root. The located element will be returned as a WebElement JSON object.
First argument to be passed is the locator strategy, which is detailed on the WebDriver docs.

Parameters:
NameTypedescription
using string The locator strategy to use.
value string The search target.
callback function Callback function which is called with the result value.
Usage:
module.exports = {
 'demo Test' : function(browser) {
    browser.element('css selector', 'body', function(res) {
      console.log(res)
    });
  }
};

  

示例:

 client.element('css selector','#file_grid > tbody > tr > td > i.publish_file.click_icon',function(result){
            
            if(result.status != -1)
            {
            //element exist
            console.log(result);
            client.elementIdClick(result.value.ELEMENT);
            
            
            }
            else
            {
            //element not exist
                console.log("no appropriate media file to publish ");
            }
        
        })

  



posted on 2018-02-28 15:55  清明-心若淡定  阅读(278)  评论(0编辑  收藏  举报