Giter Site home page Giter Site logo

angular / protractor Goto Github PK

View Code? Open in Web Editor NEW
8.8K 490.0 2.3K 9.29 MB

E2E test framework for Angular apps

Home Page: http://www.protractortest.org

License: MIT License

JavaScript 51.99% HTML 5.01% Shell 0.94% CSS 0.29% TypeScript 41.33% Less 0.45%
angular javascript selenium node test webdriver protractor end-to-end

protractor's Introduction

Protractor Build Status CircleCI Status Join the chat at https://gitter.im/angular/protractor

Protractor is an end-to-end test framework for Angular and AngularJS applications. Protractor is a Node.js program built on top of WebDriverJS. Protractor runs tests against your application running in a real browser, interacting with it as a user would.

Compatibility

Protractor 5 is compatible with nodejs v6 and newer.

Protractor works with AngularJS versions greater than 1.0.6/1.1.4, and is compatible with Angular applications. Note that for Angular apps, the binding and model locators are not supported. We recommend using by.css.

Getting Started

See the Protractor Website for most documentation.

To get set up and running quickly:

Once you are familiar with the tutorial, you’re ready to move on. To modify your environment, see the Protractor Setup docs. To start writing tests, see the Protractor Tests docs.

To better understand how Protractor works with the Selenium WebDriver and Selenium Server see the reference materials.

Getting Help

Check the Protractor FAQ and read through the Top 20 questions on StackOverflow.

Please ask usage and debugging questions on StackOverflow (use the "protractor" tag), the Gitter chat room, or in the Angular discussion group. (Please do not ask support questions here on Github.)

For Contributors

See DEVELOPER.md

protractor's People

Contributors

alecxe avatar andresdominguez avatar bcaudan avatar chirayuk avatar cnishina avatar crispusdh avatar eddiemonge avatar el-davo avatar elgalu avatar hankduan avatar heathkit avatar igniteram avatar jan-molak avatar jeffbcross avatar jesselpalmer avatar juliemr avatar karthiktv006 avatar kayhadrin avatar manoj9788 avatar marketionist avatar mdasberg avatar mgol avatar monkpit avatar nicktomlin avatar qiyigg avatar sjelin avatar stalniy avatar thorn0 avatar vedharish avatar wswebcreation avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

protractor's Issues

configuration is not working

I am new to angular JS testing , I followed you instruction for setup the protractor with sample. While on execute the testcases I getting a error

C:\Documents and Settings\sweet\Application Data\npm\node_modules\protractor\bin>protractor e:\protractor_workspace\protractor-master\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:

I changed browser name and path only in "protractorConf.js".

capabilities: {
'browserName': 'firefox'
},

// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
// Spec folders are relative to the current working directly when
// protractor is called. This can be folders or files.
specFolders: ['e:/protractor_workspace/protractor-master/example/onProtractor.js'],
isVerbose: false,
showColors: true,
includeStackTrace: true
}
};

let me know I made any mistake ?

Provide recommended DSL format

Should provide best practices for how to organize testing a page, such as the DSL that Angular Scenario Runner provided.

Docs: relationship with Karma

I'm not sure if Protractor is intended to to be used with, in addition to, or instead of Karma.

Maybe a few words in the Readme would be helpful?

Junit Reporter

We want to run protractor tests on Jenkins, so it would be very useful if there was a junit reporter (like karma has) so the status of the tests can be reported by Jenkins

Access to other selenium-webdriver features via mixin

Currently it is not possible to access other features from selenium-webdriver that are not provided in that package's WebDriver class.

In particular, this was biting me because I needed access to ActionSequence. Currently the only way for me to reach it is to require another copy of selenium-webdriver within my test script:

var webdriver = require('selenium-webdriver');
// ...
ptor.findElement(protractor.by.id("Something"))
.then(function(e)) {
    new webdriver.ActionSequence(ptor.driver)
    .dragAndDrop(elem, somewhereElse)
    .perform();
});

One solution would be for protractor to mix the other webdriver exports into its own exports.

May I know how to pass different configuration to my test cases?

Similar to karma,if I want to run same test case in multiple browsers, how can I pass my browser name from gruntfile instead of hard code in test case?

