Hello,
we are currently evaluating Telerik Test Studio and so far are pleased with the product. We do have, however, an issue regarding finding elements which have dynamic content, that is dynamic InnerText respectively TextContent. The workflow in our scenario is the following:
1. I log into our application
2. I create a new object and assign it a static name
3. I save said object
4. I use a search bar, entering the previously assigned name
5. The corresponding object is displayed
6. I click it and in the following dialog delete it
After having recorded this test, I modified steps 2, 4 and 6 so that they work with dynamic names. For steps 2 and 4 I added an extraction step so that I can use the extracted value for name assignment and searching. For step 6 I first took a look at the Find Expression of the recorded element, which was "tagname=span, TextContent exactly XYZ", where XYZ was the name I statically assigned. I then converted this step into a coded step, using the following statements:
While I believe that this code snippet should do exactly what the original Find Expression did (except that it works for dynamic names), it did not work reliably. Most of the time after step 5 (this step passed without problems) the desired HtmlSpan could not be found. Only when I went into debug mode and passed through the test steps very slowly, it succeeded sometimes. After having searched on your forums for a while I stumbled upon someone claiming that Test Studio sometimes clicks on wrong elements. There, a solution was found by adding the ActiveBrowser.RefreshDomTree()
System.Threading.Thread.Sleep(5000) method right before doing the click action. I did the same for my coded step, also adding a 5-second wait after refreshing the DOM (by using System.Threading.Thread.Sleep(5000)). With this code, the test ran successfully about half the time, maybe a little bit more. I added another call of RefreshDomTree() and another 5-second wait, and now it seems that everything is working fine. My code now looks like this:
I understand that problems like an outdated DOM tree can occur and I would be happy if the problem could be solved by adding one call of ActiveBrowser.RefreshDomTree(). However, having to add two calls of it including the following waits looks more like a workaround than a solution to me. Is there any other possibility to solve this issue? Unfortunately, I cannot provide any project files as our application is still under development and shall not be seen by third parties.
Regards
Julian
we are currently evaluating Telerik Test Studio and so far are pleased with the product. We do have, however, an issue regarding finding elements which have dynamic content, that is dynamic InnerText respectively TextContent. The workflow in our scenario is the following:
1. I log into our application
2. I create a new object and assign it a static name
3. I save said object
4. I use a search bar, entering the previously assigned name
5. The corresponding object is displayed
6. I click it and in the following dialog delete it
After having recorded this test, I modified steps 2, 4 and 6 so that they work with dynamic names. For steps 2 and 4 I added an extraction step so that I can use the extracted value for name assignment and searching. For step 6 I first took a look at the Find Expression of the recorded element, which was "tagname=span, TextContent exactly XYZ", where XYZ was the name I statically assigned. I then converted this step into a coded step, using the following statements:
1.
Dim
objectName
As
Object
= GetExtractedValue(
"objectNameVariable"
)
'The variable used in the extraction step
2.
Dim
objectSpan
As
HtmlSpan = Find.ByExpression(Of HtmlSpan)(
"tagname=span"
,
"TextContent="
+ objectName.ToString())
3.
objectSpan.Click(false)
While I believe that this code snippet should do exactly what the original Find Expression did (except that it works for dynamic names), it did not work reliably. Most of the time after step 5 (this step passed without problems) the desired HtmlSpan could not be found. Only when I went into debug mode and passed through the test steps very slowly, it succeeded sometimes. After having searched on your forums for a while I stumbled upon someone claiming that Test Studio sometimes clicks on wrong elements. There, a solution was found by adding the ActiveBrowser.RefreshDomTree()
System.Threading.Thread.Sleep(5000) method right before doing the click action. I did the same for my coded step, also adding a 5-second wait after refreshing the DOM (by using System.Threading.Thread.Sleep(5000)). With this code, the test ran successfully about half the time, maybe a little bit more. I added another call of RefreshDomTree() and another 5-second wait, and now it seems that everything is working fine. My code now looks like this:
1.
'The span is located here
2.
ActiveBrowser.RefreshDomTree()
3.
System.Threading.Thread.Sleep(5000)
4.
ActiveBrowser.RefreshDomTree()
5.
System.Threading.Thread.Sleep(5000)
6.
'The click action is here
I understand that problems like an outdated DOM tree can occur and I would be happy if the problem could be solved by adding one call of ActiveBrowser.RefreshDomTree(). However, having to add two calls of it including the following waits looks more like a workaround than a solution to me. Is there any other possibility to solve this issue? Unfortunately, I cannot provide any project files as our application is still under development and shall not be seen by third parties.
Regards
Julian