Selenium private kitchen Series 7-learn more about the working principle of selenium RC (2) [II]

Source: Internet
Author: User

In the previous article, why does the selenium server in selenium RC need to exist as a proxy server? In fact, this is related to the "same origin policy" of the browser.

1. What is a same-origin policy?

Same-origin policyIt is a well-known security policy proposed by Netscape, which is used by all browsers that support JavaScript.

Why the same-origin policy is required?Here is an example:
If there is no same-origin policy, what will happen? As you know, JavaScript can do many things, such as reading/modifying a value in a webpage. Well, you have opened a browser, opened a bank website in a tab window, and opened a malicious website in another tab window, the malicious website has a special JavaScript code for modifying bank information. When you access this malicious website and execute its JavaScript code, your bank page will be modified by this JavaScript code, the consequences will be very serious! The same-origin policy is used to prevent such a problem. See:

 

For example, in the browserSame SourceThe domain name, protocol, and port are the same. Therefore, tab1 can only execute javascript1 and javascript3 scripts, while javascript2 cannot, so as to prevent other webpages from being tampered.


Ii. Why does selenium server exist in this form of proxy server?
As mentioned above, what is the relationship between the selenium server of the same-origin policy ?? Haha, as mentioned in the previous article, selenium core is a collection of JS functions, which is the basis for browser operations. When the same-origin policy exists, some problems may occur. See:

Because the "Source" of selenium core's Js script is localhost, the browser will prevent selenium core's Js script from being executed on the test page, which is why in the first part of this series, if you only use selenium core for testing, you need to install selenium core on a remote server.

To solve the problem above, the selenium server in selenium RC appeared in the form of a proxy server, showing how it cheated the browser with the proxy identity:>

Selenium server exists as a proxy. By modifying the source information of the website, selenium RC can easily bypass the same-origin policy. In, the browser will think that the website and selenium core come from the same "Source"-proxy server!

Selenium private kitchen Series 7-learn more about the working principle of selenium RC (2) [II]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.