Also, if i want to run post build e2e testing , how can I pass pram to the URL from grunt file? You know Karma provides powerful configuration options , can we have similar in protractor?

I can run my end 2 end with protractor, but it is just not so perfect, like auto download selenium stnadalone/chromedriver , and run same test cases in multiple browsers.

Can protractor test a login that is not angular based

This question is on stackoverflow.

I am testing an application written predominantly in angularjs however some elements of the application are written in .NET C#, such as the login form.

My question is this.

Can I leverage Protractor and test my application fully with e2e testing.

I have tried using protractor and I am happy with it thus far. However I do not seem to be able to test a page that written in .NET. I am not sure if this is because protractor only tests the elements of an angular application or if it is the way I have written my tests.

I have tried searching for the elements in the page like the example below.

ptor.findElement(protractor.By.xpath('/html/body/div/div[1]/section/input')).sendKeys('xxx');

But this only returns an UnknownError: javascript error: cannot call method 'get' of undefined.

I know that this error means the elements are not visible on the page, however I have placed a timeout in my test shown below to see if this helps. I have also tried sleep(5000) but this doesn't help either.

it('test if div apears', function () {
ptor = protractor.getInstance();
ptor.get('/Test/Index');
var text = ptor.findElement(protractor.By.xpath('/html/body/div/div[1]/section/input')).sendKeys('xxx');
expect(text).toEqual('Index');
}, 10000);

all I require is to be able to add text to a dynamically created input box, created by Html.TextBoxFor()

`Keys` is not defined when using `keyDown` action

When trying to create a test which checks the result of an option + click() event in my app, Keys is not defined.

This is the test being run (apologies if the JS looks malformed, it's converted from CoffeeScript):

var driver = new webdriver.Builder()
    .usingServer('http://localhost:4444/wd/hub')
    .withCapabilities(webdriver.Capabilities.chrome()).build()

driver.manage().timeouts().setScriptTimeout(30000)
var ptor = protractor.wrapDriver(driver)

it('opens new tab with OPTION+click', function() {
    ptor.keyDown(Keys.ALT)
        .then(function() {
            ptor.findElement(protractor.By.repeater('item in ses.items').row(4).column("{{item.subject}}")).click();
            ptor.keyUp(Keys.ALT);
        })

    ptor.findElements(protractor.By.repeater('item in ses.navItems'));
        .then(function(tabs) {
            expect(tabs.length).toBe(1);
        });
});

I've also tried the following variations for Keys.ALT: ptor.driver.Keys.ALT, ptor.driver.Key.ALT, and Key.ALT

It's entirely possible I'm not writing this test correctly. If that's the case I'd appreciate any pointers in testing clicks with key modifiers.

feature request: mocha adapter support

Would love to see this supported. Currently we are experimenting with using protractor as a library for our mocha tests; thank you, included code example ;)

If there is some high-level conceptual understanding that someone could present that would describe how to accomplish this, I would love to fork this and do it myself. Some guidance as to the right direction to head would be awesome, if anyone has any ideas.

Reusing an element does not resynchronize with angular

For example:

    var slowHttpStatus =
      ptor.findElement(protractor.By.binding('slowHttpStatus'));
    var button = ptor.findElement(protractor.By.css('[ng-click="slowHttp()"]'));

    expect(slowHttpStatus.getText()).toEqual('not started');

    button.click();

    expect(slowHttpStatus.getText()).toEqual('done');

Because slowHttpStatus is being reused instead of found again with ptor.findElement it does wait for Angular to finish up $http requests.

ptor.getCurrentUrl() is not working correct

Hello,

I've just started looking at protractor for our angularjs apps and looks very promising.

I want to use ptor.getCurrentUrl() to get url after login to make sure that I actually got logged in. My code looks something like this:

var util = require('util');

