The doc of protractor v1.4.0 (http://angular.github.io/protractor/#/api-overview) tries to describe the global variables in protractor:
browser
- A wrapper around an instance of WebDriver, used for navigation and page-wide information. The browser.get method loads a page. Protractor expects Angular to be present on a page, so it will throw an error if the page it is attempting to load does not contain the Angular library. (If you need to interact with a non-Angular page, you may access the wrapped webdriver instance directly with browser.driver).
protractor
- The Protractor namespace which wraps the WebDriver namespace. Contains static variables and classes, such as protractor.Key which enumerates the codes for special keyboard signals.
My questions:
1) i don't actually understand these definitions and the difference between browser
and protractor
2) in the definition of browser
there is mentioned about browser.driver
but when i look to the protractor API doc(http://angular.github.io/protractor/#/api) there is no driver
property available for browser
.
1) There are 3 important keywords: element
, browser
, and protractor
.
element
is how you select content on the page, browser
is how you interact with the browser that you're testing (i.e. browser.get(...)
), protractor
is a shortcut for you to access static variables defined in the webdriver
namespace.
For example:
browser.get('http://www.someUrl.com'); // tell browser to go to an url
var input = element(by.css('#someInput')); // find the input using a css selector
input.sendKeys(protractor.Key.ENTER); // Send a `webdriver` key to the element (see http://selenium.googlecode.com/git/docs/api/javascript/enum_webdriver_Key.html)
I would suggest that you go through http://angular.github.io/protractor/#/tutorial as a starting place.
2) That's because driver
is a property in browser
and not a function. Use browser.driver
to access the raw webdriver (although as a new user, you shouldn't have to use it)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments