In other posts I have experienced some issues with record and playback of an app and I was told that viewstate could be something that I should look into regarding this issue.
I have a chunk of code here that is working during replay (not the same app though), but the point I am making is the same:
web_submit_data("overview.jsf",
"Action=https://wasapp-q1.adeo.no/some/sa/overview.jsf?execution=e4s1",
"Method=POST",
"TargetFrame=",
"RecContentType=text/html",
"Referer=https://wasapp-q1.adeo.no/some/sa/overview.jsf?execution=e4s1",
"Snapshot=t4.inf",
"Mode=HTML",
ITEMDATA,
"Name=overviewSearchForm:searchCriteriaId", "Value=01024531232", ENDITEM,
"Name=overviewSearchForm:j_id111", "Value=Get ", ENDITEM,
"Name=overviewSearchForm_SUBMIT", "Value=1", ENDITEM,
"Name=javax.faces.ViewState", "Value=cxeGmdwmyti6LtCKFbfHsLGYkE6QJ+eGozLlfTsidCNXrT2KqQ+JviDhkv7MCtdmlnxzQZVOMo9uO9ZrjUUdfpfFJMwwRfg/A09/Em5tTUJxNZ6fUe5LGK9oitXNeeBh0M5Yd7nwXn5uj1bLQzluR09kUUA2dnwrXajncw==", ENDITEM,
LAST);
This chunk of code is not working:
web_submit_data("hello_world_2",
"Action=http://d26jbsl00003.test.local:8080/wow/behold/83512/considervilkar?5-1.IBehaviorListener.0-vurdereVilkarListe-vurdereVilkarRepeater-4-considerVilkarListItem-considerHoved-innerPanel-vilkarDetaljer-vilkarForm-vilkarsregelValg",
"Method=POST",
"TargetFrame=",
"RecContentType=text/xml",
"Referer=http://d26jbsl00003.test.local:8080/vedtak/behandling/83512/vurderevilkar?5",
"Snapshot=t4.inf",
"Mode=HTML",
ITEMDATA,
"Name=vilkarsregelValg", "Value=OPPFYLT", ENDITEM,
LAST);
Both code chunks call web_submit_data. Assuming that Viewstate has something to do with the replay issue of the last one, what does:
"Name=javax.faces.ViewState", "Value=cxeGmdwmyti6LtCKFbfHsLGYkE6QJ+eGozLlfTsidCNXrT2KqQ+JviDhkv7MCtdmlnxzQZVOMo9uO9ZrjUUdfpfFJMwwRfg/A09/Em5tTUJxNZ6fUe5LGK9oitXNeeBh0M5Yd7nwXn5uj1bLQzluR09kUUA2dnwrXajncw==",
actually mean in LoadRunner context? Could it have something to do with my second chunk of code not working (not having a Viewstate)?
State is something which changes with every request. So, ViewState is something you will need to correlate for almost every request (when it is present). There is also jsessionstate that shows up on Java apps, ViewState is typically associated with ASP and ASP.Net
Try using AJAX Truclient, this will help you alot.
No correlations needed there.
Viewstate is a value which changes with every login .It is a 64 bit encoded value returned by the server upon login.
you can try correlating the value ,from the response of the previous request.
Related
I'm using Martin Wendt's Dynatree and want to update the tree in Ajax, dynamically and recursively.
For this, I'm using functions like tree.getNodeByKey(nodes[i-1]).appendAjax({});
and tree.activateKey(nodes[i]); in a for loop.
When adding alert("Hello world"); into the loop, my code works correctly 95% or the time. Without it, the code never works.
The problem is obviously coming from the fact that Dynatree is performing its Ajax requests in asynchronous mode, and seem ignoring the async:false, when added to .initAjax and/or .appendAjax:
jQuery('#tree').dynatree("getTree").getNodeByKey(nodes[i-1]).appendAjax({
type: 'POST',
url: "inc/treeNodes.php",
dataType: 'json',
data: {key: nodes[i]},
async:false
});
I tried adding setTimeout (function() {},2000); around the call to .appendAjax, but it prevented this method to work.
Could Dynatree be modified to support asynchronous mode?
Although it does not truly answer the question of running Dynatree in synchronous mode, I found a workaround that almost emulates an Ajax synchronous behavior.
Edit: the following workaround seems working reasonably well on localhost, but not if the site is remote.
Before important calls to Dynatree's method, add a setTimeOut() call at the end of which something will be written to the console.
for (i=1; i < n; i++) {
(...)
setTimeout(function(){console.log('_')}, 3000);
jQuery('#tree').dynatree("getTree").getNodeByKey(nodes[i-1]).appendAjax({...});
(...)
}
The setTimeout does not slower the code as much as the delay would suggest.
For instance, if the loop has three iterations, you don't have to wait 9 seconds (3x 3000) before the work done by all three appendAjax calls complete.
I assume that .appendAjax() calls are performed whilst setTimeout is still running, but the later seem having some magic effect on the document window.
Using setTimeout and trigger console.log() has similar effect as inserting alert(); calls, but is "silent" for the visitor.
I'm using this code to talk to a stock GSM modem... (Telit/Simcom etc)
// ------------------------------
sprintf(localbuf, "AT+CMGS=\"%s\"\r", recipient);
Serial1.write(localbuf); // initiate the SMS conversation
if (waitFor(5000, "> ", "ERR")) {
sprintf(localbuf, "%s%c", textMessage, CTRL_Z);
Serial1.write(localbuf); // send the message body
//... I wait for the +CMGS: response here - all good
} else {
Serial.write("\r\n-- SMS >PROMPT FAIL --");
retval = false;
}
... and move on
The first message - no problem - it works fine.
If I do other things and come back to send another - no problem.
Including other modem conversations (CSQ, CCLK etc)
But if I try to send more than one message fairly close together (in a loose loop), the second +CMGS request fails to return the '>' prompt... ?
Any thoughts.
Thanks in advance
SOLVED - Well - so far so good (SFSG?)
I discovered that if I hold-off for a second AFTER the final CMGS:... .OK is received - the following messages work as expected.
So I guess that 'OK' really isn't OK (!), no matter what testing or polling I had tried earlier - the modem simply isn't ready until it's ready.
Thanks for reading. I hope this helps someone else.
EDIT: The data sheet quotes 20mS between sequential commands, but it's more like 200mS inworst cases...
I try to make a login on facebook with Loadrunner Script, but I get always this:
vuser_init.c(41): Continuing after Error -26612: HTTP Status-Code=500(Internal Server Error) for "https://www.facebook.com/".
This is my request Script (Function):
web_submit_data("login.php",
"Action=https://www.facebook.com/login.php?login_attempt=1",
"Method=POST",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=https://www.facebook.com/",
"Snapshot=t30.inf",
"Mode=HTML",
ITEMDATA,
"Name=lsd", "Value=AVpPvlAG", ENDITEM,
"Name=email", "Value={FACEBOOK_LOGIN}", ENDITEM,
"Name=pass", "Value={FACEBOOK_PASSWORD}", ENDITEM,
"Name=default_persistent", "Value=0", ENDITEM,
"Name=timezone", "Value=-60", ENDITEM,
"Name=lgnrnd", "Value=013117_8ain", ENDITEM,
"Name=lgnjs", "Value=1392111088", ENDITEM,
"Name=locale", "Value=de_DE", ENDITEM,
EXTRARES,
LAST);
any help would be appreciated.
You don't test third parties without the express written permission of those who own, manage, and control the servers plus the commissioner of baseball. To do otherwise is to engage in a denial of services attack. Facebook has a very capable performance engineering team and they do not need your uncontrolled inputs onto their system
Use the sample applications for learning or any LAMP, WAMP or WISP applications installed on hardware/VMs that you own, manage and control.
The topic of "What causes a 500" and how to recover from it has been covered amply over the past two decades. Take advantage of your research skills to uncover existing lore on this topic.
Bad Magic
I have a function, that uses ajax, that takes really long to complete.
The thing is that I have a lot of files on server, that need to be processed, and the page I'm trying to make is like a status page.
It has a link to start processing, and file counts. It looks like this:
Click here to start process
files 0/500
When I click the link, it runs this function:
function generate_book_link_clicked(){
$.getJSON("/generate_book", function(data){
if (data['last'] == 'true'){
$('#done').fadeIn(200);
}else{
$('#current_count').html(parseInt($('#current_count').text())+1);
$('#generate_book_link').click();
}
});
}
This is the link code:
click me
and this is the code for the counter html (the "<%= #isbn_count.to_s %>" just returns the count):
<span id="current_count">0</span>/<span id="total_count"><%= #isbn_count.to_s %></span>
But what happens is, when ajax completes, it doesn't start the process over again, but the count just starts rapidly adding without ajax calls.
It's like, the first finishes successfully, but then it just starts rapidly adding values to "current_count", and it goes like that forever even over the original count (1000/500)..
I can't figure how to start the process again, currently.
I hope I made everything clear and that someone will be able to help me.
Instead of
$('#generate_book_link').click();
just call your function directly:
generate_book_link_clicked();
Our team has been testing our application with Selenium as it's heavily JavaScript driven we've always had issues with tests occasionally failing. As the number of tests has increased the probability of at least one two tests failing in a complete run has become a certainty.
What we recently figured out is that we probably have a race condition where selenium will click links before the initialization JavaScript has had a chance to attach event handlers to the element that is being clicked. Of course at this point the effects we're looking for don't happen and we get a failing test.
For the time being we've added a slight delay before clicks to give the initialization JavaScript code time to finish, this is obviously a bit hackish, adds time to overall test execution, and doesn't guarantee tests won't still fail so we're looking for a better solution.
The best idea we've come up with so far is to inject a hidden element into the DOM that Selenium can wait for, before firing the click event to know that it's ready. This will be a lot of extra overhead in terms of developer time when we're working our asynchronous events, removing and adding the element. Also it adds extra stuff to our pages that really isn't necessary for the application.
Does anyone have any better strategies? What have you done to effectively solve this problem?
We moved to Selenium 2 (WebDriver) and are using Page Objects pattern with PageFactory/AjaxElementLocatorFactory - an example of this is here
I did exactly like you : add some delay and wait for some elements to be present on the page. And I'm perfectly fine with it. Maybe switching to Webdriver / selenium 2.0 would help though. Test execution can be trimmed down if you work with an in-memory database or sharing the same selenium/selenium server between tests, or even with parallelization (easy with TestNG for instance).
Have you tried the waitForElementPresent command, and then make it click ?
To eliminate race conditions use Selenium's runScript(String initCondition) combined with waitForCondition(String jsConditional, String timeout) methods.
For example, if the AJAX functionality you want to test causes a new element to be added to the dom you can use something like the following.
String jsPoll = "";
jsPoll += "selenium.browserbot.getCurrentWindow()";
jsPoll += ".document.getElementById('DOMID')";
selenium.waitForCondition(jsPoll, "30000");
The condition will evaluate true when the element is added and the method will continue. If your AJAX function swaps elements (ie: one div for another similarly identified div), you can initialize your conditional with something like the following.
String jsInit = "";
jsInit += "!selenium.browserbot.getCurrentWindow()";
jsInit += ".document.getElementById('DOMID').setAttribute('SELENIUMTEST','1')";
String jsPoll = "";
selenium.runScript(jsInit);
jsPoll += "selenium.browserbot.getCurrentWindow()";
jsPoll += ".document.getElementById('DOMID').getAttribute('SELENIUMTEST') != 1";
selenium.waitForCondition(jsPoll, "30000");
The condition evaluates true when the element is swapped out by the AJAX function.