Protractor “by.css()” vs “$()” Dollar Sign vs “$$()” 'Bling Bling'

后端 未结 1 1778
时光说笑
时光说笑 2021-01-01 09:54

I don\'t really understand what the $ and $$ commands are for. I thought they are just a replacement for \'by.css\' but why the $$?



        
1条回答
  •  时光说笑
    2021-01-01 10:41

    $ and $$ are just convenient shortcuts.

    $("selector") is an alternative for element(by.css("selector")).

    $$("selector") is an alternative for element.all(by.css("selector")).


    FYI, quote from the source code:

    ElementFinder.prototype.$ = function(selector) {
      return this.element(webdriver.By.css(selector));
    };
    
    ElementArrayFinder.prototype.$$ = function(selector) {
      return this.all(webdriver.By.css(selector));
    };
    

    And the actual commit that initially made it happen.

    0 讨论(0)
提交回复
热议问题