JavaScript SDK
The kogiQA JavaScript SDK provides a powerful and intuitive way to automate browser testing. With support for multiple browsers and advanced features like email testing, it makes end-to-end testing simple and reliable.
Installation
To get started, install the kogiQA JavaScript SDK using npm:
npm install kogi
Tip: Make sure you have Node.js installed on your system. If you don't have it installed yet, follow our setup guide to get started.
Authentication
To use kogiQA, you need an API access token from your account. You can find or generate this token in the 'Access' settings in the kogi Desktop client.
Quick Start
Here's a simple example to get you started with the kogiQA JavaScript SDK:
import {Browser} from "kogi";
(async () => {
const browser = await Browser.start("! YOUR_ACCESS_TOKEN !", "chrome", "My Test Session");
await browser.navigate("https://example.com");
await browser.click("Login");
await browser.type("Username", "john_doe");
await browser.type("Password", "secret123");
await browser.click("Submit");
await browser.hasText("Welcome");
await browser.close();
})();
Supported Browsers
The kogiQA JavaScript SDK supports multiple browsers for testing:
| Browser | Supported |
|---|---|
| Local | ✅ |
| Chrome | ✅ |
| Firefox | ✅ |
| Safari | ✅ |
The default browser is chrome.
API Reference
For detailed information about all available methods and their parameters, please see our API Reference page.
Positioning Guide
Kogi supports a wide variety of positioning formats for elements:
English
"top left","top center","top right""center left","center","center right""bottom left","bottom center","bottom right"
German
"oben links","oben mitte","oben rechts""mitte links","mitte","mitte rechts""unten links","unten mitte","unten rechts"
Spanish
"arriba izquierda","arriba centro","arriba derecha""centro izquierda","centro","centro derecha""abajo izquierda","abajo centro","abajo derecha"
French
"haut gauche","haut centre","haut droite""centre gauche","centre","centre droite""bas gauche","bas centre","bas droite"
Advanced Usage
Running Custom Steps
You can run any custom step using runStep():
await browser.runStep({
type: "customAction",
data: {foo: "bar"}
});
Exposing Local Ports
If you're running tests against a local server, you can expose specific ports from your local machine to the cloud test runner using exposePorts().
exposePorts(ports)
Exposes the specified ports from your local device to the cloud test runner. This is especially useful when testing locally hosted applications during remote browser sessions.
// Expose common development ports
await browser.exposePorts([3000, 8080, 443]);
Overwriting Session Timeout
setTimeout(newTimeout)
Overwrite the default remote session timeout with a custom value.
await browser.setTimeout(5*60); // in seconds