Sameera De Silva
2 min readDec 23, 2019

How to setup Protractor to run in Firefox browser.

Make sure that you have the latest Firefox and Protractor versions or the comparable versions .

To update the browser drivers type webdriver-manager update in command line .

Mine is Make sure that you have the latest version of Firefox and protractor. Mine is protractor -Version 5.4.2 and Firefox 71 browser version.

Please see my sample config.js file . Please see the comments to get a clear idea.

//protractor firefoxconfig.js
exports.config = {
framework: 'jasmine',
directConnect: false, //Start protractor without start the selenium server using webdriver-manager start. default value is fales
//This is only for chrome and firefox and use drivers instead of selenium server

capabilities: {
browserName: 'firefox',
'moz:firefoxOptions': {
args: ['--verbose'],
binary: 'C:/Program Files/Mozilla Firefox/firefox.exe' //Provide binary location to avoid potential binary not found errors
//Need to start cmd via admin mode to avoid permission error
}
},
//set to true So each spec will be executed in own browser instance. default value is false
//restartBrowserBetweenTests: true,
jasmineNodeOpts: {
//Jasmine provides only one timeout option timeout in milliseconds don't add ;
defaultTimeoutInterval: 180000
},

seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['src/com/sam/scriptjs/iframes.spec.js']
}

Here is a sample spec.js file which can be executed using the config,js

//iframes.spec.js
describe('Iframe example', function() {


//Each single it function is a test script
it('Iframe handling', function() {
browser.driver.ignoreSynchronization = true;
browser.waitForAngularEnabled(false);
browser.driver.manage().window().maximize();
browser.driver.get('http://demo.automationtesting.in/Frames.html');
expect(browser.getTitle()).toEqual('Frames');
});

it('Iframe handling', function() {
//right click near the element if it show view frame source it means it'sinside of an iframe
browser.switchTo().frame(0);//we can give name or index
//sendkeys inside of an element in an iframe
element(by.xpath('//input[@type="text"]')).sendKeys('Hi element inside of a one iframe');
// switch back to main contain
browser.switchTo().defaultContent();
//click element that not in any iframe
element(by.linkText('Home')).click();
});

})

No responses yet