Confused about protractor v1.4.0 'protractor' and 'browser' global variables

Suren Aznauryan

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.

hankduan

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Protractor set global variables

From Dev

protractor angularJS global variables

From Dev

Custom browser actions in Protractor

From Dev

browser.getProcessedConfig in Protractor

From Dev

Protractor instance vs browser

From Dev

Detecting browser with protractor

From Dev

Dynamic variables in protractor

From Dev

When to assign variables in Protractor?

From Dev

When to assign variables in Protractor?

From Dev

Unable to run "Protractor test scripts in Firefox browser" for "angular 4 applicaiton"

From Dev

Protractor - get browser title as string

From Java

What is browser.ignoreSynchronization in protractor?

From Dev

Protractor/Selenium: run browser in the background

From Dev

Protractor - get browser title as string

From Dev

Protractor Chained Elements by Using Variables?

From Dev

protractor checking value of a javascript global variable

From Dev

protractor checking value of a javascript global variable

From Dev

How to call global env variable for gulp protractor

From Dev

Protractor browser.wait doesn't wait

From Dev

Loading Browser only once in Protractor.NET?

From Dev

How to use browser.getCurrentUrl() in a protractor test?

From Dev

Check there were no errors in the browser console with Protractor

From Dev

Protractor - open browser, wait, run tests

From Dev

Get the current browser name in Protractor test

From Dev

How to pass variable from browser to Protractor

From Dev

How to explain using browser.sleep in protractor

From Dev

Is it possible to run protractor test with the head on a remote browser?

From Dev

What is a good headless browser to run with protractor?

From Dev

Protractor - Where to use browser.waitForAngular()

Related Related

HotTag

Archive