john-doherty / selenium-cucumber-js

Browser automation framework written in pure JavaScript using official selenium-webdriver and cucumber-js
ISC License
120 stars 89 forks source link

selenium-cucumber-js.json configuration file is not being merged #35

Open Vitor-Carvalho opened 7 years ago

Vitor-Carvalho commented 7 years ago

Hi, I'm using a selenium-cucumber-js.json file at the root of my project with these options: { "steps": "./features/step-definitions", "pageObjects": "./page-objects", "sharedObjects": "./shared-objects", "reports": "./reports", "browser": "firefox", "timeout": 100000 } but when I run the tests (>node ./node_modules/selenium-cucumber-js/index.js), the options used are the ones on index file: { "steps": "./step-definitions", "pageObjects": "./page-objects", "sharedObjects": "./shared-objects", "reports": "./reports", "browser": "chrome", "timeout": 10000 }

Am I doing anything wrong? Or there is a problem on index.js when reading the file?

var configFileName = path.resolve(process.cwd(), 'selenium-cucumber-js.json'); if (fs.isFileSync(configFileName)) { config = Object.assign(config, require(configFileName)); }

Thanks, Vitor Carvalho

leggebroten commented 7 years ago

Hi Vitor, I'm using this option at the moment so I know it works. Have you put a breakpoint in to see what configFileName points to?

Temi89 commented 7 years ago

Hi lee , is there a way to update the confit file to specify custom webdriver configurations and sessions like desired capabilities and browser config using selenium builder api ? So basically something like this ::

const driver = new webdriver.Builder() // The "9515" is the port opened by chrome driver. .usingServer('http://localhost:9515') .withCapabilities({ chromeOptions: { // Here is the path to your Electron binary. binary: '/Path-to-Your-App.app/Contents/MacOS/Electron'

Ref link :::https://github.com/electron/electron/blob/master/docs/tutorial/using-selenium-and-webdriver.md

leggebroten commented 7 years ago

That's why I use the the --browserName to load a file that has exactly the configuration I want. (It's essentially a configuration file for the driver)

Temi89 commented 7 years ago

Thanks lee do you have a working example I can work and add spectrom configurations ?

leggebroten commented 7 years ago

In world::getDriverInstance the default case uses browserName to load a particular driver FILE. These files are similar to this one where I create a Headless Chrome driver: (It's not a complete working example as I've left off the wrapping loader

const selenium = require('selenium-webdriver'); const chromedriver = require('chromedriver');

const createSession = function () { const driver = new selenium.Builder().withCapabilities({ browserName: 'chrome', chromeOptions: { args: [ 'headless', // Use --disable-gpu to avoid an error from a missing Mesa // library, as per // https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md 'disable-gpu' ] }, javascriptEnabled: true, acceptSslCerts: true, path: chromedriver.path }).build();

return driver.manage().window().maximize() .then(function() { return driver; }); };

module.exports = { description: 'Headless Chrome', createSession: createSession };

Temi89 commented 7 years ago

Hi lee Found a work around but then a new driver session is created as opposed to one for my scenarios.Is the frame work capable of using the builder api ?

Please see below steps .

Created a config directory inside step definitions and added a before feature hooks to set global driver to my config :

module.exports = function () {

// add a before feature hook / eslint new-cap:0/ this.BeforeFeature((feature) => {

global.driver = new selenium.Builder()
// The "9515" is the port opened by chrome driver.
    .usingServer('http://localhost:9515')
    .withCapabilities({
        chromeOptions: {
            // Here is the path to your Electron binary.
            // binary: '/Path-to-Your-App.app/Contents/MacOS/Electron'
        }
    })
    .forBrowser('electron')
    .build();

}); };

Temi89 commented 7 years ago

Might be a case of following the example in chrome.js in the runtime directory and adding a case statement with spectron configuration and running the test with environment variable . Hopefully that should solve it .. I'll update you

john-doherty commented 6 years ago

Is this still an issue?

superhero1 commented 6 years ago

Headless I cannot get the example (_node ./nodemodules/selenium-cucumber-js/index.js) to work:

TypeError: Wait condition must be a promise-like object, function, or a Condition object at thenableWebDriverProxy.wait (\cucumber-js\node_modules\selenium-webdriver\lib\webdriver.js:809:13) at \cucumber-js\node_modules\selenium-cucumber-js\runtime\helpers.js:20:27 at <anonymous> at process._tickCallback (internal/process/next_tick.js:188:7)

james-tru commented 4 years ago

I get exactly the same as @superhero1 - did anyone find a cause? If I edit chromeDriver.js in the node_modules to add a 'headless' arg, that works fine (until I do anything with npm, of course). But no version of customDriver.js that looks like chromeDriver or the version above works. I just get the wait/promise problem above

superhero1 commented 4 years ago

Seems no one cares. Cannot remember in which context I used this. I just moved on.