I am looking for a way I can ensure certain things happen after each test on a Selenium Grid node. (E.g. controlling certain processes on the node)
What is the best way to do on Selenium Grid? Perhaps I don't need to reinvent the wheel and there is some way I can use Selenium Grid infrastructure to determine when a test has finished on a node programatically?
You can do this in two ways
For achieving this you should be building your own custom proxy (by extending org.openqa.grid.selenium.proxy.DefaultRemoteProxy
) 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
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.