Skip to content

Commit

Permalink
update test case 'select sheets' with page object pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkchen committed Oct 2, 2019
1 parent 7923f83 commit 1cc119f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
21 changes: 21 additions & 0 deletions zss.test.browser/src/pageObject/Spreadsheet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Selector, t } from 'testcafe';

/**
* Implement a page object pattern.
* Reference:
* - https://devexpress.github.io/testcafe/documentation/recipes/extract-reusable-test-code/use-page-model.html
* - https://martinfowler.com/bliki/PageObject.html
*/
export default class Spreadsheet{
selector: any;
sheetbar: any;

constructor (){
this.selector = Selector('.zssheet');
this.sheetbar = this.selector.find('.zssheettab');
}

async select(index: number){
await t.click(this.sheetbar.nth(index));
}
}
10 changes: 4 additions & 6 deletions zss.test.browser/src/selectSheet.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import { Selector } from 'testcafe';
import { ClientFunction } from 'testcafe';
import Spreadsheet from './pageObject/Spreadsheet';

fixture `select sheets`
.page `http://localhost:8080/zss.test/issue.zul?file=/book/t10425.xlsx`;


const tabs = Selector('.zssheettab');

/**
* select sheets one by one for nTimes
*/
test('select sheets', async t => {

let spreadsheet = new Spreadsheet();

var nTimes = 10;
for (var c = 0 ; c < nTimes ; c++){
for (var i=0 ; i < 6 ; i++){
await t.click(tabs.nth(i));
await spreadsheet.select(i);
}
}
});
Expand Down

0 comments on commit 1cc119f

Please sign in to comment.