Socket
Socket
Sign inDemoInstall

spectron

Package Overview
Dependencies
Maintainers
5
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spectron - npm Package Compare versions

Comparing version 8.0.0 to 9.0.0

27

lib/api.js

@@ -316,15 +316,12 @@ var apiCache = {}

app.client.addCommand('browserWindow.capturePage', function (rect) {
return this.executeAsync(function (rect, requireName, done) {
return this.executeAsync(async function (rect, requireName, done) {
var args = []
if (rect != null) args.push(rect)
args.push(function (image) {
if (image != null) {
done(image.toPNG().toString('base64'))
} else {
done(image)
}
})
var browserWindow = window[requireName]('electron').remote.getCurrentWindow()
browserWindow.capturePage.apply(browserWindow, args)
const image = await browserWindow.capturePage.apply(browserWindow, args)
if (image != null) {
done(image.toPNG().toString('base64'))
} else {
done(image)
}
}, rect, self.requireName).then(getResponseValue).then(function (image) {

@@ -374,5 +371,6 @@ return Buffer.from(image, 'base64')

app.client.addCommand('webContents.savePage', function (fullPath, saveType) {
return this.executeAsync(function (fullPath, saveType, requireName, done) {
return this.executeAsync(async function (fullPath, saveType, requireName, done) {
var webContents = window[requireName]('electron').remote.getCurrentWebContents()
webContents.savePage(fullPath, saveType, done)
await webContents.savePage(fullPath, saveType)
done()
}, fullPath, saveType, self.requireName).then(getResponseValue).then(function (rawError) {

@@ -397,5 +395,6 @@ if (rawError) {

app.client.addCommand('webContents.executeJavaScript', function (code, useGesture) {
return this.executeAsync(function (code, useGesture, requireName, done) {
return this.executeAsync(async function (code, useGesture, requireName, done) {
const webContents = window[requireName]('electron').remote.getCurrentWebContents()
webContents.executeJavaScript(code, useGesture, done)
const result = await webContents.executeJavaScript(code, useGesture)
done(result)
}, code, useGesture, self.requireName).then(getResponseValue)

@@ -402,0 +401,0 @@ })

@@ -228,2 +228,36 @@ var Accessibility = require('./accessibility')

/**
* Utility from webdriverio v5
* https://github.com/webdriverio/webdriverio/blob/v5.9.4/packages/webdriverio/src/commands/browser/switchWindow.js
*/
this.client.addCommand('switchWindow', async function (urlOrTitleToMatch) {
if (typeof urlOrTitleToMatch !== 'string' && !(urlOrTitleToMatch instanceof RegExp)) {
throw new TypeError('Invalid parameter urlOrTitleToMatch: expected a string or a RegExp')
}
const tabs = await this.windowHandles().then(getResponseValue)
for (const tab of tabs) {
await this.window(tab)
/**
* check if url matches
*/
const url = await this.getUrl()
if (url.match(urlOrTitleToMatch)) {
return tab
}
/**
* check title
*/
const title = await this.getTitle()
if (title.match(urlOrTitleToMatch)) {
return tab
}
}
throw new Error(`No window found with title or url matching "${urlOrTitleToMatch}"`)
})
this.client.addCommand('waitUntilWindowLoaded', function (timeout) {

@@ -230,0 +264,0 @@ return this.waitUntil(function () {

@@ -13,2 +13,8 @@ // Type definitions for spectron v3.6.0

/**
* Focus a window using its title or URL.
* <webview> tags can also be focused as a separate window.
*/
switchWindow(urlOrTitleToMatch:string):Promise<void>;
/**
* Wait until the window is no longer loading.

@@ -15,0 +21,0 @@ * Takes an optional timeout in milliseconds that defaults to 5000.

{
"name": "spectron",
"version": "8.0.0",
"version": "9.0.0",
"description": "Easily test your Electron apps using ChromeDriver and WebdriverIO.",

@@ -28,3 +28,3 @@ "main": "index.js",

"dev-null": "^0.1.1",
"electron-chromedriver": "^6.0.0",
"electron-chromedriver": "^7.0.0",
"request": "^2.87.0",

@@ -40,3 +40,3 @@ "split": "^1.0.0",

"check-for-leaks": "^1.0.2",
"electron": "^6.0.0",
"electron": "^7.0.0",
"husky": "^3.0.0",

@@ -43,0 +43,0 @@ "mocha": "^6.1.4",

# <img src="https://cloud.githubusercontent.com/assets/378023/15063284/cf544f2c-1383-11e6-9336-e13bd64b1694.png" width="60px" align="center" alt="Spectron icon"> Spectron
[![Linux Build Status](https://travis-ci.org/electron/spectron.svg?branch=master)](https://travis-ci.org/electron/spectron)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/iv8xd919q6b44pap/branch/master?svg=true)](https://ci.appveyor.com/project/kevinsawicki/spectron/branch/master)
<br>
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)
[![dependencies](https://img.shields.io/david/electron/spectron.svg)](https://david-dm.org/electron/spectron)
<br>
[![license:mit](https://img.shields.io/badge/license-mit-blue.svg)](https://opensource.org/licenses/MIT)
[![npm:](https://img.shields.io/npm/v/spectron.svg)](https://www.npmjs.com/package/spectron)
[![downloads](https://img.shields.io/npm/dm/spectron.svg)](https://www.npmjs.com/package/spectron)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/iv8xd919q6b44pap/branch/master?svg=true)](https://ci.appveyor.com/project/kevinsawicki/spectron/branch/master) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)
[![dependencies](https://img.shields.io/david/electron/spectron.svg)](https://david-dm.org/electron/spectron) [![license:mit](https://img.shields.io/badge/license-mit-blue.svg)](https://opensource.org/licenses/MIT) [![npm:](https://img.shields.io/npm/v/spectron.svg)](https://www.npmjs.com/package/spectron) [![downloads](https://img.shields.io/npm/dm/spectron.svg)](https://www.npmjs.com/package/spectron)

@@ -37,2 +30,3 @@ Easily test your [Electron](http://electron.atom.io) apps using

| `^6.0.0` | `^8.0.0` |
| `^7.0.0` | `^9.0.0` |

@@ -66,3 +60,3 @@ Learn more from [this presentation](https://speakerdeck.com/kevinsawicki/testing-your-electron-apps-with-chromedriver).

Then simply include the following your first `spec.js`.
Then simply include the following in your first `spec.js`.

@@ -470,2 +464,14 @@ ```js

#### client.switchWindow(urlOrTitleToMatch)
Focus a window using its URL or title.
```js
// switch via url match
app.client.switchWindow('google.com')
// switch via title match
app.client.switchWindow('Next-gen WebDriver test framework')
```
### Accessibility Testing

@@ -472,0 +478,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc