Skip to content

Instantly share code, notes, and snippets.

View AlexanderMoskovkin's full-sized avatar

Alexander Moskovkin AlexanderMoskovkin

View GitHub Profile
@AlexanderMoskovkin
AlexanderMoskovkin / cypress-vs-testcafe-example.js
Last active November 22, 2017 07:54
TestCafe Selector tips and tricks
// cypress
cy.get('table tr')
.each(function ($tr , index, $list){
if($tr[0].children[2].innerHTML == criteria)
{
cy.wrap($tr[0].children[0].children[0].children[0].children[0]).click()
}
})
//testcafe
import { ClientFunction } from 'testcafe';
const performAsyncOperation = ClientFunction(() => {
return Promise
.resolve()
.then(asyncFn)
.then(otherAsyncFn);
});
import { Selector } from 'testcafe';
var jQuery = Selector(selector => {
return jQuery(selector).toArray();
});
fixture `Check jQuery approach`
.page `https://jquery.com/`;
test('test', async t => {
await t
.expect(items.count).eql(0)
.typeText(newTodoInput, 'Item 1')
.pressKey('enter')
.expect(items.count).eql(2) // replace 1 with 2
.expect(items.nth(0).find('label').textContent).eql('Item 1');
import Page from './page-object';
const page = new Page();
fixture `SVG`
.page('./vue/examples/svg/index.html');
test('Add a stat', async t => {
await t
.expect(page.axisLabels.count).eql(6)
import Page from './page-object';
const page = new Page();
fixture `SVG`
.page('./vue/examples/svg/index.html');
test('Add a stat', async t => {
await t
.expect(page.axisLabels.count).eql(6)
this.axisLabels = VueSelector('axis-label');
this.addForm = {
input: Selector('input[name=newlabel]'),
btnAdd: Selector('button').withText('Add a Stat')
};
import VueSelector from 'testcafe-vue-selectors';
import { Selector } from 'testcafe';
export default class SvgPage {
constructor () {
this.addForm = {
input: Selector('input[name=newlabel]'),
btnAdd: Selector('button').withText('Add a Stat')
};
this.axisLabels = VueSelector('axis-label');
const { props, state, computed } = await VueSelector('todo-item').getVue();