Interview Questions

Selenium WebDriver - What is Same origin policy and how it can be handled?

Selenium WebDriver Interview question and Answers


(Continued from previous question...)

Selenium WebDriver - What is Same origin policy and how it can be handled?

The problem of same origin policy disallows to access the DOM of a document from an origin that is different from the origin we are trying to access the document.
Origin is a sequential combination of scheme, host and port of the URL. For example, for a URL http:// http://www.google.com/resources/, the origin is a combination of http, google.com, 80 correspondingly. Thus the Selenium Core (JavaScript Program) cannot access the elements from an origin that is different from where it was launched. For Example, if I have launched the JavaScript Program from “http://www.google.com”, then I would be able to access the pages within the same domain such as “http://www.google.com/resources”. So, In order to handle same origin policy, Selenium Remote Control was introduced.

(Continued on next question...)

Other Interview Questions