Comments (6)
ok so this works (using code from spectron tests)
start-test-2.js
require('fluentnode')
var helpers = require('./global-setup')
electron_Prebuild = require('electron-prebuilt')
appPath = __dirname.path_Combine('../../electron-apps/web-view')
var Application = require('spectron').Application
var assert = require('assert')
describe('application launch 3', function () {
this.timeout(10000)
var app = null
var path = [appPath]
beforeEach(function (done) {
helpers.setupTimeout(this)
return helpers.startApplication({
args: path
}).then(function (startedApp) { app = startedApp; done() })
})
afterEach(function () {
return helpers.stopApplication(app)
})
afterEach(function () {
//if (this.app && this.app.isRunning()) {
// return this.app.stop()
//}
})
it('shows an initial window abc', function () {
app.isRunning().assert_Is_True()
return app.client.getWindowCount().then(function (count) {
assert.equal(count, 2)
})
})
})
global-setup
var Application = require('spectron').Application
var assert = require('assert')
var chai = require('chai')
var chaiAsPromised = require('chai-as-promised')
var path = require('path')
global.before(function () {
chai.should()
chai.use(chaiAsPromised)
})
exports.getElectronPath = function () {
var electronPath = path.join(__dirname, '../../../', 'node_modules', '.bin', 'electron')
return electronPath
}
exports.setupTimeout = function (test) {
if (process.env.CI) {
test.timeout(30000)
} else {
test.timeout(10000)
}
}
exports.startApplication = function (options) {
options.path = exports.getElectronPath()
if (process.env.CI) options.startTimeout = 30000
var app = new Application(options)
return app.start().then(function () {
assert.equal(app.isRunning(), true)
chaiAsPromised.transferPromiseness = app.transferPromiseness
return app
})
}
exports.stopApplication = function (app) {
if (!app || !app.isRunning()) return
return app.stop().then(function () {
assert.equal(app.isRunning(), false)
})
}
from spectron.
Here is the above code in coffee-script
start-test.coffee
require 'fluentnode'
helpers = require('./global-setup')
appPath = __dirname.path_Combine('../../electron-apps/web-view')
assert = require('assert')
describe 'application launch 4', ->
@timeout 10000
app = null
path = [ appPath ]
beforeEach (done) ->
helpers.setupTimeout this
helpers.startApplication(args: path)
.then (startedApp) ->
app = startedApp
done()
afterEach ->
helpers.stopApplication app
it 'shows an initial window abc', ->
app.isRunning().assert_Is_True()
app.client.getWindowCount()
.then (count) ->
assert.equal count, 2
global-setup.coffee
Application = require('spectron').Application
assert = require('assert')
chai = require('chai')
chaiAsPromised = require('chai-as-promised')
path = require('path')
global.before ->
chai.should()
chai.use chaiAsPromised
exports.getElectronPath = ->
electronPath = path.join(__dirname, '../../../', 'node_modules', '.bin', 'electron')
electronPath
exports.setupTimeout = (test) ->
if process.env.CI
test.timeout 30000
else
test.timeout 10000
exports.startApplication = (options) ->
options.path = exports.getElectronPath()
if process.env.CI
options.startTimeout = 30000
app = new Application(options)
app.start()
.then ->
assert.equal app.isRunning(), true
chaiAsPromised.transferPromiseness = app.transferPromiseness
return app
exports.stopApplication = (app) ->
if !app or !app.isRunning()
return
app.stop().then ->
assert.equal app.isRunning(), false`
from spectron.
For reference the code that replicates this issue ('self.client.init if not a function') is at https://github.com/DinisCruz/BSIMM-Graphs-QA/tree/d416ec863afdc2a53550a5d8a2ea9f5184c3a57e
from spectron.
And the travis execution is at https://travis-ci.org/DinisCruz/BSIMM-Graphs-QA
from spectron.
ok found the prob and solved it
the issue was with an prototype method called keys
(see o2platform/fluentnode#95)
Here is the version with the code that works
https://github.com/DinisCruz/BSIMM-Graphs-QA/tree/5f36e9ecf3333caf745e820ff617a04b72689ead
here is the test failing in travis on the final assertion (which means that everything worked as expected)
from spectron.
For reference here is a final refactored version of the sample code shown above
Global_Setup
require 'fluentnode'
Application = require('spectron').Application
class Global_Setup
constructor: (options)->
@.options = options || {}
@.app = null
@.root_Path = wallaby?.localProjectDir || __dirname.path_Combine '../'
@.app_Path = __dirname.path_Combine '../electron-apps/web-view'
@.options.path = @.getElectronPath()
@.options.args = [@.app_Path]
getElectronPath: =>
@.root_Path.path_Combine 'node_modules/.bin/electron'
isRunning: =>
@.app?.isRunning() || false
startApplication: () =>
@.app = new Application(@.options)
@.app.start()
stopApplication: () =>
if !@.app or !@.app.isRunning()
return
@.app.stop()
module.exports = Global_Setup
start-test
assert = require('assert')
Global_Setup = require('../../src/global-setup')
describe 'Global_Setup', ->
it 'constructor', ->
using new Global_Setup(), ->
assert_Is_Null @.app
it 'isRunning', ->
using new Global_Setup(), ->
@.isRunning().assert_Is_False()
it 'getElectronPath', ->
using new Global_Setup(), ->
@.getElectronPath().assert_File_Exists()
it 'appPath', ->
using new Global_Setup(), ->
@.app_Path.assert_Folder_Exists()
it 'start, stop', ->
@.timeout 5000
using new Global_Setup(), ->
console.log 'after setup'
@.startApplication().then =>
console.log 'after start Application'
@.isRunning().assert_Is_True()
@.app.client.getTitle().then (title)=>
console.log title
title.assert_Is 'Electron App - with WebView'
@.stopApplication().then =>
console.log 'after stop'
@.isRunning().assert_Is_False()
it 'stop', ->
@.timeout 4000
using new Global_Setup(), ->
@.startApplication().then =>
@.stopApplication().then =>
@.stopApplication()
describe 'test browserwindow and client', ->
global_Setup = null
@.timeout 10000
beforeEach () ->
global_Setup = new Global_Setup()
global_Setup.startApplication()
afterEach ()->
global_Setup.stopApplication()
it 'gets window count', ()->
global_Setup.isRunning().assert_Is_True()
global_Setup.app.client.getWindowCount()
.then (count) ->
count.assert_Is 2
it 'show an initial window', ()->
using global_Setup.app.browserWindow, ->
@.setBackgroundColor('#001122')
@.setPosition(400,10)
@.setSize(600,400)
@.showInactive()
return
it 'check title', ()->
app.client.windowByIndex(1)
.then -> app.client.getTitle()
.then (title)->
title.assert_Is 'Google'
it 'check HTML', ()->
app.client.windowByIndex(1)
.then -> app.client.getHTML('*')
.then (text)->
text[0].assert_Contains 'Google'
from spectron.
Related Issues (20)
- Element Wasn't Found After Upgrading my Spectron Version to 15 & Electron to 13 HOT 1
- Please release Spectron 16, compatible with electron 14 HOT 8
- api http mocking
- Module name "process" has not been loaded yet for context:
- This version of ChromeDriver only supports Chrome version 91 HOT 1
- failing to successfully launch Spectron headless in Docker on Jenkins
- Spectron test table contents
- export interface SpectronClient extends WebdriverIO.BrowserObject HOT 1
- test suddenly failing on Github Action Windows
- Support Electron 15
- is it possible to work with selenium grid using the image
- ChromeDriver / Chrome version mismatch HOT 2
- app.stop() not work, electron process stay in the background after the mocha test program exits HOT 2
- Rewrite Discussion HOT 12
- Spectron: Deprecation Announcement HOT 10
- This version of ChromeDriver only supports Chrome version HOT 1
- TypeError: waitUntilWindowLoaded Cannot read property 'isLoading' of undefined HOT 5
- --
- unknown error: call function result missing int 'status' HOT 6
- มานะแมน (2024) ดู-หนัง เรื่องเต็ม - ดู มานะแมนเรื่องเต็ม Mana Man หนังไทยย่อยฟรี
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spectron.