Re: [selenium-users] Clean internet explorer cache between tests

361 views
Skip to first unread message

Krishnan Mahadevan

unread,
Aug 29, 2012, 6:32:35 AM8/29/12
to seleniu...@googlegroups.com
Fil,

Here's what I know [based on my limited explorations of the codebase]

InternetExplorer driver relies on the iedriver.dll/IEDriver.exe to find the iexplore binary and this seems to find the binary on its own and there seems to be no way in which you can specify an alternative location/batch file to launch IE. FirefoxDriver on the other hand does have this mechanism in place [as specified here : http://code.google.com/p/selenium/wiki/Grid2#Configuring_the_nodes]

I believe this was done intentionally because on a given machine only 1 installation of IE is expected to be available. 

RemoteWebDriver would inturn rely on the native implementation that dwells within each of these concrete implementations of WebDrivers to spawn the respective browser and start the embedded server within it.

All that said and done, you can still get this to be done, if you use the features of the Grid.

The Grid provides you with a facility wherein you can inject your own Proxy [org.openqa.grid.selenium.proxy.DefaultRemoteProxy]

So here's what you would do.

Extend org.openqa.grid.selenium.proxy.DefaultRemoteProxy and create your own concrete version of a Proxy. You can take a look at this gist that I created  : https://gist.github.com/3303591

Now within this custom proxy, you would basically need to override beforeSession() method [ This method should get called before a the node gets the request for a new session which essentially means that you are going to start a new test]

@Override
public void beforeSession(TestSession session) {
String requestedBrowser = (String) session.getRequestedCapabilities().get(CapabilityType.BROWSER_NAME);
if (requestedBrowser.equalsIgnoreCase("internet explorer")) {
try {
Runtime.getRuntime().exec("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
   super.beforeSession(session);
}

Now to consume this you have two options :

Convert this project into a jar and then use :

java -cp "selenium-standalone-.2.25.0.jar;myproxy.jar" org.openqa.grid.selenium.GridLauncher -role node -hub http://localhost:4444/grid/register -port 5555 -proxy org.mycompany.MyProxy

Or you could convert your project into a gigantic jar [embedding all of the selenium libraries into it] and then merely use

java -jar myproxy.jar -role node -hub http://localhost:4444/grid/register -port 5555 -proxy org.mycompany.MyProxy

That should get your requirement done.

P.S: I haven't had the time to test this implementation. I am telling you things based on my past explorations. So incase there are glitches, please do revert back and I will try to see what was missing. If it works, then also please do update this thread so that it can be helpful for others who are treading the same route as you.

Hope that helps !

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



On Wed, Aug 29, 2012 at 2:14 PM, filmac <fma...@venere.com> wrote:
Hi all!
We're launching selenium tests using php against a selenium hub.
We are using phpunit 3.6 and selenium nodes are running version  2.25
We have some node configured to provide iexplore and since we use cookie a lot, we would like to clean cache between tests.
I tried to use deleteCookie and deleteAllVisibleCookies but with explorer they didn't work as expected.
I found that it's possible to run the following command:

RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255

in order to clean the cache and I would like to create a bat file in order to run this command and launch explorer soon after.
But I have two doubts:
  1. how I change node configuration to launch explorer using my own bat file? I guess I need to define a *custom browser but I don't understand how to specify this in the json configuration of the node
  2. how do I bind a test to the particular custom node configuration?

Thanks

Fil

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/iHCLXtj73PYJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

filmac

unread,
Aug 29, 2012, 9:05:44 AM8/29/12
to seleniu...@googlegroups.com
Hi Krishnan,
thanks for your suggestion,
I created a custom proxy class as you described, and I added the new jar to the node configuration but when I tried to start the node we have an exception since it looks like the new proxy class is needed to the hub process too.
But...my question is, since for our configuration hub and nodes are hosted by five different machines, where is the custom proxy code run?
I hope the proxy is run on the node machine...
Thanks
Filippo

filmac

unread,
Aug 29, 2012, 10:04:41 AM8/29/12
to seleniu...@googlegroups.com
Hi Krishnan,
unfortunately I deployed the jar on the hub node to (linux hosted) and the proxy is triggered on this machine while I need to trigger something locally on the node machine that is windows hosted and that's where the internet explorer cache is stored, any hints?
thanks
Fil

Narender Kumar

unread,
Nov 13, 2019, 6:22:23 AM11/13/19
to Selenium Users
Hi Krishnan, Fil,

I am also trying to run the custom code ( which I have written in the beforeSession and afterSession methods of my custom proxy class) on the node machine.
were you able to find any way to run the custom code on the node machine?

Thanks,
Narender

⇜Krishnan Mahadevan⇝

unread,
Nov 13, 2019, 7:08:00 AM11/13/19
to Selenium Users
You revived a really really old thread. I believe a lot of things have changed.
I think there must be some flags/switches that you can pass as IE options which will help you clear the cache.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c4204166-3b3f-4469-a57a-c11c2ef916e3%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages