alright, I'm full of questions today!
Just read this in the Selenium RC Tutorial.
"If your test needs to use multiple domains (HTTP and HTTPS in the same test), your best choices are the *chrome or *iehta browser launchers, alternatively you can use proxy injection mode."
What's proxy injection mode"?
Hi,
If you are starting selenium server through multiWIndow mode or interactive mode then it will make your proxy setting by automatically, But If you are staring through proxyInjectionMode then you can set your own proxy setting....
Thanks
Ashok N
thanks for responding Ashok.
so what your saying is....
when starting up Sel-RC I can pass in "*proxyInjectionMode" instead of "*firefox" or "*iehta" (for example)?
But I still don't know what proxy injection mode is or why I'd want to use it. What are the "proxy settings" you speak of? Are these documented somewhere?
Not having used PI mode much, here's my understanding (anyone please correct me if I'm wrong!):
In non-PI mode, there is NO proxy between the browser and the AUT. Requests and responses are exchanged directly between them. The Selenium server is basically responsible for launching the Selenium-instrumented browser window, and the Selenium frame/window communicates with the RC. This frame/window has a reference to the "normal" browser window and thus controls test execution.
Browser <=> WebApp
In PI mode, the Selenium server sits between the browser and the AUT. As such, it can intercept and manipulate the exchange on the request / response level. One thing this makes possible is injecting arbitrary markup / scripting into any part of the response data, so we can inject javascript into the <head> element that runs before the rest of the page starts to load. This isn't possible in non-PI mode. Because we have this ability in PI mode, we don't even need a separate frame/window for Selenium - it's injected directly into the AUT. This does introduce a greater possibility of javascript variable namespacing issues, however.
Browser <=> Selenium server as proxy <=> WebApp
PI mode also allows you to work around the same origin policy. I believe that is one of the reasons it was first implemented.
Haw-Bin
Haw-Bin,
Thanks much for that description. It's pretty helpful. Get's me farther at least. That generates a couple more questions though....
PS. I'll suggest the documentation thread that we develop an architecture diagram. I'd do it myself but don't feel knowledgeable enough yet for that one.
Paul,
Yet more good questions ... you're forcing me to go digging for the answers myself, which is good. ![]()
1) I don't believe HTA and chrome modes involve a proxy between the browser and AUT. They are able to circumvent the same origin policy because they are running with elevated privileges. HTA, or "HTML Application", is really an HTML file that is opened locally, and as such can access the filesystem and basically act like a desktop application, thus escaping the browser sandbox ... and the same origin policy. Chrome is an elevated privilege mode for Firefox that is accessed via "chrome URL's", i.e. URL's that start with "chrome://" . Firefox plugins, for example, are accessed via chrome URL's, and are able to use the Firefox API's for accessing / modifying the filesystem and again basically acting like a full fledged application. With these two privileged modes, it's not necessary to have a proxy.
2) If you run the Selenium server with an invalid argument, it will print out a help message. This will give you an idea of the ways in which proxy injection can be useful:
...
-proxyInjectionMode: puts you into proxy injection mode, a mode
where the selenium server acts as a proxy server for all content
going to the test application. Under this mode, multiple domains
can be visited, and the following additional flags are supported:
-dontInjectRegex <regex>: an optional regular expression that
proxy injection mode can use to know when to bypss injection
-userJsInjection <file>: specifies a JavaScript file which will
then be injected into all pages
-userContentTransformation <regex> <replacement>: a regular
expression which is matched against all test HTML content; the
second is a string which will replace matches. These flags can
be used any number of times. A simple example of how this could
be useful: if you add "-userContentTransformation https http"
then all "https" strings in the HTML of the test application will
be changed to be "http".
...
Apart from rewriting HTTPS URL's as HTTP, another example use of for proxy injection is capture javascript errors that happen on the page, by redefining window.onerror . Normally, you are not able to catch any javascript errors that happen on the page during page load. However, because PI mode allows you to inject script content before the page content, the redefinition of onerror will happen in time to catch the errors.
One note about the -userJsInjection flag - the entire content of the file you specify will be included before the <html> element on the page, and will not be automatically placed in a <script> block. Thus, the content of the injected file should probably be something like:
<script>
// my customizations
window.error = function() { return true; }
...
</script>
And also remember that when using PI mode, you need to specify a PI browser, i.e. *piiexplore .
I actually find PI mode the best mode for IE testing and would be a real step forward for RC if it was the IE standard.....at least I would if it worked as intended.
Advantage over normal IE multiwindow is speed as there is no RPC overhead.
Advantage over IEHTA is that you get a real IE instance and thus don't run into these pesky js error popups.
However I find (at least with my AUT) that it breaks styles, font and font sizes are wrong, formatting is all over the place and it completely breaks some functionality all together. I suspect this is the reason for its poor adoption.
guys, thanks much for your responses. It's very helpful. I only had a chance to quickly read through this today but I may have more questions later.
We'll probably rewrite this thread and include your 'knowledge' in the documentation effort at some point.
thanks much!
