Forum Discussion
Hi kkrush,
You can use the EvaluateXPath in the Run Code Snippet Operation.
Also, you can run a script routine from keyword tests - https://support.smartbear.com/testcomplete/docs/keyword-testing/reference/test-actions/run-script-routine.html
Does it help?
- mcretacci2 years agoNew Contributor
i created a powershell script to log the time it takes to load the applications. for example: when user logs in, the biostime came out to be 15.756 seconds in the logged txt file. in testcomplete, i want the test to read the number in the file and create an if/else statement like: if bioslog is greater than 3 seconds fail, if less than pass.
- kkrush6 years agoOccasional Contributor
Hi Tanya,
Thank you so much for the information, I have created the keyword script for evaluatexpath, but the keyword test fails with the following exception "
Unable to evaluate the operation's "NewValue" parameter. Error: ReferenceError: LastResult is not defined", please find the screenshot attached.I then converted the keyword test into a script and ran it, and it works fine.RunCode snippet used is : Aliases.browser.pageXXXXXXXXXURL.panel.EvaluateXPath("//a[contains(@class, \'login-to-load ng-star-inserted\')]");tried with "QuerySelectorAll", same thing, keyword test fails, but convert to script and run it, it works.Why is the keyword script failing, can you please help here ?- AlexKaras6 years ago
Champion Level 1
Hi,
a) What line generates the exception?
b) What is this NewValue parameter? Where and how it is defined and used?
c) I am not sure, but I think that something must be returned from the Run Code Snippet operation in order LastResult variable to be assigned a value. What if you change your line of code to
return Aliases.browser.pageXXXXXXXXXURL.panel.EvaluateXPath("//a[contains(@class, \'login-to-load ng-star-inserted\')]");
- kkrush6 years agoOccasional Contributor
a) What line generates the exception?
b) What is this NewValue parameter? Where and how it is defined and used?
c) I am not sure, but I think that something must be returned from the Run Code Snippet operation in order LastResult variable to be assigned a value. What if you change your line of code to
return Aliases.browser.pageXXXXXXXXXURL.panel.EvaluateXPath("//a[contains(@class, \'login-to-load ng-star-inserted\')]");
I am attaching the project file, can you please take a look.keyword test - Test2Test case StepsGo to url :Maximize the browserGet the xpath of a button (which is the code snippet) , using "evaluateXpath"Process it to check how many are there on the page.Display the count as an output.Note : The same keyword when converted to a script, it works fine, I am curious to know why keyword test is not working.