Eugene,
How do you want this to work ?
If this is what you want, then you should be building your own custom proxy and embed your logic of clean-up as part of afterSession() so that it gets executed after driver.quit() is executed but before the session is released by the Grid. You need to ensure that you don’t trigger any exceptions here. Please refer to this article that I wrote up on grid to help you understand how to work with custom proxies.
(or)
If this is what you want, then
First you should build a servlet which when invoked can do the cleanup for you. You just inject this servlet into the node. To learn how to do this, please refer to this article of mine.
just before calling driver.quit() you should do the following :
Now after you call driver.quit(), trigger a http operation (GET/POST) to the servlet that you added to the node, by making use of the IP and port address that you obtained from above.
Thanks & Regards
Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/51bf13f1-923c-4a32-b8b3-3b5ec9fb2cec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Eugene,
Am glad that my articles on the Grid helped you out ☺ That was the intent behind creating ‘em ☺
>>> I followed the example in your article to create the ListProxiesServlet and got it working fine but I am thinking about integrating some more functionality into the existing grid console. For example, I'd like to add restart button next to each node on the console page view or a form that will allow me to push node configuration changes. What would be the approach to something like this?
For getting this done, you would need the following:
Sometime back, I blogged about the salient features of a self healing grid in this blog post of mine : https://rationaleemotions.wordpress.com/2013/01/28/building-a-self-maintaining-grid-environment/
The self-healing capabilities were added to the SeLion grid, when I worked on it a long time back. So you may want to start off with the SeLion grid (so that you get the self healing capabilities out of the box) and add your customizations on top of it. Even if you don’t use the SeLion Grid’s startup/shutdown mechanism, I would strongly urge you to leverage its proxy (which contains this capability of stopping new sessions, waiting for sessions to run to completion, triggering shutdown, the watchdog capability etc.,)
Hope that helps!
Thanks & Regards
Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/97f9fae1-8eea-4a05-b2b4-5e1b148d36e2%40googlegroups.com.
Eugene,
Comments inline.
Thanks & Regards
Krishnan Mahadevan
"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/
From: <seleniu...@googlegroups.com> on behalf of Eugene S <shrag...@gmail.com>
Reply-To: <seleniu...@googlegroups.com>
Date: Monday, December 11, 2017 at 7:23 AM
To: Selenium Users <seleniu...@googlegroups.com>
Subject: Re: [selenium-users] A way to manipulate node system conditions after each test on grid
Hi Krishnan and thanks again for you elaborate explanations. It is very much appreciated.
>>> A Custom servlet injected at the hub end, which can serve as your new console.
I assume that such servlet will need to return an html page similar to original grid console but with my amendments (buttons and such..). Does that mean that effectively I will need to recreate the console page from scratch? Is this why you suggest the other option with "classpath overriding"?
[Krishnan] Yes you would need to recreate the console page from scratch if you would need your new functionality plus the existing functionality of the Grid’s inbuilt console page. Yes that is why I was suggesting the “classpath overriding” approach.
>>>The other option is basically to resort to what I call as CLASSPATH overriding
If I understand correctly, in this case too, I will be able to reuse the original console page and amend it according to my requirements?
And if I create another class with similar names, how do I make sure that mine is being used and not the original one? If I have both of them in my classpath, won't they have a name clash?
[Krishnan] I was wondering when you would ask this question ☺ Well, the idea here is that you put your jar ahead of selenium’s jar. Java basically runs through your classpath in a sequential manner, loading all classes in the current jar before it moves on to the next one. So lets say you have your overridden version of the console residing in “myconsole.jar”, then you would be starting the Hub using the java command : java -cp myconsole.jar:selenium-server-standalone-3.8.1.jar org.openqa.grid.selenium.GridLauncherV3 -role hub
As you can see, the class part is avoided, by ensuring that your version of the class is found by Java first, ahead of what resides in the Selenium jar. Java doesnot reload the same class again, if it finds two or more variants of the same class. Its always “first come, first serve” basis. If you want to get past all of ths confusion then you can easily build your own uber jar (jar of jars) and then use that. This uber jar would contain your overridden console and would shadow out the selenium provided console.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/f06c89b6-1eda-4356-851d-2f6f1cae6312%40googlegroups.com.
...
Thanks again Krishnan, as always - super helpful!I was going through the SeLion code trying to understand how can I utilize parts of it for my purposes as you suggested and I have few questions I hope you might be able to help me with:
- As far as I understand, the SeLion grid standalone jar is designed to be the main entry point so that we do not call the SeLion jar and Selenium standalone server jar separately from command line like we do for a single servlet (like this: java -cp some-servlet.jar;selenium-server-standalone=X.X.X.jar). Instead, SeLion starts Selenium internally by itself. Is that so?
- If the above is correct, should I follow the same principle for my purposes or keep a separate jar as in your examples with a single servlet?(when you include the servlet jar and selenium server standalone jar in command line) In such case, how should I go if I have multiple servlets? Just include all of them in command line command (like this: java -cp servlet1.jar;servlet2.jar;...;servletN.jar;selenium-standalone-server-X.X.X.jar) or there is a preferred way?
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/e9f637d6-c8c3-4d64-940e-86faf8d21480%40googlegroups.com.
...
JarSpawner.main(new String[] {"-role", "hub"})
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-users+unsubscribe@googlegroups.com.
To post to this group, send email to selenium-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/b32024fb-d283-47d0-9401-4db49a5e0f8e%40googlegroups.com.
...