Skip to content

Instantly share code, notes, and snippets.

View Xotabu4's full-sized avatar
🇺🇦

Oleksandr Khotemskyi Xotabu4

🇺🇦
View GitHub Profile
@Xotabu4
Xotabu4 / wait.js
Created June 7, 2019 17:42
wait for everything, without browser.wait or driver.wait
async function waitFor(condition, timeout, poolInterval) {
const timeoutDeadline = new Date().getTime() + timeout;
let iterationRes;
do {
console.log('#', new Date().getTime(), timeoutDeadline);
if (new Date().getTime() > timeoutDeadline) {
let timeoutError = new Error("Wait timeout error!");
console.log(condition.toString())
throw timeoutError;
}
// Arrays
let arr = new Array();
let arr = []; // mostly used
// Declare array with some initial data:
let fruits = ["Apple", "Orange", "Plum"];
// GET element from array - use index
let fruits = ["Apple", "Orange", "Plum"];
// Call stack is whole tree of nested function calls
function A() {
return B();
}
function B() {
return C();
}
@Xotabu4
Xotabu4 / errors.js
Created January 23, 2019 09:34
Hadling it errors
describe("describing", function() {
it("", myWrapper(async function () {
await new Promise((resolve, reject)=> {
setTimeout(()=> reject(new Error('Test error!')), 1000)
})
}));
});
function myWrapper(fn) {
return async function() {
@Xotabu4
Xotabu4 / e2e-shadowdom.md
Created May 7, 2018 23:37 — forked from ChadKillingsworth/e2e-shadowdom.md
Selenium Testing with Shadow DOM

End-to-end Testing with Shadow DOM

As the web component specs continue to be developed, there has been little information on how to test them. In particular the /deep/ combinator has been deprecated in Shadow DOM 1.0. This is particularly painful since most end-to-end testing frameworks rely on elements being discoverable by XPath or calls to querySelector. Elements in Shadow DOM are selectable by neither.

WebDriver.io

Webdriver.io has the standard actions by selectors, but also allows browser executable scripts to return an element

@Xotabu4
Xotabu4 / selenoid.rb
Last active April 12, 2018 11:18
selenoid (1.6.0) cannot create session when video record enabled
docker_container 'selenoid' do
repo 'aerokube/selenoid'
tag node['selenoid']['selenoid_version']
volumes [
'/var/run/docker.sock:/var/run/docker.sock',
"/etc/selenoid:/etc/selenoid/",
"/etc/selenoid/video/:/opt/selenoid/video/",
]
env ["OVERRIDE_VIDEO_OUTPUT_DIR=/etc/selenoid/video/"]
command '-conf /etc/selenoid/browsers.json -limit 11 -retry-count 5 -session-attempt-timeout 30s -video-output-dir /opt/selenoid/video'

Keybase proof

I hereby claim:

  • I am xotabu4 on github.
  • I am okhotemskyi (https://keybase.io/okhotemskyi) on keybase.
  • I have a public key ASAMzEWGOiRWEjy10MabDsephkzkXd1LRVARZnZ8iogzqwo

To claim this, I am signing this object:

@Xotabu4
Xotabu4 / docker-compose.yml
Created January 18, 2018 11:20
selenoid docker compose
version: "2"
services:
selenoid:
container_name: selenoid
network_mode: bridge
image: "aerokube/selenoid:1.3.9"
command: -limit 15 -retry-count 1000
ports:
- 4444:4444
volumes:
@Xotabu4
Xotabu4 / accountProviderService.js
Created August 8, 2017 09:08
Little nodejs http server for serving users to protractor parallel runs, so each thread will get unique user.
/**
* Created by akhotemskyi on 8/18/16.
*/
const request = require('request');
let http = require('http');
let accounts;
let server;
/**
* Accepts array of object with users, that should be served thru HTTP server.
import * as fs from 'fs'
class User {
constructor(public firstName: string,
public lastName: string,
public id: number) { }
toString() {
return `First Name: ${this.firstName}, Last Name: ${this.lastName}, id: ${this.id}`
}