describe('Sign In Page', function() {
    var ptor;

    beforeEach(function() {
        ptor = protractor.getInstance();
        ptor.get('#/login/');
        ptor.waitForAngular();
    });

    it ('Login', function(){
        ptor.findElement(protractor.By.css('input[name=email]')).sendKeys("***");
        ptor.findElement(protractor.By.css('input[name=password]')).sendKeys("***");
        ptor.waitForAngular();
        var currentUrl = ptor.getCurrentUrl();
        console.log(currentUrl);
    }, 20000);

    it('afterAll', function(){
    });
});

I'm using

    var currentUrl = ptor.getCurrentUrl();
    console.log(currentUrl);

to see what exactly gets stored and in console I see following result:

APankov$ node_modules/.bin/protractor conf.js
Using the selenium server at http://localhost:4444/wd/hub
{ then: [Function: then],
  cancel: [Function: cancel],
  isPending: [Function: isPending] }

What am doing wrong in this case?

Thank you

Assertion never seems to happen within .then block

I've been attempting to use Protractor to test some of my angular code but I can't seem to get any assertions to work. I can see my web app fire up, and selenium is running properly but I immediately see: 1 test, 0 assertions, 0 failures even though I have assertions in place.

Here's a screenshot of my .conf file, my login_spec.js and the output I'm seeing in console.

screen shot 2013-07-09 at 1 58 11 am

Here's another screenshot that shows the angular template file that is injected into my ng-view:

screen shot 2013-07-09 at 2 01 48 am

The console.log correctly fires, and I can see the output in my terminal, but the assertion doesn't seem to have any effect.

Protractor E2E test times out when app polls an API at regular intervals

Our app has a poller which makes calls to an API every 3 seconds. When I load a page with has an active instance of the poller Protractor will always time out.

The poller is started when the page loads and uses the Angular $timeout function.

Is there a way to get Protractor to ignore the poller or send a signal to the app to pause the poller momentarily so the E2E test can finish running?

Add By.cssSelector function

protractor.By.cssSelector is not defined. The webdriver API includes this functionality and so should protractor.js.

Trace:
TypeError: Object [object Object] has no method 'cssSelector'

Protractor.prototype.getInstance fails when Protractor is globally installed

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

  1. npm install -g protractor
  2. cd [path-where-you-have-protractor-checked-out]
  3. 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

Runner should allow additional arguments to be passed to seleniumJar

I want to let the protractor runner launch my selenium standalone server, but I need it to launch chromedriver from a manually-specified path to the binary. Presently, protractor will only launch with chromedriver if the chromedriver binary is available in my PATH.

I propose adding a string property to config:

seleniumJarArgs: "-Dwebdriver.chrome.driver=/path/to/chromedriver"

Which would be executed as

java -jar path/to/selenium-standalone.jar -Dwebdriver.chrome.driver=/path/to/chromedriver

TypeError: Cannot call method 'get' of undefined

Hi. I cloned the repo, followed all instructions but when I execute the example suite or the testapp suite, I always get the same error:

TypeError: Cannot call method 'get' of undefined

When I look at the code, it is always referring at ptor instance being undefined.

Context:
The test application is up and running on port 8000 and the angularjs site is accesible as well. Both suites should be able to fulfill its purpose.
Im running on osx, using chrome driver and the standalone selenium server.
I have not made any change on the code.
As an example of the error:

1) test application finding elements in forms should find an element by binding 
  Message:
 TypeError: Cannot call method 'get' of undefined
 Stacktrace:
   TypeError: Cannot call method 'get' of undefined
     at null.<anonymous> (/Users/sesteva/Development/Projects/protractor/spec/testAppSpec.js:26:12)
     at jasmine.Block.execute (/usr/local/share/npm/lib/node_modules/protractor/node_modules/jasmine-node/lib/jasmine-node/jasmine-1.3.1.js:1064:17)
     at jasmine.Queue.next_ (/usr/local/share/npm/lib/node_modules/protractor/node_modules/jasmine-node/lib/jasmine-node/jasmine-1.3.1.js:2096:31)
     at jasmine.Queue.start (/usr/local/share/npm/lib/node_modules/protractor/node_modules/jasmine-node/lib/jasmine-node/jasmine-1.3.1.js:2049:8)
     at jasmine.Spec.execute (/usr/local/share/npm/lib/node_modules/protractor/node_modules/jasmine-node/lib/jasmine-node/jasmine-1.3.1.js:2376:14)
     at jasmine.Queue.next_ (/usr/local/share/npm/lib/node_modules/protractor/node_modules/jasmine-node/lib/jasmine-node/jasmine-1.3.1.js:2096:31)
     at jasmine.Queue.start (/usr/local/share/npm/lib/node_modules/protractor/node_modules/jasmine-node/lib/jasmine-node/jasmine-1.3.1.js:2049:8)
     at jasmine.Suite.execute (/usr/local/share/npm/lib/node_modules/protractor/node_modules/jasmine-node/lib/jasmine-node/jasmine-1.3.1.js:2521:14)
     at jasmine.Queue.next_ (/usr/local/share/npm/lib/node_modules/protractor/node_modules/jasmine-node/lib/jasmine-node/jasmine-1.3.1.js:2096:31)
     at jasmine.Queue.start (/usr/local/share/npm/lib/node_modules/protractor/node_modules/jasmine-node/lib/jasmine-node/jasmine-1.3.1.js:2049:8)

Thanks

Sleep() or Pause() functionality

Someway to make the Protractor sleep for the given amount of time, would be helpful to have in case of fast traversing pages, where not much activities are happening.

Tried to start up selenium standalone server in my testing script, but can't pass chrome webdriver path

I tried to start up selenium standalone server in my testing script:
var SeleniumServer = require('selenium-webdriver/remote');
var server = new SeleniumServer.SeleniumServer({
jar: 'test/e2e/selenium-server-standalone-2.33.0.jar',
port: 4444
});
server.start();

I can start up the server , and works fine in firefox. But if run test for Chrome, there is no parameter for me to pass the chromedriver's location, and it looks for the chromedriver in root path instead.

Timed out after 5000 msec waiting for spec to complete

I am trying protractor to conduct my e2e test on angular app . At beginning i have just written two test cases with simple DOM assertions sometime my test run successfully but majority of time they fail with Message timeout:timed out after 5000 msec waiting for spec to complete .Could you guide me how to resolve this issue

Error: Angular is not defined when working with none Angular applications

I am testing web application with some access restrictions. Main part of this application is developed using AngularJS framework however to access this part user needs to be authenticated by "none Angular" web page. When I am trying to get instance of protractor to enter credentials on "none Angular" page using following code

var ptor = protractor.getInstance();
ptor.get('http://localhost:3000');

I get error

