Protractor : use browser or browser.driver methods?

后端 未结 2 1990
天命终不由人
天命终不由人 2021-01-13 13:34

When using protractor, the global variable browser appears to have all the functionality of browser.driver.

I am specifically

2条回答
  •  猫巷女王i
    2021-01-13 14:39

    Some browser methods are the same...

    The browser object is made up by composition of WebDriver methods and Protractor specific methods. So methods like sleep, wait, and getCurrentUrl are copied over from WebDriver (see the browser.ts). So should you use browser or browser.driver? Well, if it is listed in the link above, they are the exact same thing.

    Some browser methods are not...

    However, not every method is just copied over. For methods like get, the browser is implemented differently in Protractor vs selenium-webdriver. For Angular pages, you should use browser.get. This will wait for Angular to be stable before moving on to other commands before moving onto other commands.

    When in doubt, check out the documentation

    So when you navigate to protractortest.org/#/api, you will see a list of browser methods that are Protractor specific and "inherited from webdriver.WebDriver". The methods that follow "inherited from webdriver.WebDriver" are the same method if you decide to use browser or browser.driver.

提交回复
热议问题