Site Loader
Auckland, New Zealand
We have seen many topics on Selenium ranging from working from Selenium IDE to Creating a data driven framework in Selenium, but let’s turn back our attention on how Selenium actually works. Since we have seen all the magic selenium has did for us by just writing very simple codes. Did we ever thought how selenium opens a browser, the pages and communicates with the pages and perform operations we have specified in the code we have written? Did you ever heard about Selenese? Do you know Selenium server actually understand only Selenese command? Where did your actual code turns into selenese command? Well we are going to discuss all the above questions in this topic of how Selenium works We know there is a Selenium Server (Selenium RC Server), Selenium Client driver (driver specific to languages such as C#, JAVA etc) and we use them in our famous Eclipse IDE for writing code. Once we start running a code from Eclipse IDE following stuffs will happen behind the scenes  
1. The Client driver will first establishes a connection with Selenium server. 2. Selenium Server will do following a. It will create a session for that particular request b. It will launch the desired browser (Specified in the code IE,FF,Chrome etc) c. Loads the Selenium cores Javascript file into the specified browser (So as selenium server will have handle with the webpage for performing Selenese action) 3. Now the Client driver will send the program that we have written in eclipse IDE as selenese (by making conversion) and send it to Selenium server. 4. Selenium server is intelligent enough to understand the selenese command and triggers the corresponding javascript execution in the web browser. 5. Here Selenium Server act as a “Proxy Server” between the AUT (Application under Test) and actual browser, due to the restriction of “Same origin policy” selenium server performs “Proxy Injection”.Being a proxy gives Selenium Server the capability of “lying” about the AUT’s real URL. 6. Now Selenium server requests the actual webserver for the page open request and then it receives the page and sends it to the browser. 7. Now any operation or request which the browser makes will eventually passes through Selenium RC server to actual webserver and vice verse.
Well you can see the same behind the scenes operation by your own. Let us see how we can do that. Step 1 Open the selenium server 2.15 from command prompt using the following command.
java -jar selenium-server-standalone-2.15.0.jar
Step 2 Now navigate to the URL, which is nothing but the default URL in which selenium server start, you can of course change the same if you want. Now your browser will have a page something like this Step 3 Lets create a session by clicking on the Create Session button in the browser we have, now this will ask us to select the browser We will select Internet Explorer and click “OK” button, which will eventually create a session for us and launches a browser with empty page (Since we have not supplied any command to Selenium server at this point to open any URL or to perform any operations) Now your Selenium URL page which you have opened in step 1. Here we have three more buttons with rest of steps we are going to perform. In this topic we are not going to detail the Load scriptfunctionality, since this is beyond the scope of the topic which we are dealing with. Anyways, this is how selenium actually works and performs the magic !!! That’s it. Please leave your comments and rate the post !!! Also please mail me @ karthik@executeautomation.comif you find this post needs any modification. Thanks, Karthik KK

Post Author: Karthik kk

2 Replies to “How Selenium Works ?”

Leave a Reply

Your email address will not be published. Required fields are marked *