exports.ProductPage= class ProductPage { constructor(page) { this.page = page; this.productsButton = "//span[normalize-space()='Products']"; this.productListButton= "//a[normalize-space()='Product List']"; this.addProductButton="//a[normalize-space()='Add Product']"; this.productName="//input[@id='oba_product_name']"; this.productPrize="//input[@id='oba_product_price']"; this.managedRadioButton="//input[@id='managed']"; this.unmanagedRadioButton="//input[@id='unmanaged']"; this.productQuantityValue="//input[@id='oba_product_quantity']"; this.orderLimit="//input[@id='oba_product_order_limit']"; this.taxIn="//input[@id='oba_product_tax']"; this.productAvailableCheck="//input[@name='isAvailable']"; this.isLiveCheck="//input[@name='isLive']"; this.shortDescription="//textarea[@id='oba_product_short_description']"; this.productDescription="//textarea[@name='editor-html-code']"; this.productImage="#edit_image"; this.uploadImage="#oba_product_input_display"; this.productlistSearchBox="//input[@id='oba_product_search']"; this.searchBox="//i[@class='fa fa-lg fa-fw fa-search']"; this.editButton="//i[@class='fa fa-lg fa-edit']"; this.saveButton="//button[@class='btn btn-primary btn-block']"; this.deleteButton="//i[@class='fa fa-lg fa-trash']"; this.searchProduct="//input[@id='oba_product_search']"; this.searchButton="//button[@id='oba_product_search_btn']"; //API this.nameAPI="//td[normalize-space()='T-Shirt']"; this.priceAPI="//b[normalize-space()='200']"; this.quantityAPI="//td[normalize-space()='79971']"; this.availableAPI="//td[normalize-space()='true']"; this.orderlimitAPI="//td[normalize-space()='100']"; } async clickProductsButton(){ await this.page.locator(this.productsButton).click(); } async clickProductlistButton(){ await this.page.locator(this.productsButton).click(); await this.page.locator(this.productListButton).click(); } async clickAddProductButton(){ await this.page.locator(this.productsButton).click(); await this.page.locator(this.addProductButton).click(); } async addProductFunctionality(productName, productPrize, productQuantity, orderLimitvalue, taxin, shortDescription){ await this.page.locator(this.productsButton).click(); await this.page.locator(this.addProductButton).click(); await this.page.locator(this.productName).fill(productName); await this.page.locator(this.productPrize).fill(productPrize); await this.page.locator(this.managedRadioButton).check(); await this.page.locator(this.productQuantityValue).fill(productQuantity); await this.page.locator(this.orderLimit).fill(orderLimitvalue); await this.page.locator(this.taxIn).fill(taxin); await this.page.locator(this.productAvailableCheck).check(); await this.page.locator(this.isLiveCheck).check(); await this.page.locator(this.shortDescription).fill(shortDescription); await this.page.waitForSelector('.CodeMirror'); await this.page.evaluate(() => { const codeMirrorElement = document.querySelector('.CodeMirror'); codeMirrorElement.CodeMirror.setValue('Yummy! Delicious Biriyani Taste the Beauty of Kanyakumari'); }); await this.page.locator(this.productImage).click(); await this.page.locator(this.uploadImage).setInputFiles("C:/Automate Testing/OBA Automation/Biriyani.jpg"); await this.page.locator(this.saveButton).click(); } async addProductFunctionalityDelete(productName, productPrize, productQuantity, orderLimitvalue, taxin, shortDescription){ await this.page.locator(this.productsButton).click(); await this.page.locator(this.addProductButton).click(); await this.page.locator(this.productName).fill(productName); await this.page.locator(this.productPrize).fill(productPrize); await this.page.locator(this.managedRadioButton).check(); await this.page.locator(this.productQuantityValue).fill(productQuantity); await this.page.locator(this.orderLimit).fill(orderLimitvalue); await this.page.locator(this.taxIn).fill(taxin); await this.page.locator(this.productAvailableCheck).check(); await this.page.locator(this.isLiveCheck).check(); await this.page.locator(this.shortDescription).fill(shortDescription); await this.page.waitForSelector('.CodeMirror'); await this.page.evaluate(() => { const codeMirrorElement = document.querySelector('.CodeMirror'); codeMirrorElement.CodeMirror.setValue('Yummy! Delicious Biriyani Taste the Beauty of Kanyakumari'); }); await this.page.locator(this.productImage).click(); await this.page.locator(this.uploadImage).setInputFiles("C:/Automate Testing/OBA Automation/Biriyani.jpg"); await this.page.locator(this.deleteButton).click(); } async addProductFunctionalityForAll(productName, productPrize, productQuantity, orderLimitvalue, taxin, shortDescription){ await this.page.locator(this.productsButton).click(); await this.page.locator(this.addProductButton).click(); await this.page.locator(this.productName).fill(productName); await this.page.locator(this.productPrize).fill(productPrize); await this.page.locator(this.managedRadioButton).check(); await this.page.locator(this.productQuantityValue).fill(productQuantity); await this.page.locator(this.orderLimit).fill(orderLimitvalue); await this.page.locator(this.taxIn).fill(taxin); await this.page.locator(this.productAvailableCheck).check(); await this.page.locator(this.isLiveCheck).check(); await this.page.locator(this.shortDescription).fill(shortDescription); await this.page.waitForSelector('.CodeMirror'); await this.page.evaluate(() => { const codeMirrorElement = document.querySelector('.CodeMirror'); codeMirrorElement.CodeMirror.setValue('Yummy! Delicious Taste, LifteTime Settlement'); }); //await this.page.locator(this.productImage).click(); // await this.page.locator(this.uploadImage).setInputFiles("C:/Automate Testing/OBA Automation/Biriyani.jpg"); await this.page.locator(this.saveButton).click(); } async addProductFunctionalityUnmanaged(productName, productPrize, orderLimitvalue, taxin, shortDescription){ await this.page.locator(this.productsButton).click(); await this.page.locator(this.addProductButton).click(); await this.page.locator(this.productName).fill(productName); await this.page.locator(this.productPrize).fill(productPrize); await this.page.locator(this.unmanagedRadioButton).check(); await this.page.locator(this.orderLimit).fill(orderLimitvalue); await this.page.locator(this.taxIn).fill(taxin); await this.page.locator(this.productAvailableCheck).check(); await this.page.locator(this.isLiveCheck).check(); await this.page.locator(this.shortDescription).fill(shortDescription); await this.page.waitForSelector('.CodeMirror'); await this.page.evaluate(() => { const codeMirrorElement = document.querySelector('.CodeMirror'); codeMirrorElement.CodeMirror.setValue('Crispy Chicken Tandori'); }); await this.page.locator(this.productImage).click(); await this.page.locator(this.uploadImage).setInputFiles("C:/Automate Testing/OBA Automation/Tandori.jpg"); await this.page.locator(this.saveButton).click(); } async addProductFunctionality1(productName, productPrize, productQuantity, orderLimitvalue, taxin, shortDescription){ await this.page.locator(this.productsButton).click(); await this.page.locator(this.addProductButton).click(); await this.page.locator(this.productName).fill(productName); await this.page.locator(this.productPrize).fill(productPrize); await this.page.locator(this.managedRadioButton).check(); await this.page.locator(this.productQuantityValue).fill(productQuantity); await this.page.locator(this.orderLimit).fill(orderLimitvalue); await this.page.locator(this.taxIn).fill(taxin); await this.page.locator(this.productAvailableCheck).check(); await this.page.locator(this.isLiveCheck).check(); await this.page.locator(this.shortDescription).fill(shortDescription); await this.page.waitForSelector('.CodeMirror'); await this.page.evaluate(() => { const codeMirrorElement = document.querySelector('.CodeMirror'); codeMirrorElement.CodeMirror.setValue('Chicken Lollipop'); }); await this.page.locator(this.productImage).click(); await this.page.locator(this.uploadImage).setInputFiles("C:/Automate Testing/OBA Automation/Chicken Lollipop.jpg"); await this.page.locator(this.saveButton).click(); } async searchProductName(productName){ await this.page.locator(this.productsButton).click(); await this.page.locator(this.productListButton).click(); await this.page.locator(this.searchProduct).fill(productName); await this.page.locator(this.searchButton).click(); } async editProduct(){ await this.page.locator(this.productsButton).click(); await this.page.locator(this.productListButton).click(); await this.page.locator(this.editButton).click(); await this.page.locator(this.productAvailableCheck).click(); await this.page.locator(this.saveButton).click(); } }