Open karthik22061993 opened 4 years ago
Same problem here!
You can try to add chromeDriverArgs: ['remote-debugging-port=9222']
as AppConstructorOptions
.
@XRenSiu I Faced the same issue where it was opening mutiple windows after adding chromedriverargs I see only one window but end up getting Cannot call non W3C standard command while in W3C mode.Not sure where I can make this w3c mode to false
you can add webdriverOptions
, but I don't think this is the right approach.
@Rajesh2015, I think you're seeing the trouble that I am. Attempting to add some webdriverOptions means that you have to take responsibility for all the config options. @XRenSiu this is the trouble for you too, because the path goes to chrome instead of electron.
If you drill into your npm folder node_modules\spectron\lib\application.js around line 203...
const options = {
hostname: self.host,
port: self.port,
waitforTimeout: self.waitTimeout,
connectionRetryCount: self.connectionRetryCount,
connectionRetryTimeout: self.connectionRetryTimeout,
logLevel: 'silent',
capabilities: {
'goog:chromeOptions': {
binary: launcherPath,
args: args,
debuggerAddress: self.debuggerAddress,
windowTypes: ['app', 'webview']
}
},
logOutput: DevNull()
};
if (self.webdriverLogPath) {
options.outputDir = self.webdriverLogPath;
options.logLevel = 'trace';
}
Object.assign(options, self.webdriverOptions);
Here, spectron is preparing the options that it will send use to create webdriver. Spectron will use your webDriverOptions if you pass one when you create a new Spectron Application. So if you want to add in a w3c: false you have to replicate a lot of code. As a test you can tweak the code here after the Object.assign and add options.capabilities['goog:chromeOptions'].w3c = false;
This does get my electron11 app off the ground. Then it promptly has some trouble in Application.prototype.start around line 59. The call of setTimeouts results in errors about a mismatch of the function sig. Commenting out this section worked for me:
// .then(function () {
// return self.client.setTimeouts(
// self.waitTimeout,
// self.waitTimeout,
// self.waitTimeout
// );
// })
I'm curious if this also works for you. I'm about to try reproing this in a test environment.
just to follow up, after breaking this down, it seems that I don't have trouble until protractor gets involved. A clean repo with just spectron seems oka.
My electron app works as expected but it keeps on opening new windows when I run spectron test that tests for number of windows opened.
Electron version - v8.0.2 , "spectron": "^10.0.1" . I am not sure how to check exact version of spectron. I am just running a small demo, below I will give code snippet
Note: I am running the spectron test pointing to .exe file generated by electron-packager.
Does Anyone have an idea what is the issue if possible how to solve it?
main.js
index.js
test.js
package.json
Versions Installed npm ls --depth=0 demoelectronapp@1.0.0 C:\demoCLS\demoElectronApp +-- assert@2.0.0 +-- electron@8.2.2 +-- electron-packager@14.2.1 +-- mocha@7.1.1 +-- path@0.12.7 `-- spectron@10.0.1 –