I'm having a message time to time could not find any reason.
dose any body have an idea.
it's same place when just started test.
comes only ramdomly ...
the number reffered did not change so may not be a memory location?
Solved! Go to Solution.
We'd kind of need to know what's being executed. What's the code being run? Have you tried dropping in a break point and debugging to see where the error happens?
Anyway I handled that using try/except ....but original problem is there.
below is my code..(with solution)
error fires at highlighted log message line
class Tabs(): def __init__(self,tab=None): self.tab = tab def tabExists(self): success = False while not success: try: Aliases.......MDIClient.RefreshMappingInfo() tabCount = Aliases...........MDIClient.ChildCount if tabCount ==0 : return False for i in range (0,tabCount): childtab = Aliases.................MDIClient.Child(i) if self.tab in childtab.Text: Log.Message(childtab.Text+" ..exists") return True else: return False success = True # <--this will never excute, just in case except RuntimeError: Log.Message(RuntimeError) success =False
Un fortunatly can not debug since it dosn't occure every time ....
once in 5 /6 times.
Not been a Python guru...
> for i in range (0,tabCount)
Shouldn't it be
for i in range (0,tabCount - 1)
Thanks for the help, guys!
@NisHera, does it help resolve the issue?
Thanks for the update, @NisHera.
Let me mark Alexei's reply as a solution for a while. If it doesn't work for you - just post an update here and we will continue investigating the issue.
Thank you for the update.
Well... Now, with the update from you, the reason seems to be obvious to me. 🙂
So... Just for the record...
And again - my experience with Python is very limited, thus, I might be wrong with something Python-related, but in general:
-- Usually, it is not the best idea to use more or less persistent variables to keep references to UI objects that potentially can change (be disposed of/recreated/properties changed/etc.);
-- It is even less good idea to keep references to the Aliased objects. On the one hand, Aliases use late binding which makes it possible to declare variables like this: someVar = Aliases.SomeObject even when SomeObject does not exist yet. Variable will be initialized with the actual object reference at the moment when test code will attempt to perform some action over the object. On the other hand, as it is described in the documentation, Aliases object tries to keep a cached copy of the object and may not update it when the real object changes. This requires test developer to be very attentive to potential caching problems and either avoid them or use .Refresh()/.RefreshMappingInfo() properly.