15:26:19.740 INFO - Executing: [new session: {browserName=chrome}] at URL: /session)
15:26:19.742 INFO - Creating a new session for Capabilities [{browserName=chrome}]
Started ChromeDriver
port=34098
version=26.0.1383.0
log=C:\opt\selenium-server\chromedriver.log
15:26:20.489 INFO - Done: /session
15:26:20.496 INFO - Executing: org.openqa.selenium.remote.server.handler.GetSessionCapabilities@5bb48c07 at URL: /session/b01e86b3-7e7a-4dc1-afd5-f95232bb69c6)
15:26:20.498 INFO - Done: /session/b01e86b3-7e7a-4dc1-afd5-f95232bb69c6
15:26:20.528 INFO - Executing: [set script timeoutt: 100000] at URL: /session/b01e86b3-7e7a-4dc1-afd5-f95232bb69c6/timeouts/async_script)
15:26:20.559 INFO - Done: /session/b01e86b3-7e7a-4dc1-afd5-f95232bb69c6/timeouts/async_script
15:26:20.596 INFO - Executing: [execute async script: return (function () {
var callback = arguments[arguments.length - 1];
angular.element(document.body).injector().get('$browser').
notifyWhenNoOutstandingRequests(callback);
}).apply(null, arguments);, []] at URL: /session/b01e86b3-7e7a-4dc1-afd5-f95232bb69c6/execute_async)
15:26:21.239 WARN - Exception thrown
org.openqa.selenium.WebDriverException: Script execution failed. Script: return (function () {
var callback = arguments[arguments.length - 1];
angular.element(document.body).injector().get('$browser').
notifyWhenNoOutstandingRequests(callback);
}).apply(null, arguments);;
angular is not defined (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 13 milliseconds
Build info: version: '2.33.0', revision: '4e90c97', time: '2013-05-22 15:32:38'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_25'
Session ID: 7c5980b1f3b725539e6b4ce7af942af0
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=XP, chrome.chromedriverVersion=26.0.1383.0, acceptSslCerts=false, javascriptEnabled=true, browserName=chrome, rotatable=false, locationContextEnabled=false, version=28.0.1500.95, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, webStorageEnabled=true, nativeEvents=true, applicationCacheEnabled=false, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:191)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebDriver.executeAsyncScript(RemoteWebDriver.java:481)
at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:101)
at com.sun.proxy.$Proxy1.executeAsyncScript(Unknown Source)
at org.openqa.selenium.support.events.EventFiringWebDriver.executeAsyncScript(EventFiringWebDriver.java:221)
at org.openqa.selenium.remote.server.handler.ExecuteAsyncScript.call(ExecuteAsyncScript.java:57)
at org.openqa.selenium.remote.server.handler.ExecuteAsyncScript.call(ExecuteAsyncScript.java:1)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:169)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
15:26:21.245 WARN - Exception: Script execution failed. Script: return (function () {
var callback = arguments[arguments.length - 1];
angular.element(document.body).injector().get('$browser').
notifyWhenNoOutstandingRequests(callback);
}).apply(null, arguments);;
angular is not defined (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 13 milliseconds
Build info: version: '2.33.0', revision: '4e90c97', time: '2013-05-22 15:32:38'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_25'
Session ID: 7c5980b1f3b725539e6b4ce7af942af0
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=XP, chrome.chromedriverVersion=26.0.1383.0, acceptSslCerts=false, javascriptEnabled=true, browserName=chrome, rotatable=false, locationContextEnabled=false, version=28.0.1500.95, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, webStorageEnabled=true, nativeEvents=true, applicationCacheEnabled=false, takesScreenshot=true}]
15:26:21.459 INFO - Executing: [delete session: b01e86b3-7e7a-4dc1-afd5-f95232bb69c6] at URL: /session/b01e86b3-7e7a-4dc1-afd5-f95232bb69c6)
15:26:22.771 INFO - Done: /session/b01e86b3-7e7a-4dc1-afd5-f95232bb69c6

I think it would be nice to allow for using protractor also in cases similar to mine

expose driver functionality

When wrapping a driver, shouldn't protractor expose the underlying driver methods as well as angular-specific ones? For example:

ptor.get("http://www.smashingmagazine.com");
ptor.getTitle().then(function(title) {
  expect(title).to.equal('Smashing Magazine — For Professional Web Designers and Developers');
  done();
});    

getTitle is a method on the wrapped driver, but not available after being wrapped.

No way to get number of elements returned by `findElements`

This issue may not be Protractor related but I'm not sure where else to look. My setup is using Protractor with jasmine-node to test an Angular front-end to a Rails app. When I try to get how many elements are found by protractor.findElements it always errors out.

My spec file follows the onJasmineNode example. So far I've tried the following:

  • ptor.findElements(protractor.By.css('.selector-string')).size();: [object object] has no method size
  • ptor.findElements(protractor.By.css('.selector-string')).count();: [object object] has no method count
  • ptor.findElements(protractor.By.css('.selector-string')).length;: undefined is not a function

For fun I wrapped the findElements in a console.log and it returns this:

{ then: [Function: then],
  cancel: [Function: cancel],
  isPending: [Function: isPending] }

Protractor will not switchTo().window(handle). nameOrHandle Undefined error.

Question cross-posted on SO. http://stackoverflow.com/q/18394261/1226721

I have gone around this as many ways as I can think, and still can't get this to work. I am trying to switch to a popUp as a way to automate a login. Protractor goes to my main page, clicks the login button and waits for the loggin popup.

The setup:

var ptor;
beforeEach(function() {
  var handlesDone = false;
  ptor = protractor.getInstance();
  ptor.get('#/');
  runs(function() {
    return ptor.findElement(protractor.By.className('btn')).click();
  });
  waits(3000);
  runs(function() {
    return ptor.getAllWindowHandles().then(function(handles) {
      popUpHandle = handles[1];
      parentHandle = handles[0];
      return handlesDone = true;
    });
  });
  waitsFor(function() {
    return handlesDone;
   });
 });

