-
-
Notifications
You must be signed in to change notification settings - Fork 16
docs: add more examples #511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { defineConfig } from '@wdio/config' | ||
|
||
export const config = defineConfig({ | ||
// ... | ||
reporters: [ | ||
'dot', | ||
['junit', { | ||
outputDir: './testresults/', | ||
outputFileFormat: function (options) { | ||
return `results-${options.cid}.xml`; | ||
} | ||
}] | ||
], | ||
// ... | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { defineConfig } from '@wdio/config' | ||
|
||
export const config = defineConfig({ | ||
// ... | ||
reporters: [ | ||
'dot', | ||
['junit', { | ||
outputDir: './testresults/' | ||
}] | ||
], | ||
// ... | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { defineConfig } from '@wdio/config' | ||
|
||
export const config = defineConfig({ | ||
// ... | ||
capabilities: { | ||
platformName: 'iOS', | ||
app: 'net.company.SafariLauncher', | ||
udid: '123123123123abc', | ||
deviceName: 'iPhone', | ||
// ... | ||
} | ||
// ... | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { defineConfig } from '@wdio/config' | ||
|
||
export const config = defineConfig({ | ||
//... | ||
user: '<browserstack_username>' || process.env.BROWSERSTACK_USERNAME, | ||
key: '<browserstack_access_key>' || process.env.BROWSERSTACK_ACCESS_KEY, | ||
commonCapabilities: { | ||
'bstack:options': { | ||
projectName: "Your static project name goes here", | ||
buildName: "Your static build/job name goes here" | ||
} | ||
}, | ||
services: [ | ||
['browserstack', { | ||
accessibility: true, | ||
// Optional configuration options | ||
accessibilityOptions: { | ||
'wcagVersion': 'wcag21a', | ||
'includeIssueType': { | ||
'bestPractice': false, | ||
'needsReview': true | ||
}, | ||
'includeTagsInTestingScope': ['Specify tags of test cases to be included'], | ||
'excludeTagsInTestingScope': ['Specify tags of test cases to be excluded'] | ||
}, | ||
}] | ||
], | ||
//... | ||
}); |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,11 @@ | ||||||||
import { defineConfig } from '@wdio/config' | ||||||||
|
||||||||
export const config = defineConfig({ | ||||||||
// ... | ||||||||
capabilities: [{ | ||||||||
browserName: 'chrome', | ||||||||
'custom:caps': { | ||||||||
// custom configurations | ||||||||
} | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
For consistency |
||||||||
}] | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
For consistency |
||||||||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { defineConfig } from '@wdio/config' | ||
|
||
export const config = defineConfig({ | ||
// ... | ||
}) | ||
|
||
if (process.env.CI) { | ||
config.user = process.env.SAUCE_USERNAME | ||
config.key = process.env.SAUCE_ACCESS_KEY | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,13 @@ | ||||||||||||||||||
import { defineConfig } from '@wdio/config' | ||||||||||||||||||
|
||||||||||||||||||
export const config = defineConfig({ | ||||||||||||||||||
hostname: "your_cloud_name.perfectomobile.com", | ||||||||||||||||||
path: "/nexperience/perfectomobile/wd/hub", | ||||||||||||||||||
port: 443, | ||||||||||||||||||
protocol: "https", | ||||||||||||||||||
// ... | ||||||||||||||||||
capabilities: [{ | ||||||||||||||||||
// ... | ||||||||||||||||||
securityToken: "your security token" | ||||||||||||||||||
}], | ||||||||||||||||||
}) | ||||||||||||||||||
Comment on lines
+11
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
For consistency |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,8 @@ | ||||||||||||||||||||||
import { defineConfig } from '@wdio/config' | ||||||||||||||||||||||
|
||||||||||||||||||||||
export const config = defineConfig({ | ||||||||||||||||||||||
runner: ['browser', { | ||||||||||||||||||||||
// network IP of the machine that runs the WebdriverIO process | ||||||||||||||||||||||
host: 'http://172.168.0.2' | ||||||||||||||||||||||
}] | ||||||||||||||||||||||
Comment on lines
+4
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
For consistency |
||||||||||||||||||||||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { defineConfig } from '@wdio/config' | ||
|
||
export const config = defineConfig({ | ||
// ... | ||
mochaOpts: { | ||
ui: 'tdd', | ||
// provide a setup script to run in the browser | ||
require: './__fixtures__/setup.js' | ||
}, | ||
// ... | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { defineConfig } from '@wdio/config' | ||
|
||
export const config = defineConfig({ | ||
runner: 'local', | ||
specs: [ | ||
'test/spec/**', | ||
['group/spec/**'] | ||
], | ||
maxInstances: 10, | ||
capabilities: [ | ||
{ | ||
browserName: 'chrome', | ||
}, | ||
{ | ||
browserName: 'firefox', | ||
} | ||
], | ||
logLevel: 'info', | ||
outputDir: './logs', | ||
baseUrl: 'http://localhost:8080', | ||
waitforTimeout: 30000, | ||
framework: 'mocha', | ||
reporters: [ | ||
'dot', | ||
'allure' | ||
], | ||
mochaOpts: { | ||
ui: 'bdd' | ||
}, | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Buffer } from 'buffer'; | ||
import { defineConfig } from '@wdio/config' | ||
|
||
// Read the username and password from environment variables | ||
const username = process.env.SELENIUM_GRID_USERNAME; | ||
const password = process.env.SELENIUM_GRID_PASSWORD; | ||
|
||
// Combine the username and password with a colon separator | ||
const credentials = `${username}:${password}`; | ||
// Encode the credentials using Base64 | ||
const encodedCredentials = Buffer.from(credentials).toString('base64'); | ||
|
||
export const config = defineConfig({ | ||
// ... | ||
headers: { | ||
Authorization: `Basic ${encodedCredentials}` | ||
} | ||
// ... | ||
}) |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,5 @@ | ||||||||||
import { defineConfig } from '@wdio/config' | ||||||||||
|
||||||||||
export const config = defineConfig({ | ||||||||||
resolveSnapshotPath: (testPath, snapExtension) => testPath + snapExtension, | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
For consistency |
||||||||||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { defineConfig } from '@wdio/config' | ||
|
||
export const config = defineConfig({ | ||
// ... | ||
reporter: ['custom'], | ||
// ... | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { defineConfig } from '@wdio/config' | ||
import CustomReporter from './reporter/my.custom.reporter' | ||
|
||
export const config = defineConfig({ | ||
// ... | ||
reporters: [ | ||
/** | ||
* use imported reporter class | ||
*/ | ||
[CustomReporter, { | ||
someOption: 'foobar' | ||
}], | ||
/** | ||
* use absolute path to reporter | ||
*/ | ||
['/path/to/reporter.js', { | ||
someOption: 'foobar' | ||
}] | ||
], | ||
// ... | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { defineConfig } from '@wdio/config' | ||
|
||
export const config = defineConfig({ | ||
// ... | ||
services: ['custom'], | ||
// ... | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { defineConfig } from '@wdio/config' | ||
import CustomService from './service/my.custom.service' | ||
|
||
export const config = defineConfig({ | ||
// ... | ||
services: [ | ||
/** | ||
* use imported service class | ||
*/ | ||
[CustomService, { | ||
someOption: true | ||
}], | ||
/** | ||
* use absolute path to service | ||
*/ | ||
['/path/to/service.js', { | ||
someOption: true | ||
}] | ||
], | ||
// ... | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { defineConfig } from '@wdio/config' | ||
|
||
const debug = process.env.DEBUG | ||
const defaultCapabilities = ... | ||
const defaultTimeoutInterval = ... | ||
const defaultSpecs = ... | ||
|
||
export const config = defineConfig({ | ||
// ... | ||
maxInstances: debug ? 1 : 100, | ||
capabilities: debug ? [{ browserName: 'chrome' }] : defaultCapabilities, | ||
execArgv: debug ? ['--inspect'] : [], | ||
jasmineOpts: { | ||
defaultTimeoutInterval: debug ? (24 * 60 * 60 * 1000) : defaultTimeoutInterval | ||
} | ||
// ... | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { defineConfig } from '@wdio/config' | ||
|
||
export const config = defineConfig({ | ||
// ... | ||
maxInstances: 1, | ||
specs: [ | ||
'**/myspec.spec.js' | ||
], | ||
capabilities: [{ | ||
browserName: 'firefox' | ||
}], | ||
// ... | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { defineConfig } from '@wdio/config' | ||
|
||
export const config = defineConfig({ | ||
// ... | ||
capabilities: [{ | ||
maxInstances: 1, | ||
browserName: 'chrome', | ||
'goog:chromeOptions': { | ||
args: [ | ||
'--no-sandbox', | ||
'--disable-infobars', | ||
'--headless', | ||
'--disable-gpu', | ||
'--window-size=1440,735' | ||
], | ||
} | ||
}], | ||
// ... | ||
}) |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,9 @@ | ||||||||
import { defineConfig } from '@wdio/config' | ||||||||
|
||||||||
export const config = defineConfig({ | ||||||||
// ... | ||||||||
services: [['electron', { | ||||||||
appEntryPoint: './path/to/bundled/electron/main.bundle.js', | ||||||||
appArgs: [/** ... */], | ||||||||
}]] | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
For consistency |
||||||||
}) |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,17 @@ | ||||||||
import { v4 as uuidv4 } from 'uuid' | ||||||||
import { defineConfig } from '@wdio/config' | ||||||||
import { publishCucumberReport } from '@wdio/cucumber-framework'; | ||||||||
|
||||||||
export const config = defineConfig({ | ||||||||
// ... Other Configuration Options | ||||||||
cucumberOpts: { | ||||||||
// ... Cucumber Options Configuration | ||||||||
format: [ | ||||||||
['message', `./reports/${uuidv4()}.ndjson`], | ||||||||
['json', './reports/test-report.json'] | ||||||||
] | ||||||||
}, | ||||||||
async onComplete() { | ||||||||
await publishCucumberReport('./reports'); | ||||||||
} | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
For consistency |
||||||||
}) |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,16 @@ | ||||||||
import { defineConfig } from '@wdio/config' | ||||||||
|
||||||||
export const config = defineConfig({ | ||||||||
//... | ||||||||
services: [ | ||||||||
// your other services | ||||||||
[ | ||||||||
"ocr", | ||||||||
{ | ||||||||
contrast: 0.25, | ||||||||
imagesFolder: ".tmp/", | ||||||||
language: "eng", | ||||||||
}, | ||||||||
], | ||||||||
], | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
For consistency |
||||||||
}); |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,14 +1,16 @@ | ||||||||||||||||||||||||||||||
import fs from 'node:fs' | ||||||||||||||||||||||||||||||
import { remote } from 'webdriverio' | ||||||||||||||||||||||||||||||
import { defineConfig } from '@wdio/config' | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
const browser = await remote({ | ||||||||||||||||||||||||||||||
const config = defineConfig({ | ||||||||||||||||||||||||||||||
capabilities: { | ||||||||||||||||||||||||||||||
browserName: 'chrome', | ||||||||||||||||||||||||||||||
'goog:chromeOptions': { | ||||||||||||||||||||||||||||||
args: process.env.CI ? ['headless', 'disable-gpu', 'window-size=1200,800'] : [] | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
Comment on lines
6
to
11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
For consistency |
||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||
const browser = await remote(config) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
await browser.url('https://webdriver.io') | ||||||||||||||||||||||||||||||
const apiLink = await browser.$('=API') | ||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never seen
commonCapabilities
, is this new?