selenium - Error : profile.getTemplateDir is not a function -
i'm trying implement multi-browser test protractor firefox , chrome. test, need change download path. in chrome, works in firefox, solution found involved changing profile of firefox. found way in answers of question set firefox profile protractor .
but when try run multiple instance of navigator alongside of 1 instance of firefox modified profile, error profile.gettemplatedir not function
.
here code in protractor configuration file :
var q = require('q'); var firefoxprofile = require("selenium-webdriver/firefox").profile function getprofiles() { let deferred = q.defer(); let multicapabilities = [{ browsername: 'chrome' }] deferred.resolve(multicapabilities); let firefoxprofile = new firefoxprofile(); firefoxprofile.setpreference("browser.download.folderlist", 2); firefoxprofile.setpreference("browser.download.manager.showwhenstarting", false); firefoxprofile.setpreference("browser.download.dir", '/tmp'); let foxcapabilities = { browsername: 'firefox', firefox_profile: firefoxprofile }; multicapabilities.push(foxcapabilities); deferred.resolve(multicapabilities); return deferred.promise; } exports.config = { seleniumaddress: "http://localhost:4444/wd/hub", specs: [ 'spec.js' ], framework: 'jasmine2', getmulticapabilities: getprofiles, jasminenodeopts: { defaulttimeoutinterval: 30000 }, };
does knows why error triggered , how resolve ?
thanks
so have digged issue debugging code , seems limitation/bug in selenium web-driver
when getmulticapabilities
returns multiple browsers, protractor creates fork of process run test
this forked process sent profile created json
the childprocess can receive json data in form of text , not in form of profile
object
later creategeckodriver
function called profile object. code of creategeckodriver
expecting profile object
so code needs fixed in selenium webdriver , should check if profile sent encoded or not. code have used needs fixed encode profile. below work once selenium driver patched allow sending encoded profile
var firefox = require('selenium-webdriver/firefox'); var q = require('q'); var firefoxprofile = require("selenium-webdriver/firefox").profile var makefirefoxprofile = function (preferencemap) { var deferred = q.defer(); var firefoxprofile = new firefoxprofile(); (var key in preferencemap) { firefoxprofile.setpreference(key, preferencemap[key]); } firefoxprofile.encode().then(function(encodedprofile){ cap = { "browsername": "firefox", marionette: true, "firefox_profile": encodedprofile, }; deferred.resolve(cap); }); return deferred.promise; }; exports.config = { seleniumaddress: "http://localhost:4444/wd/hub", specs: [ 'spec.js' ], framework: 'jasmine', getmulticapabilities: function () { return q.all([ { browsername: 'chrome' }, makefirefoxprofile( { "browser.download.folderlist": 2, "browser.download.dir": "/path/to/save/downloads", "browser.helperapps.neverask.savetodisk": "application/zip" } ) ]); }, jasminenodeopts: { defaulttimeoutinterval: 180000 } };
Comments
Post a Comment