Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as JavaScript by Evgeny_S ( 6 years ago )
//parent class in ../page_objects/pageObject.js

class PageObject {
    constructor(){
        this.SUBMIT_BUTTON = '[data-testid = "submit-button"]';
        this.CANCEL_BUTTON = '[data-testid = "cancel-button"]';
    }
}


//child class in ../page_objects/itemsPage.js

export default class ItemsPage extends PageObject{
    constructor(page){
        super();
        this.page = page;
        this.ADD_BUTTON = '#add-button';
        this.ADD_ITEM_BUTTON = '[id $= "add-item"]';
        this.ADD_FOLDER_BUTTON  = '[id $= "add-folder"]';
    }

    async addFolder(){
        await this.page.hover(this.ADD_BUTTON);
        await this.page.click(this.ADD_FOLDER_BUTTON);
    }

    async addItem(){
        await this.page.hover(this.ADD_BUTTON);
        await this.page.click(this.ADD_ITEM_BUTTON);
    }
}

//test in ../tests/test1.js

import ItemsPage from '../page_objects/itemsPage.js';

//some code

let itemsPage = new ItemsPage(page);

//some code

 

Revise this Paste

Parent: 111074
Your Name: Code Language: