Open Amy-Lynn opened 5 years ago
I was looking for more information about starting spectron within a protractor process. It seems that you did that with some success. The config for protractor seems to want the selenium session id at launch, I saw that there is a beforeLaunch hook that I was thinking might be a place to boot spectron and get the seleniumSessionId setup as well as stuffing the spectron object into browser for later use. Did you try that approach?
here's where I ended up, seems to work. I expect that I could add app to the the 'params' object and that would be available in the tests.
import {Config} from 'protractor';
import { Application } from 'spectron';
let app:Application;
export let config: Config = {
framework: 'jasmine',
specs:['something_spec.js'],
seleniumAddress:'http://localhost:9515/wd/hub',
beforeLaunch: async()=>{
app = new Application({
path: 'PATH_TO_ELECTRON_APP.exe',
webdriverLogPath:'c:\\temp\\webdriverlog.log'
})
await app.start();
let s:any = await app.client.session();
config.seleniumSessionId = s.sessionId;
},
afterLaunch: async (exitCode: number) =>{
return app.stop();
}
};
Feature Request
In
protractor.conf.js
, allow the export to be either a config object (current behavior) or a promise that resolves to the config object.Spectron
to launch the app. I can start the app and get a selenium session id, but that's asynchronous. While you can start protractor in a new process and pass in the sessionId via CLI, then I don't have access to theSpectron
object (so I lose electron-specific functionality). This would also address #4749Happy to try a PR.