Skip to content

Instantly share code, notes, and snippets.

@AlexanderMoskovkin
Created December 5, 2017 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexanderMoskovkin/b5aac22fa803ca206bee2e2cb51a48c5 to your computer and use it in GitHub Desktop.
Save AlexanderMoskovkin/b5aac22fa803ca206bee2e2cb51a48c5 to your computer and use it in GitHub Desktop.
An example how you can test DevExpress ASP controls with TestCafe
import { Selector } from 'testcafe';
fixture `DX Controls`
.page `https://demos.devexpress.com/aspxgridviewdemos/GridEditing/EditModes.aspx`;
const ComboBox = class {
constructor (id) {
this.id = id;
this.dropDownBtn = Selector(`#${id}_B-1`);
this.popup = Selector(`#${id}_DDD_PW-1`);
}
getItem (text) {
return this.popup.find('td[class^="dxeListBoxItem"]').withText(text)
}
}
const Grid = class {
constructor(id) {
this.id = id;
this.mainElement = Selector(`#${id}`);
}
getRow (idx) {
return Selector(`#${this.id}_DXDataRow${idx}`);
}
getEditingRow () {
return Selector(`#${this.id}_DXEditingRow`);
}
getEditBtn (rowIdx) {
return this.getRow(rowIdx).find('span').withText('Edit');
}
getUpdateBtn (rowIdx) {
return this.getEditingRow().find('span').withText('Update');
}
getEditor (columnIdx) {
return Selector(`#${this.id}_DXEditor${columnIdx}_I`);
}
getCell (rowIdx, columnIdx) {
return Selector(`#${this.id}_DXMainTable`).find('tr[class^="dxgvDataRow"]').nth(rowIdx).find('td').nth(columnIdx);
}
}
test('test1', async t => {
const grid = new Grid('ContentHolder_grid');
const combobox = new ComboBox('ControlOptionsTopHolder_ddlEditMode')
await t
.click(combobox.dropDownBtn)
.click(combobox.getItem('Inline'))
.click(grid.getEditBtn(0))
.typeText(grid.getEditor(1), 'My Name', { replace: true })
.click(grid.getUpdateBtn(0))
.expect(grid.getCell(0, 1).textContent).eql('My Name');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment