[英]Automation testing - from Katalon Recorder script to Protactor - is it a good solution?
I'm new in the Automation Testing world.我是自动化测试领域的新手。 I don't know exactly how to implement that for an application built in Angular, with Bambo, git (we are using also JIRA) and the best strategy and tools to use.
我不知道如何使用 Bambo、git(我们也在使用 JIRA)以及最好的策略和工具来为在 Angular 中构建的应用程序实现它。
In my team, we created a lot of tests with Katalon Recorder for doing “automatic” testing from Katalon Recorder.在我的团队中,我们使用 Katalon Recorder 创建了很多测试,以便通过 Katalon Recorder 进行“自动”测试。 Our next step is to execute automatically these tests from a server or for instance Bamboo.
我们的下一步是从服务器或例如 Bamboo 自动执行这些测试。 We didn't currently get a licence for using Katalon Studio.
我们目前没有获得使用 Katalon Studio 的许可。
I tried to export a test from Katalon Recorder in protactor (typescript):我试图在 protactor (typescript) 中从 Katalon Recorder 导出测试:
import { browser, by, element, Key, logging, ExpectedConditions as EC } from 'protractor';
describe('Create Commitment Numberring - Grant', () => {
beforeAll(async () => { });
beforeEach(async () => { });
it('should do something', async () => {
await element(by.linkText("Implementing Measures")).click();
await browser.sleep(1200);
await element(by.linkText("Commitment Numbering")).click();
await browser.sleep(1200);
await element(by.xpath("//commitment-numbering-home/ux-panel/div[2]/div/div[2]/div/div/div[2]/ux-dropdown-button/ux-button/button")).click();
await element(by.xpath("//div[starts-with(@id,'mat-menu-panel-')]/div/span[2]/span/ux-dropdown-button-item/div/button")).click();
// WARNING: unsupported command assertAttribute. Object= {"command":"assertAttribute","target":"//*[@id=\"commitment-numbering-modal\"]/div[2]@style","value":"display: block;"}
expect(await element(by.xpath("//*[@label='Grant']")).getText()).toContain(`Grant`);
// WARNING: unsupported command storeEval. Object= {"command":"storeEval","target":"getComputedStyle(document.querySelector(\".ux-badge--accent\")).backgroundColor","value":"backgroundGrant"}
// WARNING: unsupported command assertEval. Object= {"command":"assertEval","target":"\"${backgroundGrant}\" == \"rgb(255, 214, 23)\"","value":"true"}
expect(await element(by.xpath("//commitment-numbering-home/commitment-numbering-modal/ux-modal/div[2]/div/div/div[1]/uxmodalheader/ux-layout-horizontal/div/div[2]/uxlayouthorizontalcenter/span/b/em")).getText()).toContain(`New Grant`);
expect(await element(by.xpath("//commitment-numbering-home/commitment-numbering-modal/ux-modal/div[2]/div/div/div[1]/uxmodalheader/ux-layout-horizontal/div/div[3]/uxlayouthorizontalright/div/ux-button/button/span[2]")).getText()).toContain(`Check data`);
// WARNING: unsupported command storeEval. Object= {"command":"storeEval","target":"getComputedStyle(document.querySelector(\"html body.modal-open app-root ux-layout-app-shell div#app-wrapper.sidebar--open.sidebar-state-close-with-icons.xxl div#main div#main-content commitment-numbering-home.ng-star-inserted commitment-numbering-modal.ng-star-inserted ux-modal#commitment-numbering-modal div#commitment-numbering-modal.eui-u-anim.ux-modal.eui-u-anim--slideInDown.eui-u-anim--fast.show div.cdk-drag.ux-modal__dialog.cdk-drag-disabled div.ux-modal__content div.cdk-drag-handle.ux-modal__header uxmodalheader.ng-star-inserted ux-layout-horizontal div.ux-layout-horizontal div.ux-layout-horizontal__right uxlayouthorizontalright div.flex-container.button-actions.ng-star-inserted ux-button.ng-star-inserted button.ux-button.ux-button--warning.ux-button--with-label\")).backgroundColor","value":"backgroundCheckDataButton"}
// WARNING: unsupported command assertEval. Object= {"command":"assertEval","target":"\"${backgroundCheckDataButton}\" == \"rgb(242, 149, 39)\"","value":"true"}
expect(await element(by.xpath("//*[@label='Status']/div/label/span")).getText()).toContain(`Status`);
expect(await element(by.xpath("//*[@formcontrolname='statusId']/div")).getText()).toContain(`Active`);
expect(await element(by.xpath("//*[@label='Unit']/div/label/span")).getText()).toContain(`Unit`);
await element(by.xpath("//*[@formcontrolname='orgId']")).click();
await element(by.xpath("//*[@formcontrolname='orgId']/select")).element(by.cssContainingText('option', 'ESTAT.A.5')).click();
expect(await element(by.xpath("//*[@label='Commitment Reference']/div/label/span")).getText()).toContain(`Commitment Reference`);
expect(await element(by.xpath("//*[@class='signature-year']")).getText()).toContain(`Signature Year`);
expect(await element(by.xpath("//*[@class='sequence']")).getText()).toContain(`Sequence Number`);
await element(by.xpath("//commitment-numbering-home/commitment-numbering-modal/ux-modal/div[2]/div/div/div[2]/uxmodalbody/commitment-numbering-form/div[1]/ux-card/div/div[2]/form/div[3]/div/ux-form-group/div/div/div/div/div/ux-datepicker/div/div/ux-button/button")).click();
await element(by.xpath("//mat-calendar[starts-with(@id,'mat-datepicker-')]/div/mat-multi-year-view/table/tbody/tr[2]/td[2]/div")).click();
expect(await element(by.xpath("//*[@class='sequence-number']")).getText()).toContain(`XXXX`);
expect(await element(by.xpath("//*[@label='Credit Type']/div/label/span")).getText()).toContain(`Credit Type`);
// WARNING: unsupported command assertSelectOptions. Object= {"command":"assertSelectOptions","target":"//*[@formcontrolname='creditTypeId']/select","value":"Operational credits,Administrative credits"}
await element(by.xpath("//*[@formcontrolname='creditTypeId']/select[1]")).click();
await element(by.xpath("//*[@formcontrolname='creditTypeId']/select[1]")).element(by.cssContainingText('option', 'Administrative credits')).click();
expect(await element(by.xpath("//*[@label='Commitment BIFI-ID']/div/label/span")).getText()).toContain(`Commitment BIFI-ID`);
await element(by.xpath("//*[@formcontrolname='bifiId']/select[1]")).click();
await element(by.xpath("//*[@formcontrolname='bifiId']/select[1]/")).element(by.cssContainingText('option', '1')).click();
// WARNING: unsupported command storeValue. Object= {"command":"storeValue","target":"//*[@formcontrolname='bifiId']/select[1]/","value":"bifiIDValue"}
expect(await element(by.xpath("//*[@label='Comment']/div/label/span")).getText()).toContain(`Comment`);
await element(by.xpath("//*[@formcontrolname='comment']/span/textarea")).click();
await element(by.xpath("//*[@formcontrolname='comment']/span/textarea")).sendKeys('Creation of a new FD Cnum - Grant - CSB - A.5 - Seb');
await element(by.xpath("//commitment-numbering-home/commitment-numbering-modal/ux-modal/div[2]/div/div/div[1]/uxmodalheader/ux-layout-horizontal/div/div[3]/uxlayouthorizontalright/div/ux-button/button")).click();
expect(await element(by.xpath("//commitment-numbering-home/commitment-numbering-modal/ux-modal/div[2]/div/div/div[1]/uxmodalheader/ux-layout-horizontal/div/div[3]/uxlayouthorizontalright/div/ux-button/button/span[2]")).getText()).toContain(`Edit`);
// WARNING: unsupported command storeEval. Object= {"command":"storeEval","target":"getComputedStyle(document.querySelector(\".flex-container > ux-button:nth-child(1) > button:nth-child(1)\")).backgroundColor","value":"backgroundEditButton"}
// WARNING: unsupported command assertEval. Object= {"command":"assertEval","target":"\"${backgroundEditButton}\" == \"rgb(0, 68, 148)\"","value":"true"}
expect(await element(by.xpath("//commitment-numbering-home/commitment-numbering-modal/ux-modal/div[2]/div/div/div[3]/uxmodalfooter/ux-layout-horizontal/div/div[3]/uxlayouthorizontalright/ux-button[1]/button/span[2]")).getText()).toContain(`Save`);
// WARNING: unsupported command storeEval. Object= {"command":"storeEval","target":"getComputedStyle(document.querySelector(\"div.show:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > uxmodalfooter:nth-child(1) > ux-layout-horizontal:nth-child(1) > div:nth-child(1) > div:nth-child(3) > uxlayouthorizontalright:nth-child(1) > ux-button:nth-child(1) > button:nth-child(1)\")).backgroundColor","value":"backgroundSaveButton"}
// WARNING: unsupported command assertEval. Object= {"command":"assertEval","target":"\"${backgroundSaveButton}\" == \"rgb(70, 122, 57)\"","value":"true"}
expect(await element(by.xpath("//commitment-numbering-home/commitment-numbering-modal/ux-modal/div[2]/div/div/div[3]/uxmodalfooter/ux-layout-horizontal/div/div[3]/uxlayouthorizontalright/ux-button[2]/button/span")).getText()).toContain(`Close`);
// WARNING: unsupported command storeEval. Object= {"command":"storeEval","target":"getComputedStyle(document.querySelector(\"div.show:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > uxmodalfooter:nth-child(1) > ux-layout-horizontal:nth-child(1) > div:nth-child(1) > div:nth-child(3) > uxlayouthorizontalright:nth-child(1) > ux-button:nth-child(2) > button:nth-child(1)\")).backgroundColor","value":"backgroundCloseComm"}
// WARNING: unsupported command assertEval. Object= {"command":"assertEval","target":"\"${backgroundCloseComm}\" == \"rgb(255, 255, 255)\"","value":"true"}
expect(await element(by.xpath("//*[@label='Status']/div/label/span")).getText()).toContain(`Status`);
expect(await element(by.xpath("//*[@formcontrolname='statusId']/div")).getText()).toContain(`Active`);
expect(await element(by.xpath("//*[@label='Unit']/div/label/span")).getText()).toContain(`Unit`);
expect(await element(by.xpath("//*[@formcontrolname='orgId']/div")).getText()).toContain(`ESTAT.A.5`);
expect(await element(by.xpath("//*[@label='Commitment Reference']/div/label/span")).getText()).toContain(`Commitment Reference`);
expect(await element(by.xpath("//*[@class='signature-year']")).getText()).toContain(`Signature Year`);
expect(await element(by.xpath("//*[@formcontrolname='dtSignatureYear']/div/div/div/input")).getAttribute('value')).toContain(`2021`)
expect(await element(by.xpath("//*[@class='sequence']")).getText()).toContain(`Sequence Number`);
expect(await element(by.xpath("//*[@class='sequence-number']")).getText()).toContain(`XXXX`);
expect(await element(by.xpath("//*[@label='Credit Type']/div/label/span")).getText()).toContain(`Credit Type`);
expect(await element(by.xpath("//*[@formcontrolname='creditTypeId']/div")).getText()).toContain(`Administrative credits`);
expect(await element(by.xpath("//*[@label='Commitment BIFI-ID']/div/label/span")).getText()).toContain(`Commitment BIFI-ID`);
expect(await element(by.xpath("//*[@formcontrolname='bifiId']/div")).getText()).toContain(`${bifiIDValue}`);
expect(await element(by.xpath("//*[@label='Comment']/div/label/span")).getText()).toContain(`Comment`);
expect(await element(by.xpath("//*[@formcontrolname='comment']/div/div")).getText()).toContain(`Creation of a new FD Cnum - Grant - CSB - A.5 - Seb`);
await element(by.xpath("//commitment-numbering-home/commitment-numbering-modal/ux-modal/div[2]/div/div/div[3]/uxmodalfooter/ux-layout-horizontal/div/div[3]/uxlayouthorizontalright/ux-button[1]/button")).click();
// WARNING: unsupported command assertAttribute. Object= {"command":"assertAttribute","target":"//*[@id=\"commitment-numbering-modal\"]/div[2]@style","value":"display: none;"}
// WARNING: unsupported command assertElementPresent. Object= {"command":"assertElementPresent","target":"//html/body/app-root/ux-layout-app-shell/div/ux-growl/div/div","value":""}
// WARNING: unsupported command assertElementPresent. Object= {"command":"assertElementPresent","target":"//html/body/app-root/ux-layout-app-shell/div/ux-growl/div/div","value":""}
// WARNING: unsupported command storeAttribute. Object= {"command":"storeAttribute","target":"//html/body/app-root/ux-layout-app-shell/div/ux-growl/div/div@class","value":"validationAlertBox"}
// WARNING: unsupported command assertEval. Object= {"command":"assertEval","target":"storedVars[\"validationAlertBox\"].includes(\"success\")","value":"true"}
// WARNING: unsupported command assertElementPresent. Object= {"command":"assertElementPresent","target":"//html/body/app-root/ux-layout-app-shell/div/ux-growl/div/div/div/div","value":""}
expect(await element(by.xpath("//html/body/app-root/ux-layout-app-shell/div/ux-growl/div/div/div/div/span")).getText()).toContain(`Create Success`);
// WARNING: unsupported command assertElementPresent. Object= {"command":"assertElementPresent","target":"//html/body/app-root/ux-layout-app-shell/div/ux-growl/div/div/div/div/p","value":""}
expect(await element(by.xpath("//html/body/app-root/ux-layout-app-shell/div/ux-growl/div/div/div/div/p")).getText()).toContain(`Commitment Numbering created successfully`);
await browser.sleep(3000);
// WARNING: unsupported command assertElementNotPresent. Object= {"command":"assertElementNotPresent","target":"//html/body/app-root/ux-layout-app-shell/div/div[2]/div","value":""}
});
afterEach(async () => {
// Assert that there are no errors emitted from the browser
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
expect(logs).not.toContain(jasmine.objectContaining({
level: logging.Level.SEVERE,
} as logging.Entry));
});
});
1 - As you can see when exporting in this format, a lot of warnings appear. 1 - 正如您在以这种格式导出时所看到的,出现了很多警告。 In another format there are less warning.
在另一种格式中,警告较少。 I'm afraid when choosing this export format, that the tests will not correctly work, what do you think about that ?
我担心在选择这种导出格式时,测试将无法正常工作,您对此有何看法?
2 - Is it the best format for exporting the tests suits in order to use it for Automation Testing? 2 - 它是导出测试套装以用于自动化测试的最佳格式吗?
3 - Could you please explain me how to implement the automation testing, which are the best strategy and tools to use? 3 - 你能解释一下如何实施自动化测试,哪些是最好的策略和工具?
Thanks in advance for your help在此先感谢您的帮助
when you read through my answer, keep in mind that I'm not a fan of record n play tools in general当您通读我的回答时,请记住,我一般不喜欢 Record n 播放工具
Before I even give you feedback about your questions, I must mention that protractor is being deprecated soon (look up for more info) and thus it shouldn't be chosen for long term projects在我就你的问题给你反馈之前,我必须提到量角器很快就会被弃用(查找更多信息),因此不应该为长期项目选择它
Now back to your questions现在回到你的问题
But I have a question in turn too, why did the team decide to convert Katalon tests into actual scripts?但反过来我也有一个问题,为什么团队决定将 Katalon 测试转换为实际脚本? What was wrong with Katalon test suites?
Katalon 测试套件有什么问题? Please comment below
请在下方评论
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.