-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Protractor.prototype.getInstance fails when Protractor is globally installed #36
Description
summary
I ran into this when installing protractor globally with npm install -g protractor
and attempting to run with protractor example/protractorConf.js
, it seems that with protractor installed globally there is a problem with protractor.getInstance()
returning undefined which leads me to think this is a path issue with one of the module imports within the protractor code.
The two lines of code that trigger the below exception are:
https://github.com/juliemr/protractor/blob/master/example/onProtractor.js#L10
https://github.com/juliemr/protractor/blob/master/example/onProtractor.js#L21
steps to reproduce
npm install -g protractor
cd [path-where-you-have-protractor-checked-out]
protractor example/protractorConf.js
protractor terminal output
$ pwd
/Users/davidmosher/code/protractor
davidmosher@localhost:~/code/protractor (master) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [11:30:57]
$ protractor example/protractorConf.js
Using the selenium server at http://localhost:4444/wd/hub
FF
Failures:
1) angularjs homepage should greet using binding
Message:
TypeError: Cannot call method 'get' of undefined
Stacktrace:
TypeError: Cannot call method 'get' of undefined
at null.<anonymous> (/Users/davidmosher/code/protractor/example/onProtractor.js:10:10)
at /Users/davidmosher/code/protractor/jasminewd/index.js:54:12
at webdriver.promise.ControlFlow.runInNewFrame_ (/Users/davidmosher/code/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1431:20)
at webdriver.promise.ControlFlow.runEventLoop_ (/Users/davidmosher/code/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1296:8)
at wrapper [as _onTimeout] (timers.js:252:14)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
==== async task ====
at null.<anonymous> (/Users/davidmosher/code/protractor/jasminewd/index.js:53:12)
at null.<anonymous> (/usr/local/lib/node_modules/protractor/node_modules/minijasminenode/lib/async-callback.js:45:37)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
2) angularjs homepage should list todos
Message:
TypeError: Cannot call method 'get' of undefined
Stacktrace:
TypeError: Cannot call method 'get' of undefined
at null.<anonymous> (/Users/davidmosher/code/protractor/example/onProtractor.js:21:10)
at /Users/davidmosher/code/protractor/jasminewd/index.js:54:12
at webdriver.promise.ControlFlow.runInNewFrame_ (/Users/davidmosher/code/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1431:20)
at webdriver.promise.ControlFlow.runEventLoop_ (/Users/davidmosher/code/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1296:8)
at wrapper [as _onTimeout] (timers.js:252:14)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
==== async task ====
at null.<anonymous> (/Users/davidmosher/code/protractor/jasminewd/index.js:53:12)
at null.<anonymous> (/usr/local/lib/node_modules/protractor/node_modules/minijasminenode/lib/async-callback.js:45:37)
Finished in 0.044 seconds
2 tests, 2 assertions, 2 failures
selenium server terminal output
$ java -jar /usr/local/opt/selenium-server-standalone/selenium-server-standalone-2.33.0.jar -p 4444 -Dwebdriver.chrome.driver=/usr/local/opt/chromedriver/bin/chromedriver
Jul 20, 2013 11:34:03 AM org.openqa.grid.selenium.GridLauncher main
INFO: Launching a standalone server
Setting system property webdriver.chrome.driver to /usr/local/opt/chromedriver/bin/chromedriver
11:34:08.149 INFO - Java: Apple Inc. 20.51-b01-457
11:34:08.150 INFO - OS: Mac OS X 10.8.4 x86_64
11:34:08.161 INFO - v2.33.0, with Core v2.33.0. Built from revision 4e90c97
11:34:08.287 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
11:34:08.288 INFO - Version Jetty/5.1.x
11:34:08.289 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
11:34:08.289 INFO - Started HttpContext[/selenium-server,/selenium-server]
11:34:08.290 INFO - Started HttpContext[/,/]
11:34:08.332 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@47d62270
11:34:08.333 INFO - Started HttpContext[/wd,/wd]
11:34:08.342 INFO - Started SocketListener on 0.0.0.0:4444
11:34:08.342 INFO - Started org.openqa.jetty.jetty.Server@54cbf30e
11:34:34.683 INFO - Executing: [new session: {browserName=chrome}] at URL: /session)
11:34:34.697 INFO - Creating a new session for Capabilities [{browserName=chrome}]
Started ChromeDriver
port=47466
version=26.0.1383.0
log=/Users/davidmosher/code/protractor/chromedriver.log
objc[38541]: Object 0x79a75480 of class NSPathStore2 autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
objc[38541]: Object 0x79c752a0 of class NSPathStore2 autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
objc[38541]: Object 0x79c75550 of class NSConcreteData autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
objc[38541]: Object 0x79a75510 of class __NSCFString autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
objc[38541]: Object 0x79c75210 of class NSBundle autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
11:34:36.265 INFO - Done: /session
11:34:36.281 INFO - Executing: org.openqa.selenium.remote.server.handler.GetSessionCapabilities@472462b3 at URL: /session/0307b782-d185-4af4-acd8-8dbe4b52be6a)
11:34:36.281 INFO - Done: /session/0307b782-d185-4af4-acd8-8dbe4b52be6a
11:34:36.295 INFO - Executing: [set script timeoutt: 100000] at URL: /session/0307b782-d185-4af4-acd8-8dbe4b52be6a/timeouts/async_script)
11:34:36.301 INFO - Done: /session/0307b782-d185-4af4-acd8-8dbe4b52be6a/timeouts/async_script
11:34:36.306 INFO - Executing: [delete session: 0307b782-d185-4af4-acd8-8dbe4b52be6a] at URL: /session/0307b782-d185-4af4-acd8-8dbe4b52be6a)
11:34:36.874 INFO - Done: /session/0307b782-d185-4af4-acd8-8dbe4b52be6a
conclusions
This does not occur when using the local binary ./bin/protractor example/protractorConf.js
or if you have used npm link
within the protractor project directory (which makes sense as it just provides a global alias for the protractor
command that points to the local binary in ./bin/protractor).
I also tested this against my own project and tests and could not get specs to execute using globally installed protractor. My workaround for the time being has just been to execute specs using ./node_modules/protractor/bin/protractor config/spec-e2e.js
as can be seen here