I have browsed through internet but did not get any appropriate solution. My query here is, my selenium script takes long time to execute as application is large, cause of which session of application is getting expired and it logout form the application. I have tried tried with the following javascript code in @BeforeMethod in testng but still no luck,
public void keepSessionAlive()
{
((JavascriptExecutor)Driver.driver).executeScript("checkActivity(1200000, 60000, 0);"+
"function checkActivity(timeout, interval, elapsed) "
+ "{"+
"if ($.active) "
+ "{"+
"elapsed = 0;"+
"$.active = false;"+
"$.get('app/heartbeat');"
+ "}"+
"if (elapsed < timeout) "
+ "{"+
"elapsed += interval;"+
"setTimeout(function() "
+ "{"+
"checkActivity(timeout, interval, elapsed);"+
"}, "
+ "interval);"+
"} "
+ "else "
+ "{"+
"window.location = 'timeout';"+
"}"+
"};");
}
Aucun commentaire:
Enregistrer un commentaire