Skip to content

Instantly share code, notes, and snippets.

View Xotabu4's full-sized avatar
🇺🇦

Oleksandr Khotemskyi Xotabu4

🇺🇦
View GitHub Profile
@Xotabu4
Xotabu4 / config.ts
Last active February 4, 2022 01:05
Describing how add automatic waits, scrolling and retries for wdio click function
import { declareClickCommand } from './customCommands';
export const baseConfig: WebdriverIO.Config = {
bail: 0,
automationProtocol: 'webdriver',
hostname: 'localhost',
protocol: 'http',
port: 4444,
path: '/wd/hub',
baseUrl: '',
// name: Trigger tests for run
// description: Triggers automated tests for a test run
// author: Oleksandr Khotemskyi <xotabu4@github.io>
// version: 1.0
// includes: ^runs/view
// excludes:
// js:
$(document).ready( function () {
// TestRail project id -> gitlab pipeline
@Xotabu4
Xotabu4 / config.ts
Last active February 14, 2020 13:24
// Somewhere in protractor onPrepare:
onPrepare: function () {
patchProtractorWait()
afterEach(async function () {
// Wait fix needs to be re-applied after browser restart, checking if function was patched already:
const waitFunctionSymbols = Object.getOwnPropertySymbols(browser.wait);
if (!waitFunctionSymbols.includes(WAIT_FIX)) {
patchProtractorWait();
@Xotabu4
Xotabu4 / process_end_listener.ts
Created February 13, 2020 13:07
Trying to close protractor browser on process exit
import { browser } from 'protractor';
/**
* @experimental
*/
export function registerCloseBrowserOnProcessEndListener() {
async function exitHandler(options, exitCode) {
console.log('[registerCloseBrowserOnProcessEndListener] called!');
try {
await browser.close();
/**
* @experimental
* This function tries to highligh exact point at webpage where click was failed,
* by placing special red square into failed coordinate.
* So allure screenshots will show exact failing location
* @param error exception object
*/
async function drawClickPointAttempt(error: Error) {
try {
const text = error.message;
@Xotabu4
Xotabu4 / promise.ts
Last active February 6, 2020 14:31 — forked from SergeyPirogov/promise
const sendCommand = (target, method, params) => {
return new Promise((resolve, reject) => {
chrome.debugger.sendCommand(target, method, params, result => {
if (chrome.runtime.lastError) {
reject(chrome.runtime.lastError);
} else {
resolve(result);
console.log(method, result);
}
});
@Xotabu4
Xotabu4 / index.ts
Created January 10, 2020 10:09
Test files management module. TestResources
import * as path from 'path'
import * as fs from 'fs'
const resFolderImages = './resources/images/'
const resFolderAudio = './resources/audio/'
const resFolderOffice = './resources/office/'
const resFolderVideos = './resources/videos/'
const resFolderOther = './resources/other/'
export interface FileStats {
@Xotabu4
Xotabu4 / LoginForm.ts
Last active July 16, 2019 13:34
Protractor Page Object with ShadowDOM example. Uses Protractor By.js - http://www.protractortest.org/#/api?view=webdriver.By.js
import { browser, By, element, ElementFinder, ExpectedConditions as EC } from 'protractor';
class LoginModal {
private get shadowDOM() {
return element(By.js(function () {
// returned value must be array
return [document.querySelector('CSSselectorForShadowDomContainingElement').shadowRoot];
}));
}