So far so good, next I want to make sure that I have, in fact, a window handle for my pop-up:

describe('login', function() {
  it('should switch to popUp\'s handle', function() {
    expect(popUpHandle).toBeDefined();

finally, I try to switch to this window:

  ptor.switchTo().window(popUpHandle).getWindowHandle().then(function(handle) {
    expect(handle).toEqual(popUpHandle);
    });
  });
});

Yet no matter what I have tried, I keep getting the following error:


login
should switch to popUp's handle

Failures:

  1. login should switch to popUp's handle
    Message:
    ReferenceError: nameOrHandle is not defined
    Stacktrace:
    ReferenceError: nameOrHandle is not defined
    at webdriver.WebDriver.TargetLocator.window (.../node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:1385:32)
    at null. (.../test/e2e/e2e-spec.js:40:21)
    at ...node_modules/protractor/jasminewd/index.js:54:12
    at webdriver.promise.ControlFlow.runInNewFrame_ (.../node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1438:20)
    at webdriver.promise.ControlFlow.runEventLoop_ (.../node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1303:8)
    at Timer.exports.setInterval.timer.ontimeout (timers.js:234:14)
    ==== async task ====

Finished in 5.388 seconds
1 test, 2 assertions, 1 failure


as you can see, I have 2 assertions:

  1. that popUpHandle is defined

  2. that the handle after the switchTo is the same as the popUpHandle

I have tested that I have 2 handles total. I have tested that they are both strings. I have tested that they are different from each other. In this example I test that popUpHandle is defined. All those test pass. Yet no mater what I do, when I try to plug a handle into the .switchTo().window() method I get the same "nameOrHandle is not defined".

I'm stumped. There is so little documentation on WebDriverjs I can't even be sure that switchTo is implemented. Does anyone know what is going on here?

Thanks.

A way to click on hidden elements

This question has been asked on stackoverflow also.

Is there a way to click on a hidden value. I would like to be able to do something like

