在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):mllrsohn/gulp-protractor开源软件地址(OpenSource Url):https://github.com/mllrsohn/gulp-protractor开源编程语言(OpenSource Language):JavaScript 97.7%开源软件介绍(OpenSource Introduction):gulp-protractor
UsageFirst, install npm install --save-dev gulp-protractor Then, add it to your var protractor = require("gulp-protractor").protractor;
gulp.src(["./src/tests/*.js"])
.pipe(protractor({
configFile: "test/protractor.config.js",
args: [
'--baseUrl', 'http://127.0.0.1:8000',
'--suite', 'login',
'--params.environment', 'test'
]
}))
.on('error', function(e) { throw e }) Protractor WebdriverYou have to update and start a standalone selenium server. Please read the offical instructions. You can also ensure that the driver is installed by using the You have 2 options to start the selenium server. The first one is to let Protractor handle it automatically, including stopping it once your tests are done. To do that, simply point to the selenium jar in the protractor config file (you will need to update the version number accordingly) instead of the address: // The file path to the selenium server jar ()
seleniumServerJar: './node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.2.0.jar',
// seleniumAddress: 'http://localhost:4444/wd/hub', The second option is to let the gulp task handle it with the built-in webdriver snippet. If you decide to start it that way, the task will keep running indefinitely. var webdriver_standalone = require("gulp-protractor").webdriver_standalone;
gulp.task('webdriver_standalone', webdriver_standalone); APIprotractor(options)options.configFileType: The path to your protractor config options.argsType: Arguments get passed directly to the protractor call Read the docs for more information options.debugType: Enables Protractor's debug mode, which can be used to pause tests during execution and to view stack traces. webdriver_update_specific(options)options.webDriverManagerArgsType: // Download and update the selenium driver
var webdriver_update = require('gulp-protractor').webdriver_update_specific;
// Downloads the selenium webdriver - stupid solution to pass extra args like ignore_ssl
gulp.task('webdriver_update', webdriver_update({
webdriverManagerArgs: ['--ignore_ssl']
})); Running Protractor without a pluginIf you want to avoid using a plugin at all, here are gulp tasks which install the webdriver and start protractor: First install the protractor package:
Then add these tasks to your // gulpfile.js should be in workspace root for this example
var gulp = require('gulp');
var path = require('path');
var child_process = require('child_process');
function getProtractorBinary(binaryName){
var winExt = /^win/.test(process.platform)? '.cmd' : '';
var protractorBin = path.join('node_modules', '.bin', binaryName);
return path.join(protractorBin, winExt);
}
gulp.task('protractor-install', function(done){
child_process.spawn(getProtractorBinary('webdriver-manager'), ['update'], {
stdio: 'inherit'
}).once('close', done);
});
gulp.task('protractor-run', function (done) {
var argv = process.argv.slice(3); // forward args to protractor
child_process.spawn(getProtractorBinary('protractor'), argv, {
stdio: 'inherit'
}).once('close', done);
}); You can add command line arguments for protractor behind the gulp task:
License |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论