量角器实例与浏览器

量角器实例与浏览器

本文介绍了量角器实例与浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾尝试查找类似的 QA,但我找不到让我满意的.所以基本上我看到在一些例子中它被使用了

I have tried to looked up for similar QA's but i couldn't find one to satisfy me.So basically i saw that in some examples it's used

ptor = protractor.getInstance();
ptor.get(url);

在其他一些例子中也使用了它.

And in some other examples it's used.

browser.get(url);

所以问题是:使用量角器实例和浏览器获取特定 url 有什么区别?另外,如果我在 P.S. 中的假设是的,这是更好的做法:只使用量角器,还是混合它们?

So th question is: What's the difference using protractor instance and browser for getting specific url?Also if my assumption in the P.S. is right, which is better practice: to use only protractor, or to mix them?

附:我也看到了与调试器在使用上的相同差异.我知道量角器是网络驱动程序的包装器,我假设量角器.getInstance().get(url) 是 browser.get(url) 的隐式调用.

P.S. Also i saw same difference in usage with the debugger.I know that protractor is a wrapper over web driver and i assume that protractor.getInstance().get(url) is a implicit invocatin of browser.get(url).

推荐答案

浏览器是新的首选语法.browserprotractor.getInstance() 相同.

browser is the new, preferred syntax. browser is the same as protractor.getInstance().

几个版本前引入了一种新语法.主要变化是:

A few versions ago a new syntax was introduced. The major changes were:

  • 浏览器是量角器实例
  • element(locator)ptor.findElement(locator)
  • 的新语法
  • by[strategy]protractor.By.[strategy]
  • 的新语法
  • browser is a protractor instance
  • element(locator) is the new syntax for ptor.findElement(locator)
  • by[strategy] is the new syntax for protractor.By.[strategy]

这里是新文档:http://angular.github.io/protractor/#/api

这篇关于量角器实例与浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 15:06