Forum Discussion
Hi,
I try to reproduce the same code as appear https://support.smartbear.com/testcomplete/docs/app-testing/web/services/custom-headers.html
1) I add a General event -> GeneralEvents_OnWebServiceRequest
2) Generate the script in python
def GeneralEvents_OnWebServiceRequest(Sender, Request, Helper, RequestInfo):
Helper.AddHeader('USER', 'http://auth.', '1014531');
Helper.AddHeader('PASSWORD', 'http://auth', '4QrcOUm6Wau+VuBX8g+IPg==');
def Main():
webservice.example.method()
and the solution is: no head included and when I run the method GeneralEvents_OnWebServiceRequest appear:
AttributeError: 'NoneType' object has no attribute 'AddHeader' 14:25:40 Normal 0,00
Run Script Routine Unit1 - GeneralEvents_OnWebServiceRequest ... Runs a script routine.
- tristaanogre7 years agoEsteemed Contributor
Based upon what you have posted, it appears that you have added the event handler as a script routine call to a keyword test. That is not how event handlers work. You should be running ONLY what you have declared as def Main(). The event handler will be triggered automatically when the request is made. This is why you're getting the error your getting: there is no "Helper" to add a header to because you're running the event handler directly.
As for the recursive call... You probably have the keyword test you're trying to run call a method which in turn calls the keyword test. That's what recursion is... Especially if you are having the keyword test call the event handler and the event handler calling Main which triggers the event handler.
The solution in the article you linked only runs "Main". No other code is directly executed.If you need further help, please post a screenshot of the KeywordTest you are attempting to run so we can help you correct that.
Related Content
- 11 years ago
- 2 years ago
Recent Discussions
- 5 hours ago