Timeout in Ext Direct - extjs

I'm using Ext Direct to communicate with the server side. My server side takes more than 45 seconds to return all the data to extjs. I can see in the network ( in chrome browser ), that my request was cancelled since the operation took more than 30 seconds.
Where can i override this setting ?
Is it possible ?

I understand in Leo's answer that he suggests to edit directly ExtJS code, I don't think this is a good practice, all the more so as the parameter exists in the REMOTING_API:
Ext.app.REMOTING_API = {
"url":"/usermanagement/extdirect/router",
"actions":{"myService":[{"len":0,"name":"myMethod"}]},
"type":"remoting",
"timeout":120
};

I'm pretty sure it's browser thing. It's not ExtJs breaking your connection attempt but the browser itself.
Update: I haven't tried using ExtDirect with huge data. And honestly speaking - you should not force your user to just wait on load such long time. It's very bad design. If you have something that takes that long - you need to provide some kind of feedback of the progress and break whole communication into smaller pieces.

In your ext-all-debug.js,
under
Ext.define('Ext.data.Connection', { timeout:30000
You can edit the timeout to a higher value, the default value is 30 seconds.

Related

Is there a way to refresh the page as many times as possible and wait for an element to load in that page in selenium?

I need to check if an element is appearing after refreshing a page continuously, cause it takes a while for the changes to be reflected and the element to appear in that page.
Is there any built in method in selenium using Ruby as the programming language ?
Just to confirm, it sounds like the page does not dynamically update once the content is available, so you have to wait until that is true, and then manual refresh, right?
I don't know of anything built into selenium to handle this. It feels like it might even be a symptom of a UI that needs a little more design work (pardon my critique). If the user is experiencing the same thing as the test -- kicking off an action, waiting some unspecified period of time, and then manually refreshing to see the results -- that's a kind of lousy user experience. If that's a bad assumption, and there IS feedback (e.g. a spinner), then your best option will be to conditionally wait for the spinner to appear and then disappear, and then refresh a single time.
If there's really no visible feedback, then you still have a couple of options:
Easy: Hardcode a sleep that's longer than the operation will ever take to complete, and refresh once.
Medium: In a loop, sleep for a constant delay, refresh, repeat until some timeout.
Hard: If the delay required varies widely (sometimes seconds, sometimes minutes), you might consider an exponential back off solution, that sleeps for increasingly longer delays each iteration, before ultimately timing out. The upside is that you're not frantically refreshing dozens of times, the downside is that your delay might be unnecessarily long, if the content arrives just after the next big delay begins.
You can use wait method for the element to be available.
If you need to refresh the page continuously just make sure to wait after each refresh.

Comment Box update time

I have an app wherein i have a comments box. Everything is working fine. However there is a small thing that is bugging me. I am using React and set the update Interval to 2 sec. So every 2 sec, a REST call is made which will return a new comment or no comment (i do this by sending last updated timestamp in the API call). However this rest call, is still returning 200 B, when empty. now on its own this size is minimal. But if a user stays on the page for 10 minutes, even with no new comments, he would download 10*60/2*200 B ~ 60000 B ~ 60 KB.
Is this considered appropriate or should i look into other solutions?
I would use a websocket.
You can then poll your comments-source for changes from the server with no need to involve the browser. Only if you detect new comments on the server would you then broadcast an appropriate socket event with the payload. All listening clients would then update their comments only when required.
In this way you avoid any overhead, either the server load caused by creating and destroying the http connections, or client load receiving 'empty' payloads.

Extend Store class to always execute a function after load on ExtJS

I am working on a project where we were asked to "patch" (they don't want a lot of time spent on development as they soon will replace the system) a system implemented under ExtJS 4.1.0.
That system is used under a very slow and non-stable network connection. So sometimes the stores don't get the expected data.
First two things that come to my mind as patches are:
1. Every time a store is loaded for the first time, wait 5 seconds and try again. Most times, a page refresh fix the problem of stores not loading.
Somehow, check detect that no data was received after loading a store and, try to get it again.
This patches should be executed only once to avoid infinite loops or unnecessary recursivity, given that it's ok that some times, it's ok that stores don't get any data back.
I don't like this kind of solutions but it was requested by the client.
This link should help with your question.
One of the posters suggests adding the below in an overrides.js file which is loaded in between the ExtJs source code and your applications code.
Ext.util.Observable.observe(Ext.data.Connection);
Ext.data.Connection.on('requestexception', function(dataconn, response, options){
if (response.responseText != null) {
window.document.body.innerHTML = response.responseText;
}
});
Using this example, on any error instead of echoing the error in the example you could log the error details for debugging later and try to load again. I would suggest adding some additional logic into this so that it will only retry a certain number of times otherwise it could run indefinitely while the browser window is open and more than likely crash the browser and put additional load on your server.
Obviously the root cause of the issue is not the code itself, rather your slow connection. I'd try to address this issue rather than any other.

Random Popups While Automating the Webpage

I was attending an interview and he gave me the following scenarios . If I could get an hint as I could not answer the questions.
Assume that there is an application and popups keep coming up all the time. These are not times, its just random. You never know when they are going to come. How to deal with it?
Assume that the script you wrote is fine. But due to network issues the objects in the page are really slow to load or the page itself is taking long time. How do you deal with such a scenario?
Assume that I have 5-6 pages in the application. In all the pages we have certain text fields. In page 1 and Page 5 there is an object which is a text box. I see that what ever whatever identification method (css, xpath, id etc) you take, the values are same. That is duplicates. How do you deal with this scenario?
What is the basic purpose of "data provider" annotation in TestNG. In genral, what is the purpose of testng annotations?
Thanks.
Assume that the script you wrote is fine. But due to network issues the objects in the page are really slow to load or the page itself is taking long time.
How do you deal with such a scenario. In such situation, You should Wait property of Selenium. Implicit Wait or Explicit wait.
Implicit Wait -- Used for setting Timeout for Webpage loading
Driverobject.manage().timeouts().PageLoadtimeOut(units,TimeUnit.SECONDS);
Explicit Wait-- Used for setting Timeout for particular
Webelement FirefoxDriver f = new FirefoxDriver();
WebDriverWait ww = new WebDriverWait(f,Units);
ww.until(ExpectedConditions.CONDITION);
For second question, Anubhav has answered it.
For third, even if elements are same for the page1 and page5, they can be differentiated. First, switch to page to, whose text field you want to interact with, and then interact with that text field.
For forth, dataprovider is an annotation in TestNG using which you can do data driven testing and using TestNG annotations, you can manage test execution flow of your tests. For more details of dataprovider and TestNG annotation, please go here
For third, If you open 5-6 the pages in different tabs of single browser you will get such a duplication problem. That time only one page is visible to the end user. So we can differentiate that element by visibility and can interact with that element using webdriver
List<WebElement> el=driver.findElements(By.xpath("xpath of that text element"));//you can use other than xpath too to identify the elements
for(int i=0;i<el.size();i++)
{
if(el.get(i).isDisplayed())
el.get(i).sendKeys("text you want to send");//any other action you want to perform
break;
}

How to make my U_store.load() waiting infinitely in extjs

how to make my U_store.load() waiting infinitely
var U_store = new Ext.data.JsonStore({
id:'jfields',
totalProperty:'totalcount',
root:'rows',
url: 'first-utility/index_json.php',
});
my index_json.php returns result in 10 min but the load() in extjs does not wait so much it return immediately , can somebody help me how to get result from index_json.php ??
Your users are going to wait 10 mins for data to load?
You'd probably be better off with a solution based on periodic polling rather than "infinte" waiting. Maybe the initial call starts your long process and you have a separate call that checks for the results? Without knowing what you're doing it's hard to know what the best approach is.
Why don't you gather all information and save it in the database/file by a separate process and then you can easily load store from database data.
In fact if it takes 10 minutes to load the data then I think it should be a huge amount of data. If possible then you can go for partial loading of data depending on the client events/actions.
To answer his question as asked, I'd try to use the Ext.Ajax object since you can define a timeout on there.
On the success of the Ajax you can take the response object and create the data store using something like :
var myResponseData = response.responseText;
myStore.loadData(myResponseData);
The drawback to going this route is that you cannot use to Ext.Ajax again while it is processing the query since it is a static member.
It might take some tweaking but I hope the basic idea is sound. If anyone sees a problem with this idea, I'd like to know. This has me thinkin'

Resources