{"library":"spectron","title":"Spectron","type":"library","description":"Spectron is an end-to-end testing framework designed specifically for Electron applications. It leverages ChromeDriver and WebdriverIO to provide an API for interacting with Electron apps, allowing developers to simulate user interactions and assert application state. The current stable version is 19.0.0. However, Spectron was officially deprecated on February 1, 2022, and is no longer actively maintained. Its primary differentiator was its tight integration with Electron, allowing control over both the Electron main process and renderer processes through WebdriverIO. Due to its deprecated status, new projects are advised to seek alternative testing solutions for Electron.","language":"javascript","status":"deprecated","last_verified":"Tue Apr 21","install":{"commands":["npm install spectron"],"cli":null},"imports":["import { Application } from 'spectron'","const { Application } = require('spectron')","import electronPath from 'electron'"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":"https://www.electronjs.org/spectron","github":"https://github.com/electron/spectron","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/spectron","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import { Application } from 'spectron'\nimport assert from 'assert'\nimport electronPath from 'electron' // Require Electron from the binaries included in node_modules.\nimport path from 'path'\n\ndescribe('Application launch', function () {\n  this.timeout(10000)\n\n  beforeEach(async function () {\n    this.app = new Application({\n      path: electronPath,\n      args: [path.join(__dirname, '..')]\n    })\n    await this.app.start()\n  })\n\n  afterEach(async function () {\n    if (this.app && this.app.isRunning()) {\n      await this.app.stop()\n    }\n  })\n\n  it('shows an initial window', async function () {\n    // Example assertion: check if the main window is visible\n    const isVisible = await this.app.browserWindow.isVisible()\n    assert.strictEqual(isVisible, true, 'Initial window should be visible')\n\n    // Example assertion: check window title\n    const title = await this.app.client.getTitle()\n    assert.strictEqual(title, 'Your Electron App Title', 'Window title should match')\n  })\n\n  it('should have a button and click it', async function() {\n    const button = await this.app.client.$('#my-button')\n    await button.click()\n    const text = await this.app.client.$('#status-text').getText()\n    assert.strictEqual(text, 'Button clicked!', 'Status text should update after click')\n  })\n})","lang":"javascript","description":"This quickstart demonstrates how to set up Spectron with Mocha to launch an Electron application, perform basic assertions on window visibility and title, and simulate user interaction like clicking a button.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}