Selenium script stopes after some time - java

I have a selenium script that runs fine but when I am executing the same script in loop it stops after some time (1 to 2 hours).
Following is the error:
INFO: ERROR in Record- session d5609515-432f-4b01-b93d-b3b5571e009d does not exist
Kindly help me.

It's seems that in that process you have time that the page not changing and the session expires, for example in bank account's sites if there is no action on page it will kill your session after x seconds.
keep always focus on the website even if you processing other thing's
Exception: ERROR in Record- session
d5609515-432f-4b01-b93d-b3b5571e009d does not exist
tells you that you trying to use driver for any propose with session identification that not exist expired, for what i know it's session timeout
one more important thing if you have to do your script for (1 to 2 hours) you need to think about ways to split it for better results, it's internet and it's not always stable.
Session Has Expired error on the Internet
ErrorWhen browsing a website that is database driven, requires a
login, or is secured, you may see a "Session Expired" or "Session Has
Expired" error. The causes of these error messages are detailed in the
following sections.
Inactivity - If you have not been doing anything on the page for a set length of time (often 10-30min) the server will time out your
session. This is often done for security reasons and to help increase
the overall speed of the web page. In other words if you were browsing
the page and get up and leave, go to lunch, or start browsing other
pages when you come back you need to re-login and create a new
session.
Date or time not correct - Make sure the date and time are properly set on your computer.
Cookies - If you are browsing anonymously or your browser does not have cookies enabled it causes many sessions to fail. Make sure your
Internet cookies are enabled.
Firewall or proxy - If you are connecting to the Internet behind a firewall or through a proxy the firewall or proxy may be restricting
or prohibiting the session from being established.
Other site related issue - If this issue is only occurring on a certain site and you're not encountering any of the above-related
issues it's possible that it could be the site encountering an issue.
Contact the company or Webmaster to verify the problem is not on their
end.

Related

Spring Boot App losing session data in chrome

Whenever I use google chrome to hit my application, almost any requests that I make are not hitting the rest service. However, I can login and hit the rest service, the problem is once I get to the home page, any requests after the initial login all fail. Instead it seems like the session is becoming invalidated. I checked some other stack overflow threads and saw this may have to do with a 302 error occurring when the browser is trying to load the favicon.ico. I can see in the network tab of my developer tools that this is infact getting a 302. I am unsure if this is the actual issue and or is there is another issue.

What is an active session in a Java web application?

What are "active sessions" in tomcat? I am trying to monitor active sessions for a Java web application. But the values I am getting are not matching with number of people using web application. Could you please explain?
Basically the number of active sessions is the number of existing or previous browser or other connections with an unique jSESSIONID cookie value. As soon as someone hits your webpage with a browser a new session is initiated and an unique JSESSIONID is assigned to this session. If next hit is performed with the same JSESSIONID (which is transmitted as cookie or url parameter) the session count remains the same. If the parameter is not transmitted a new session is created.
Usually all browsers keep the session id cookie over multiple requests and even multiple tabs or windows (except for incognito tabs/windows of course).
There are multiple reasons why your session count is larger than you user count.
Sessions are held in tomcat for a period of time, with 2 hours being the default. You can change this amount in tomcat settings. So if 100 user logins into your application in first hour, and 100 in second, your total session count will be 200, even if the first 100 users are idle.
Robots like the google bot tend to create tons of sessions. If your page is publicly available check the access logs if there are some bots visiting your page.
If your application is behind the loadbalancer or proxy which are continuously 'pinging' your application for its availability, this pings can create sessions as well.
Finally there are a lot of 'funny' ways your app can get requests from browsers, for example search results prefetching and similar.
Also keep in mind that session is bound to the domain name of the site. So if a user connects to your site via multiple domains (for example www.domain.com for content and static.domain.com for images) each of the connections will have its own session.
Now, there are different way to prevent unneeded session creation, depending on what your exact problem is (and if it is a problem at all).
If you have parts of your application that don't require a session ensure that you don't call request.getSession() somewhere in your code. Also in the jsp you can explicitly turn off session with <%# page session="false" %>
The the session timeout lower to make them expire quicker in tomcat/conf/web.xml <session-config><session-timeout>30</session-timeout></session-config>
The session-timeout value is in minutes.
Finally if you are interested in what is really happening in your application, get yourself an APM (application performance management) tool like MoSKito

jsessionid is saved and used even after reboot\re-installation of the service

I have a Tomcat 7 web server.
After login to it I can see under Cookies that there is jsessionid which, from what I have read is saving the id of the session instance between the user and the web server.
But the thing I cannot understand is that after I login and I stay in the browser.
I can stop the server, even un install it from the system and re-install it.
and then after I restart it I can continue navigating in the website without needing to enter credentials or anything like that, as if nothing happened in the background - I just can move on with the same jesssionId.
So basically I will divide my question into sub-question so it will be easier to answer:
1. How is it even possible that after stopping the service or even un install it it can still happen?
2. How excatly is the jesessionID created? I mean is it possible that it is the same jsession id?
3.When exactly does the jsessionID is being created?
4. Is it possible to change this behavior and "invalidate" the session so the user will have to re-enter his credentials?
5. Following question #4, what is common in most of the services? demand to login again or to enable the use of the old session id ?
Thanks a lot!
In answer to your questions:
Tomcat's session Manager will serialize session data and save it to a file to persist it across restarts. You can disable this.
Tomcat's SessionId Generator determines the exact way the id is created.
Here a good answer for when session ids are created: Under what conditions is a JSESSIONID created?
If your goal is to invalidate sessions after a Tomcat restart, you can do this by disabling session persistence.
Typically a user would want to be considered "logged in" until they click a "log out" link or button in your application. You can also adjust the session expiration time if you want the session to expire after a period of inactivity. How exactly this should work is up to you and depends on your application's use cases.

How to remove cookies in servlets on window close or while application re-run is happening

As the title said, I want to remove the cookies when I close a window. I know of the methods for cookies like Cookies.removeCookie(Constants.XXX); And also of cookie.setMaxAge(0);
for removing cookies. But that is done on clicking logout.
I want to remove cookies on window close or when application has stopped running. Because whenever, I am debugging the application, whenever I rerun the application, I see the cookie is still there even though I am not logged in, and the session has not started for the user. So there is a conflict, where the cookie is already set even though, the user has still not logged in !
Its a GWT Application.
First of all, it's important to differentiate between a cookie on the client side, and a session on the server side (I think you already knew that).
Usually, for a clean logout, you'll want to call session.invalidate() on the servers side, and Cookies.removeCookie(...) on the client side.
But not every 'logout' is clean:
The logout request may not make it to the server
The browser may crash even before you call removeCookie - so any attempt to remove a cookie on window close will be unreliable
On the server side, you can use timeouts (see the link provided by #thinksteep: How we call logout servlet on browser close event).
For the client side cookie, you can set an expiryDate/maxAge. Or you can use "session cookies": These are the cookies where you don't set expiry or maxAge at all. Most browsers will delete "session cookies" automatically when the browser restarts - but please see Firefox session cookies.
All of this may mean, that cookies are maybe not the best technology for your use case: In general, a cookie is by design available in all browser tabs, and the concept of a browser session doesn't even always end, when the browser/window closes (what would it mean on a smartphone anyway?). This is desirable for many current web sites (users don't have to log in explicitly every time), and many users have come to expect this kind of behavior.
For sites that want a "one tab = one session" policy, it's possibly better to store a token e.g. in a Javascript (or GWT) object, and send it with every request. This way, you can log in separately - even as different users - from multiple browser tabs, and once a tab closes, the token is gone. Please note, that a tab may still get restored by the browser on session restore. (I would always combine this technique with a httponly cookie, to avoid certain kinds of attacks.)

IE8 losing session details

I have a Java web app that intermittently loses session data. The problem only occurs with users on IE8. I have used IEWatch to monitor the http traffic, and it seems that the correct session cookies are being sent (JSESSIONID2).
When the request gets to the server the session has become unbound from the custom session monitor (this uses HttpBindingListener).
As I have mentioned this problem is intermittent and I have even gone through a transaction with the customer doing exactly the same thing on my machine - however I was unable to replicate their problem. It should also be noted that the transaction fails at the same point every time for all users experiencing this - it one the second page of a 4 page wizard type transaction.
Any help will be gratefully received.
Nige
Yep, I did find the problem.
I use DWR for AJAX stuff and there is an issue with DWRUtil.useLoadingMessage().
See http://directwebremoting.org/dwr/browser/util/useLoadingMessage.html
So this caused an execption, which went to an error page (jsp) which had an invalidate session statement on it.
Took me bloody ages to find it.
I hope this helps you, but I somehow doubt it :)
Nige

Categories