Launch chrome with extension using protractor - selenium

I'm trying to launch chrome browser with "Modheader" extension using protractor by using the following in my conf.js
chromeOptions: {
args: [
'--load-extension=C:/Utilities/extension_2_2_4_0.crx'
],
But on running the test I get the following error:
Failed to load extension from ..... Manifest file is missing or unreadable
Is there any way to launch the browser with extension already installed OR is there any way to provide header with URL using protractor
baseUrl= www.abc.com
Header= 'name' : 'testuser'

Related

protractor error 105 and webdriver-manager interactions

I've seen this question before but nothing in the answers solved my problems. I am trying to do the protractor tutorial and here is the conf.js file:
// conf.js
exports.config = {
framework: 'jasmine',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['spec.js']
}
Here is the spec.js file:
// spec.js
describe('Protractor Demo App', function() {
it('should have a title', function() {
browser.get('http://juliemr.github.io/protractor-demo/');
expect(browser.getTitle()).toEqual('Super Calculator');
});
});
I am also getting ERROR100 on running another project, but for simplicity, I'm going to focus on this one project. Here is the error I'm getting:
E/configParser - Error code: 105
E/configParser - Error message: failed loading configuration file conf.js
E/configParser - C:\Workspace\ProtractorCalc\conf.js:6
I know this has to be something with my webdriver/selenium, but I don't know enough to debug it properly. I run webdriver-manager update and webdriver-manager start before running the conf.js file and when I do webdriver-manager start, it looks like it's running, but also prompts me to end webdriver-manager start in order to give me control of the command line:
I/e the last line when running it is "Selenium Server is up and running"
but then to be able to type protractor conf.js, I have to enter ctrl+c and I get this back:
Attempting to shut down selenium nicely
Staying alive until the Selenium Standalone process exists
events.js:163 throw er; //Unhandled 'error' event
Error: read ECONNRESET
at exports._errnoException (util.js:1050:11)
at TCP.onread(net.js.581:26)
Terminate batch job (Y/N)?
So is webdriver-manager kicking me out and that's why protractor's conf.js file is failing?
webdriver-manager start starts the webdriver, as you say, and it is running properly. However, when you press ctrl+c to "regain control", you're actually killing the process. It's at that point that webdriver stops, and that's why protractor won't run.
The easiest way to do this correctly is to open two command windows: run webdriver-manager start in the first one and protractor conf in the second.
First the logging refers to the conf.js file. When I look at your file I guess the problem is that you don't provide a capability to run the tests against. In other words, against what browser do you want to run your tests?
Here is an example project which has an example conf.js-file. If you change your file to this I think it should work without a problem
// An example configuration file.
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},
// Framework to use. Jasmine is recommended.
framework: 'jasmine',
// Spec patterns are relative to the current working directory when
// protractor is called.
specs: ['spec.js'],
// Options to be passed to Jasmine.
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
}
};

Using Protractor's 'browser' object with PhantomJS

I am trying to run a test suite written in Protractor headlessly (using PhantomJS), but when I run the command 'phantomjs testSuiteFile.js' I get the error: ReferenceError: Can't find variable: browser. The browser variable is important in all of my tests so is there a way to allow phantomjs to find & use the browser object?
I also tried configuring my protractor config file to use phantomjs, I started selenium webdriver for phantomjs using the command recommended in the docs: phantomjs --webdriver=9134 and ran the config file with protractor protractor.conf.js. The config file is set to only run myTest.js, and I now get the error E/launcher - Error: Error: Cannot find module 'webpage'. But myTest.js works when I run phantomjs myTest.js
myTest.js:
var WebPage = require('webpage');
page = WebPage.create();
page.open('http://google.com');
page.onLoadFinished = function() {
page.render('googleScreenShot' + '.png');
phantom.exit();}
This is not how Protractor and PhantomJS work together. You need to execute protractor command from the command-line to have browser and other Protractor global variables initialized.

Codeception acceptance test not working with firefox