driver.findElement(protractor.By.xpath('/html/body/div/div/a')).mouseover.then(function() {
ptor.findElement(protractor.By.className('name').getText().then(function(result) {
expect(result).toBe('Me');
});
});

when the menu item is not visible, or are we limited with this at the moment. If this is not possible would this be a likely addition to Protractor in the future and is there a way around this issue at present.

Runner should be separated into CLI and Node Module

I'd like to be able to run the runner from Grunt instead of bash, but the runner is currently just a CLI that gets the config from the process args. I propose making the runner an exported node library, and creating a separate CLI script to wrap it.

Docs: Protractor documentation

Is there a plan in the short term to document the angular.js / protractor integration? Right now the only way to see the angular specific protractor functions is by browsing the codebase.

Asynchronous Issues Running Tests: Browser Opens After Tests Complete

Hi,
This is a repost of issue #14 (apologies as I couldn't figure out how to reopen the closed issue per the closing comments). Some of the comments in that post seem to suggest that this may be a windows related issue. I'm running Win7 64 and am experiencing the same symptoms described in the original issue. I've added more details to the original issue thread.

I've added a timer test to attempt to wait for the browser to open and discovered that the browser doesn't actually open until my tests are complete. Putting a monster delay in the spec file (10 seconds) simply delayed the browser from opening until it completed running.

Thanks again for any help you can provide.

Is expect() executing before my model updates?

I started with a new project via yo angular and first tried to replace e2e with protractor. Here's my main.html:

<div class="hero-unit">
  <h1>'Allo, 'Allo!</h1>
  <p>You now have</p>
  <ul>
      <li ng-repeat="thing in awesomeThings">{{thing}}</li>
  </ul>               
  <p>installed.</p>
  <h3>Enjoy coding! - Yeoman</h3> 
  <button id="sendMessage" ng-click="sendMessage()">Send Message</button>
  <input type="text" id="msg" ng-model="message">
</div>

Here's my main controller:

'use strict';

angular.module('tradeblastApp')
  .controller('MainCtrl', function ($scope) {
    $scope.awesomeThings = [
      'HTML5 Boilerplate',
      'AngularJS',
      'Karma'
    ];

    $scope.sendMessage = function () {
      $scope.message = 'Message Received';
    };
  });

Here's my protractor test:

describe('App', function () {
  describe('Index', function () { 
    var ptor = protractor.getInstance();

    beforeEach(function () {
      ptor.get('');
    });

    it('should send a message', function () {
      var button = ptor.findElement(protractor.By.id('sendMessage'));
      var message = ptor.findElement(protractor.By.id('msg')).getText(); 
      expect(message).toBe('');       
      button.click();
      expect(message).toBe('Message Received');
    });
  });
});

Here's my protractor.conf.js:

exports.config = {
  seleniumServerJar: './selenium/selenium-server-standalone-2.34.0.jar',
  seleniumPort: null,
  chromeDriver: './selenium/chromedriver',
  seleniumArgs: [],
  specs: [
    'test/scenarios.js',
  ],
  capabilities: {
    'browserName': 'chrome'
  },
  baseUrl: 'http://localhost:9000',
  jasmineNodeOpts: {
    // onComplete will be called before the driver quits.
    onComplete: null,
    isVerbose: false,
    showColors: true,
    includeStackTrace: true
  }
};

Here's my error message:

$ protractor protractor.conf.js 
Starting selenium standalone server...
Selenium standalone server started at http://10.211.55.10:58088/wd/hub
F

Failures:

  1) App Index should send a message
   Message:
     Expected '' to be 'Message Received'.
   Stacktrace:
     Error: Expected '' to be 'Message Received'.
    at /usr/lib/node_modules/protractor/jasminewd/index.js:79:32
    at /usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/base.js:1178:15
    at webdriver.promise.ControlFlow.runInNewFrame_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1438:20)
    at notify (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:328:12)
    at notifyAll (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:297:7)
    at fulfill (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:402:7)
    at Object.webdriver.promise.asap (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:672:5)
    at webdriver.promise.ControlFlow.runInNewFrame_ (/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1449:25)

Finished in 4.604 seconds
1 test, 2 assertions, 1 failure

Shutting down selenium standalone server

I think this test should pass though as I literally see the appropriate message displayed in the browser before the test concludes and the browser closes. Also, I've tried changing var message = ptor.findElement(protractor.By.id('msg')).getText(); to var message = ptor.findElement(protractor.By.binding('{{message}}')).getText(); but then it can't even find the element, which is strange. Any thoughts?

Runner - Close open browsers after failed tests

Using chromedriver (on Mac), if tests fail or Webdriver throws an error, the browser windows remain open until I manually close them. Although this is just a nuissance on the desktop, it's problematic for CI environments.

HTTP/AJAX Mocking and assertions

Currently I'm running my tests against a server which responds to my AJAX requests with canned chunks of JSON. It would be great to be able to make assertions against these requests in a similar way to karma

$httpBackend.expectGET('some/url').respond({some: 'JSON'});

The only solution I have right now is to run protractor and my connect server in the same process and then write an interface a bit like this manually.

I'd love to get a discussion going about plans to deal with this in protractor.

Regression: `specs: ['spec-dir']` no longer works in 0.6.1

With 0.5.0 I can setup my conf.js file to point to a directory of spec files, which are automatically found and run:

// 0.5.0
jasmineNodeOpts: {
   specFolders: ['spec-dir']
}

With 0.6.1 and the change to minijasminenode this behaviour no longer works and users are required to enumerate each spec manually

// 0.6.1
specs: ['spec-dir/some_spec.js', 'spec-dir/some_other_spec.js']

This is a problematic regression as being able to point to specs-dir (or even a glob matcher) is preferable to enumerating each spec file manually IMHO.

Should be able to choose whether webdriver errors immediate quit or not

Currently, an error from webdriver (such as an element not found) immediately exits and prints the stack trace, and does not quit the driver. This is useful when in-depth debugging one test, but not very nice if you just want to run the entire suite and see your failures. There should be an option to just have errors turn into failures.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.