how to get Object.Name without triggering element search
Hi guys,
I know that this topic may sound a bit weird, but I have a very good reasons for it :) Here is my situation...
I have a mapped element, containing an xpath, which I need to pass to a function as a parameter. The xpath alone, may not find an element! This is a critical point of my problem! The xpath is supposed to be used as a parameter in FindElements method. And because FindElements parameter requires xpath, I first need to extract the xpath from the mapped element.
BTW, of course, I know that I can pass the xpath directly as a parameter. But I want all my xpaths stored in Name Mapping and not here or there in keyword/script modules. Therefore, I want to pass either mapped object or string value, representing the mapped/alias object.
The problem is, that if the mapped element is used directly, as a parameter of function, during runtime, it always triggers the element search. But as I mentioned above, the xpath alone cannot find the element!
So I decided to assign the mapped element via string constant (to avoid the search of element) and then convert the string back to object using Eval function. Eval correctly converts the string to object, but then, after calling Name property, it again tries to search the mapped element in UI, which, of course fails, not to mention takes long time.
So, is there a way, how to get the xpath of a mapped element, without triggering element search? Thanks.
Hi, thanks for the suggestion. It's something I considered as a very last resort. Luckily, I finally found the solution of my problem. It fact, it was "easily" solved by unchecking option "Search for visible objects first".
In my initial post, I mentioned, that the element was not found. But it was not the case! The name mapped element was actually always found, it just took quite a lot of time. And because I was impatient, I (prematurely) terminated the search.
After multiple (unsuccessful) tries of editing the xpath, I also tried to play with TC option. I did not expect anything, but surprisingly, unchecking the above mentioned option helped. After unchecking it, the search returned the element (and so Name property) almost instantly.
It's really weird, because according to the description, this option should be ignored in case there is used xpath expression, which is exactly what I'm using :D So it looks like a TC bug or, at very least, misleading description?