Search code examples
seleniumselenium-webdriverwebdriverselenium-rcsame-origin-policy

Where does the functionality of selenium to control the browser lies in?


Where does the functionality of the Selenium lie?

I've read somewhere that the language binding or API provides glue code to use Selenium in java.

Glue code or Binding code: The code that connects incompatible software components.

Jason Huggings wrote JavaScriptTestRunner to control the browser. The functionality to control the browser lie in the JavaScriptTestRunner. It suffers from Same-origin policy. Paul Hammant created HTTP Proxy to bypass the Same-origin policy. This opened the doors to write tests in multiple languages. We are provided with an API to write tests.

Then WebDriver is created. WebDriver and RC are merged to form Selenium 2.

Where does the functionality to control the browser gone to?

  • Within the API?
  • Within the browser driver?

Why does the API is called as glue code or binding code? What does it bind?


Solution

  • Selenium in the general usage of the term is a library - a collection of code organized in modules and packages. In this form it's a WebDriver client - it can communicate with that kind of server, following the WebDriver protocol; thus enabling a programmer to control a browser.

    Where does the functionality to control the browser gone to?

    In the WebDriver protocol, and the server that translates the WebDriver commands to browser instructions, and back.
    Selenium being a client gives you the ability to use this functionality, in your chosen language - conveniently, without you having to learn or directly run WebDriver requests and parse their response.

    Why does the API is called as glue code or binding code? What does it bind?

    In programming binding is the uniform / or well-defined API of a library, that connects lower-level code (other programs, or the OS) or protocols - WebDriver in this case, to higher-level concepts - your code. Wikipedia to the rescue, with more details.