I am trying to run an acceptance test on firefox using selenium 3.0.1. I am also using wp-browser WPWebDriver module. My acceptance-suit.yml looks like this.
class_name: AcceptanceTester
modules:
enabled:
- \Helper\Acceptance
- WPWebDriver
config:
WPWebDriver:
url: 'url'
adminUsername: 'juhi.saxena#gmail.com'
adminPassword: '123456'
adminPath: '/wp-admin'
browser: firefox
webdriver.gecko.driver: 'bin/geckodriver.exe'
On runnuning this wpcept run acceptance testsCest.php I get [Facebook\WebDriver\Exception\UnknownServerException] The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded fro
m https://github.com/mozilla/geckodriver/releases
Try removing the '.exe'.
I'm running successfully with webdriver.gecko.driver: '/usr/local/bin/geckodriver'.
Also, have you placed the geckodriver.exe in the path?
I solved a similar problem with Codeception and Firefox by adding path='' to the WebDriver config section.

acceptance testing with selenium and codeception, browser shows blank page

I'm using codeception with Yii2 and my configuration is as follows:
class_name: AcceptanceTester
modules:
enabled:
- WebDriver:
url: 'http://ucms.ac.ir/admin/index-test.php/'
browser: chrome
- tests\codeception\common\_support\FixtureHelper
- Yii2
config:
Yii2:
configFile: '../config/backend/acceptance.php'
tests run, and they finish successfully, but nothing appears on the new browser tab opened by selenium. I've seen some tutorials and in those tutorials browser actually shows process of testing. also, when an error occurs and a screenshot is taken by codeception for later reference, it's only a white empty page too.
I'm on ubuntu 14.10, selenium 2.47.1 and chrome 45. it also happens when I use firefox instead of chrome.
I asked same question in codeception's github repo and here's the answer:
Don't use Yii2 and WebDriver in the same suite.
My fault, this is corrected configs:
class_name: AcceptanceTester
modules:
enabled:
- WebDriver:
url: 'http://ucms.ac.ir/admin/index-test.php/'
browser: chrome
- tests\codeception\common\_support\FixtureHelper

Test browser code with Intern through Grunt and Phantomjs

I have been playing with Intern and made my tests work in the browser. To better integrate with my current workflow I'm trying to run my tests through grunt with phantomjs. However all my attempts have failed. I've been looking at this question as a reference Intern WebDriver and PhantomJS but can't figure out all of the steps to make it work.
First of all: Is it even possible to run the tests through grunt and phantomjs?
A little bit of info:
I don't want/can't connect to Sauce Labs or a Selenium testing environment.
I want to test browser code while having jQuery as a shimmed dependency
I have Grunt 0.4.1 and phantomjs 1.9.1 installed
I'm not testing any ajax request (as the linked question is having problem with)
I'm not familiar with neither Selenium nor Sauce Lab
If it is possible to test through grunt and phanomjs, how would I go about doing it?
I guess that I have to start the GhostDriver
phantomjs --webdriver=8910
But then what are the important pieces of info in the Intern config to make this work?
define({
proxyPort: 9000,
proxyUrl: 'http://localhost:9000/',
environments: [
{
browserName: 'phantom',
version: '1.9.0',
platform: 'Linux'
}
],
webdriver: {
host: 'localhost',
port: 8910
},
maxConcurrency: 3,
useSauceConnect: false,
// ...
});
How does the environments browserName map to phantomjs? I've tried the browserNames 'phantom' as well as 'phanomjs' with different versions and platforms (running Mac 10.7)
My Gruntfile section for intern looks like:
intern: {
phantom: {
options: {
config: 'tests/intern',
reporters: ['webdriver']
}
}
}
Running this setup without any test-suite that includes browser code outputs
'ReferenceError: document is not defined' in 'node_modules/intern/lib/reporters/webdriver.js:41:19'
Adding browser tests gives 'ReferenceError: window is not defined' in 'src/vendor/jquery/jquery-1.9.1.js:9597:5'
Running it through node gives the same 'window is not defined' error.
node node_modules/intern/client.js config=tests/intern
What am I doing wrong/missing here?
There are two problems with your Gruntfile configuration:
The default run type for the Grunt task is 'client', which means it runs the Node.js client by default, not the test runner. You need to set runType: 'runner' in your Gruntfile options to run tests against your specified environments.
The webdriver reporter is for use in a browser client only and is specified automatically by the test runner when it is needed. You should typically never use it directly. The reporter you specify in the Gruntfile should be the one you want the test runner to use; the console default is usually appropriate.
These two things in combination mean that you’ve configured Intern to try to use a reporter that only works in a browser in conjunction with the test runner inside the Node.js client, hence the error. Once corrected, the remaining configuration should work properly to run on PhantomJS, assuming it is already running on localhost at port 8910.