Modifying Test Complete Project Properties from script
I've came across a specific issue. I'd like to know if it's possible to modify Current Project Properties directly from the script.
I would like to have PlayBack -> OnError property value (from Stop current item to Stop and rerun current item) to be configurable.Is there any specific way to do so?
Another thing is that currently even a manual project property change from GUI directly affects the .mds file since its added to git repository. Is there some nifty way to avoid it? I don't want to commit any changes by mistake. Maybe switching from Current Project Properties to Global? Is that the way to go? If so, how can I accomplish that?
Sorry, there's no script access to those properties. You can add a feature request or vote for an existing one here:
It does affect the .mds file because that's where the property is stored. If you're concerned about any commit that you're about to make in git, you can always do a diff first.
@Marsha_R, thanks for the answer.
I need to have this property to be configurable by script. What are my options then?
1. Is it a way to have two .mds files for one project and switch it programmatically, then?
2. Or is it the way to reload .mds file after the script change via xml parsing?
I really have no idea how to tackle this problem.
Neither one of those is a good option.
You can try putting your Stop tests and Stop/Rerun tests in two different projects under one project suite. Then they would automatically have different .mds files.
Something else that might work is writing your own event handler for the ones you want to rerun and check for the failure yourself instead of letting TC handle it automatically.
@Marsha_R I would really want to avoid making seprate project in my test suite that would only differ with one parameter (hard for maintenance - 2 same code base).
So if I would choose writing my own event handler, how should I approach it? Let's say I've written a handler for OnStopTestCaseEvent https://support.smartbear.com/testcomplete/docs/reference/events/onstoptestcase.html since it's occurs after test case is executed and it's possible to retireve test case status. But I did not manage to find a help in the docs for telling the TestComplete that current test case should be rerun directly from the script.I've read about TestCase Object https://support.smartbear.com/testcomplete/docs/reference/program-objects/testcase/properties.html but I can only give an information about current item that is currently running, nothing more.
def general_events_on_stop_testcase(sender, stop_testcase_params): err_status = stop_testcase_params.Status if err_status == 2: # HOW TO RERUN TEST FROM HERE?
Nope. And I am fully in line with what Marsha has written.
Any more information as for why do you need scripting access to these properties?
However, regardless of the answer 🙂 I see only two options:
a) Project file parsing and modification before test start. This is generally not recommended and you may do this on your own risk;
b) Implement retry functionality in code. But, depending on your requirements, this might appear to be not a trivial task.
Something like that:
-- Create a loop;
-- Call actual test code from within this loop;
-- Test code must set some flag (e.g. via the project variable) that indicates whether or not test should be rerun. Additionally, this flag may be manipulated by event handling code (e.g. OnLogError);
-- Loop or exit from the loop depending on the flag's state.
/Alex [Community Champion]
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.