The difference between Recording a Script and directly coding
Hello everyone, I am slowly building up my test cases with TestComplete. I realise that I am intuitively using an approach like that:
1- Using Object Spy and locating Web Elements
2- Passing them into my code to interact, click(), setText() etc
But when I record a script TestComplete using a complete different approach like declaring variables for the WebElements in the code and then using them for interactions
I'm curios what are the pros and cons of my approach? If I continue like that is it OK or it may cause some possible future problems for me?
I will quote for the same code from same actions:
My code:
//click Region dropdown
NameMapping.Sys.browser.pagaPersonCreate.dropdownRegion.Click();
//choose a value from the dropdown for example:Tbilisi
NameMapping.Sys.browser.pagePersonCreate.regionTbilisi.Click();
Record Script Code:
Browsers.Item(btChrome).Navigate("https://**********");
let browser = Aliases.browser;
browser.BrowserWindow.Maximize();
let page = browser.pagePersonCreate;
let form = page.sectionAddress.formRegion;
form.label.Click();
page.regionTbilisi.Click();
form.label2.Click();
page.textnodeDidgori.textnodeDidgori2.Click();
Of course code is more than that but I just quoted that part I believe it is enough to explain my question.
Thanks everyone in advance.
It won't cause any harm!