I have tried all of the refreshes that I could find.
It will only find the page elements on the previous page. Any suggestions on what I can do? I have tried both a click and a mouseclick
18 Answers, 1 is accepted
From your description you might be dealing with an AJAX postback. Instead of using the Refresh methods, try waiting for the AJAX Postback to complete as seen in this article. This ensures synchronization with the postback event.
If you are still unable to get this to work, you can point as to a publicly accessible application that demonstrates the issue and we'll be glad to assist you in finding the best way to overcome the problem.
the Telerik team
Basically if I click the Calendar link then the Calendar section will open, but I cannot find the Calendar DOM elements (i.e. It will only display the mail objects).
I have created a temporary login and password for the application I'm automating:
Email Address: firstname.lastname@example.org
Please let me know any suggestions/options
If you need to see the code in my framework this is what I have (I have my framework setup with PageObjects Class & Navigate Class):
Thank you for the provided access to your application. The problem is that all objects on the Calendar page are contained inside of a Frame. To access the frame elements and perform actions against them, you need to access the frame from the 'Frames' collection first.
Here is a sample code against your application:
This code will navigate to the Calendar page, get the frame from the 'Frames' collection and click on the arrow button to navigate to the next date in the Calendar. See this video.
Hope this helps!
the Telerik team
I am having a similar issue, i discovered in the web application that i was testing against, it generates modal pop-up(child) windows, the DOM of which gets added the DOM of the main page(parent page), so when i do a Manager.ActiveBrowser.RefreshDomTree() it discovers the element present on the child pop-up window.
So my sample code is below:
Manager.ActiveBrowser.Find.ByExpression<HtmlImage>(new HtmlFindExpression("tagname=img", "id="parentpagesubmitbtn")).Click();
Thread.Sleep(2000); //wait for a random time here 2 secs for the popup
Manager.ActiveBrowser.RefreshDomTree(); //refresh the dom
HtmlDiv divModalpopup = Manager.ActiveBrowser.Find.ByExpression<HtmlDiv>(new HtmlFindExpression("tagname=div", "id=divonthemodalpopup"));
I need to do a random wait of 2 secs even though the popup apears earlier, i noticed that if i do away with the thread.sleep(2000) ,the manager object cant find the element on the popup. Is there anyway to do away with the Thread.sleep and have something like the manager.waituntilready to wait till the popup content loads and then do a refresh on the DOM tree? I hope i explained myself clearly here. I dont want to introduce sleep in my code.
@Yatindra - When I connect to a new window I usually add a statement similiar to:
This way I don't have to add a Thread.Sleep(3000) and it will continue once it is finds the new window.
Thanks for the quick response. The issue is that Its a modal pop-up(usually a div) not a Html modal, so will that work for the same. Technically it doesnt open in a new browser window, but inside the same parent page container.
Hopefully Telerik Support will be able to mention a better solution.
Although your suggestion works.. the condition that i have built the test system is that I will not be introducing any manual timeout(sec) in the code at any place, hence i am using the waituntilready() function in the code and there isnt a sleep or timeout condition anywhere in the code. I would like to stick to that design, is there any way i can let the page dictate that it has completed the loading rather than giving manual timeouts in the code? Any suggestion woulld be helpful
Actually Matt is right, the best way to handle this scenario is to use the WaitForElement method and pass the timeout value as an argument to that method. Note that this is not a hard-coded timeout. Test Studio will wait up to the specified timeout value, refreshing the DOM tree, and at the moment the element is found in the DOM, it will proceed with the rest of the test.
See this article for more information.
Thank you for assisting another customer. I've updated your Telerik points accordingly.
Thanks for the reply, this issue is that by design i let the page dictate when it is loaded all it DOM, take for example a scenario where i specify the timeout condition in the waitforelement, but the page hasnt completely loaded and some processes are still going on for the DOM to be completely loaded.
Unfortunately these are the only three options we can offer you right now:
- ActiveBrowser.WaitUntilReady() - This will wait for the browser to return to a ready state, but if you have processes running on the background(AJAX Postback for example) after the ready state is returned this will not work.
- Wait for an AJAX Postback to Complete - This ensures synchronization with the postback event.
- WaitForElement - Waits for a specific element to exists in DOM.
One last suggestion I have is if your page has a lot of AJAX connections I've also had success implementing this custom AJAX wait from forum post (http://www.telerik.com/automated-testing-tools/community/forums/test-studio-express/automation-framework/need-a-better-way-to-wait-for-ajax-operation-to-complete.aspx).
I am having a similar issue to others. I have a "very" simple AJAX / Jquery UI auto-complete box and all I am trying to do is to insure that it is populated when an expected search term is entered.
Here is my code:
The problem is in the ActiveBrowser.WaitForAjax(). If I step through the code manually, it works with no problem. However, if I let the code just run on its own (or as part of a group of tests), then it fails. I believe the issue is that the "WaitForAjax()" is returning and the "RefreshDomTree()" is being called before the DOM is actually updated.
Any ideas would be great!
Please send us the trace log. What is the exception when the code fails.
You can also try refresh the DOM first and then wait for Ajax.
Hope to hear from you soon.
I am not sure what "trace log" you are referring to. However, the error I get when the code fails is that the "Assert.True()" failed. This is happening because it is not seeing the DOM refreshed. I also tried reversing the "RefreshDOM" and "WaitForAjax" but no luck. Any ideas?
I mean the log from the test, where the error/exception appears.
You can try out also this:
1. Sleep the thread for 10-15 secs before the assert:
2. Increase Ajax timeout.
If the issue persists we need to reproduce the issue on our end to give you a solution. Please provide us with a copy of your test and if it is possible grant us access to your application so we can reproduce the issue on our end and give you a solution.
If direct access is not possible, capture a Fiddler trace and attach it to this support ticket in a zip file. If you are unfamiliar with how to do so, this link will provide you with step-by-step instructions for download and use. Please make sure to enable 'Decrypt HTTPS traffic' and 'Store binaries' options (see attached image) before starting capture.
Hope to hear from you soon.