Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure for Page Object pattern project #46

Closed
schwarcu opened this issue Sep 7, 2017 · 12 comments
Closed

Configure for Page Object pattern project #46

schwarcu opened this issue Sep 7, 2017 · 12 comments
Assignees

Comments

@schwarcu
Copy link

schwarcu commented Sep 7, 2017

How do I configure this to make it work when I have following project structure?
pages has PO files, specs has specifications files, data has files with all strings and parameters used for tests, selenium has chromeDriver etc.
capture

@schwarcu
Copy link
Author

schwarcu commented Sep 7, 2017

My gulp file:

var angularProtractor = require('gulp-angular-protractor');
var gulp = require('gulp');
gulp.task('test', function(callback) {
gulp
.src(['./**/*.js']) -<
.pipe(angularProtractor({
'configFile': 'tco-conf.js',
'debug': true,
}))
.on('error', function(e) {
console.log(e);
})
.on('end', callback);

});

@guan01
Copy link

guan01 commented Sep 7, 2017

Not sure where to start, can you post the error when you run your test?

I have cucumber setup with this framework.
I create pageObject.ts and in my steps.ts I declare like this

var expect = require('../common/chai.js');
var homePageObj = require('../homePage/homePage-object.js');
var allSupplierObj = require('../allSuppliers/allsupplier-object.js');
var loginPageObj = require('../login/login-page-object.js');
var cartPageObj = require('../cart/cart-object.js');
var ConnectDatabase = require('../common/connectDatabase.js');
var connectDatabase = new ConnectDatabase();
var sql = 'select * from agreement_acceptance;';
var specTimeOutMS = 30000;

@guan01
Copy link

guan01 commented Sep 7, 2017

to call the obj

loginPageObj.cartButton.click().then(function() {
});

@rochejul
Copy link
Owner

rochejul commented Sep 7, 2017

Hi

There is a bunch of examples at this link: https://github.com/rochejul/gulp-angular-protractor/tree/master/examples

Otherwise, could you make a sample of your project and attach it on the issue ? To understand what is the problem ?

Many thanks

@schwarcu
Copy link
Author

schwarcu commented Sep 8, 2017

You didn't understand my question. I have already done whole protractor project. Everything works well.
I am using directConnect, without webdriver selenium server.
Now I want to run my protractor test as a gulp task.

After some changes now I managed to run the protractor but I only want to run specs I have defined in my protractor config which are:
specs: [ "specs/pre-login-spec.js", "specs/login-spec.js", "specs/startpage-spec.js", "specs/topbar-spec.js", "specs/smallbar-spec.js", ],

bug gulp runs all specs from my specs folder, and with messed up order.
How do I force gulp to run only specs defined by protractor config? or suite if I define one

@schwarcu
Copy link
Author

schwarcu commented Sep 8, 2017

Current gulp file:

var angularProtractor = require('gulp-angular-protractor');
var gulp = require('gulp');
gulp.task('test', function (callback) {
gulp
.src(['./specs/**/*.js'])
.pipe(angularProtractor({
'configFile': 'tco-conf.js',
'autoStartStopServer': false
}))
.on('error', function (e) {
console.log(e);
})
.on('end', callback);

});

@schwarcu
Copy link
Author

schwarcu commented Sep 8, 2017

Also, I used to run protractor with parameters like:
protractor tco-conf.js --params.login.user "USERNAME" --params.login.password "PASSWORD"

how do I run protractor with gulp with such parameters?

@schwarcu
Copy link
Author

schwarcu commented Sep 8, 2017

Another issue: even if I define specs in gulp file, chrome opens but it doesn't go to any page, it doesn't execute any specs. I mean the browser itself.
capture

@rochejul
Copy link
Owner

rochejul commented Sep 8, 2017

Such as the gulp-protractor plugin, the specs property from the protractor config is ignored. So you should change the scope into your gulp file

For your blank page, it could be an issue with proxies or security environments. Check the protractor configuration to set up this point

Regards

@rochejul
Copy link
Owner

rochejul commented Sep 8, 2017

For security configuration, see angular/protractor#124

@rochejul rochejul self-assigned this Sep 8, 2017
@schwarcu
Copy link
Author

schwarcu commented Sep 8, 2017

I figured out blank page was caused by params not found. I passed parameters as args in gulp configuration.
It all works now.
Tho one question remains: what if I want to define 2 suites with separate sets of test cases? How do I put them in the gulp file? You said protractor specs are ignored

@rochejul
Copy link
Owner

rochejul commented Sep 8, 2017

That means you should declare two suites of tests (and so two gulp task)

Example:

/*jshint node: true, camelcase: false*/
/*global require: true*/

'use strict';

var gulp = require('gulp');
var gulpProtractorAngular = require('gulp-angular-protractor');

function setupProctator(specs, callback) {
	gulp
        .src(specs)
        .pipe(gulpProtractorAngular({
            'configFile': 'protractor.conf.js',
            'debug': false,
            'autoStartStopServer': true
        }))
        .on('error', function(e) {
            console.log(e);
        })
        .on('end', callback);
}

// Setting up the test task
gulp.task('protractor', function(callback) {
	setupProctator(['**/*.spec.js'], callback);
});

gulp.task('protractor:restricted', function(callback) {
	setupProctator(['example.spec.js'], callback);
});

Many thanks

@rochejul rochejul closed this as completed Sep 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants