Posts

Two ways to Close a Browser in Selenium!

Do you want to know something about Selenium? Well, congratulations on finding it!

In this article you will learn:

  • What is selenium?
  • The functions and advantages of Selenium
  • How does Selenium relate to Python and WebDriver?
  • The difference between the close() and quit() methods

 

What is Selenium?

Selenium is a tool for Web application testing. Selenium tests run directly in the browser, just as real users do. Supported browsers include Internet Explorer (7, 8, 9, 10, 11), Mozilla Firefox, Safari, Google Chrome, Opera, Edge, and more.selenium

  • AboutWeb automation

Web automated testing is web automated testing. You can use software to input data into web objects, click, and compare the pre-results with actual results, including test reports.

Web test automation includes interface test automation and UI test automation.

Automatic interface test: Verifies the interface level by sending HTTP or HSF requests to obtain the returned result and verify the service logic function on the link. Support online regression validation.

UI automation testing: The UI automation tools of the industry, such as WebDriver, Selenium, etc., are usually used to verify the functions and performance of website business logic by opening a browser and simulating user operations.

The Selenium components

1) Selenium IDE

A Firefox plugin that can record the user’s basic operations and generate test cases. These test cases can then be run and played back in the browser, and the test cases can be converted to automated scripts in other languages.

  • Selenium Remote Control (RC) :

Supports multiple platforms (Windows, Linux, Solaris) and multiple browsers (IE, Firefox, Opera, Safari), and can write test cases in multiple languages (Java, Ruby, Python, Perl, PHP, C#).

  • Selenium Grid:

Selenium-RC allows you to extend for large test cases or test cases that need to be run in different environments.

The version of Selenium

The core part of the Selenium1.0 (Selenium RC or Remote Control) tool is implemented based on the JavaScript codebase.

Selenium 1.0 automated test execution steps are as follows:

  1. Testers write test scripts based on Selenium supported programming languages
  2. Testers execute test procedures
  3. The test script sends an HTTP request to the Remote Control Server (RC) to access the website
  4. Upon receiving the request, RC visits the site under test, retrieves the data content of the page, inserts Selenium Core’s JavaScript codebase into the page, and returns it to the browser where the tester is performing the test
  5. The test script calls Selenium Core inside the browser to execute the test code logic, and finally records the test results to complete the test.

Selenium2.0 appears (Selenium2.0 = Selenium + WebDriver).

In October 2016, Selenium3.0 was introduced to separate the core API from the client driver and remove the less-used Selenium RC functionality.

 

The function of Selenium

The main functions of Selenium include testing browser compatibility and system functionality.

Test compatibility: Test the application to see if it works well across browsers and operating systems.

Test system functionality: Create regression tests to verify software functionality and user requirements.

The bottom layer of the framework uses JavaScript to simulate the operation of the browser by real users. When the test script is executed, the browser automatically clicks, enters, opens, and validates the script code, just as a real user would, testing the application from the end user’s perspective.

Makes it possible to automate browser compatibility testing, although there are still subtle differences between browsers.

Simple to use, you can use Java, Python, and other languages to write use case scripts.

The advantage of Selenium

Selenium tests run directly in the browser, just as real users do. Selenium tests run in Internet Explorer, Chrome, and Firefox on Windows, Linux, and Macintosh. No other testing tool can cover so many platforms. There are many other benefits to using Selenium and running tests in a browser.

Selenium is completely open-source and has no restrictions for business users. It supports distribution and has a mature community and learning documentation. Here are the main benefits:

By writing Selenium test scripts that mimic the user’s actions, you can test the application from the end user’s perspective. By running tests in different browsers, it is easier to find browser incompatibilities. The core of Selenium, also known as the Browser Bot, is written in JavaScript. This allows the test script to run in a supported browser. The Browser Bot is responsible for executing the commands received from the test scripts, which are either written in HTML table layouts or in one of the supported programming languages.

Selenium works in the following browsers:

  • Google Chrome
  • Internet Explorer 7, 8, 9, 10, 11
  • Firefox
  • Safari
  • Opera
  • Microsoft Edge
  • HtmlUnit
  • PhantomJS
  • Android
  • iOS

 

How does Selenium relate to Python and WebDriver?relationship

Relationship between Selenium and Python

Selenium is also a tool for Web application testing. ThoughtWorks is an acceptance testing tool written specifically for Web applications.

Python is an object-oriented, literal computer programming language. Is also a powerful and perfect universal language, has more than ten years of development history, mature and stable. Python has the richest and most powerful class library of any scripting language, enough to support most everyday applications. Python syntax is simple and clear, and it has a rich and powerful class library. Often nicknamed the Glue language, it makes it easy to link together modules made in other languages (especially C/C++).

Selenium can use the Python language to call Selenium RC for testing.

Relationship between Selenium and WebDriver

With the continuous development of Internet technology and the security limitations of browsers on the JavaScript language, the development of Selenium has encountered many difficult difficulties. Due to its own implementation mechanisms, Selenium is unable to break through the browser sandbox, making testing requirements for many test scenarios difficult to implement.

In 2006, Google engineer Simon Stewart started WebDriver, a project that lets test tools call built-in methods provided by browsers and the operating system itself to bypass the sandbox limitations of the JavaScript environment.

In 2008, Selenium and WebDriver merged, and Selenium2.0 emerged (Selenium2.0 = Selenium + WebDriver).

 

The difference between the close() and quit() methods

In some cases, we need to open more content than a browser with multiple tabs. To close these meetings quit() and close() methods, Selenium is used. But there is a difference.

Close: Used to close the current window. When many open Windows are open, use close to close some Windows.

Quit: Exit the driver and close all associated Windows. End the process and close all Windows. The close() method is used to close one of the Windows opened during the execution of the use case.close vs quit

Code test:

# -*- coding: utf-8 -*-

from selenium import webdriver

from time import sleep

driver = webdriver.Firefox()

driver.get(‘http://sahitest.com/demo/index.htm’)

Print driver.current_window_handle # Check the current window handle

driver.find_element_by_link_text(‘Window Open Test’).click()   # Open new Window1

driver.find_element_by_link_text(‘Window Open Test With Title’).click()  # Open new Window2

print driver. Window_handles  # View all window handles

driver.close()

print driver.window_handles  # If you have any window handles, you can see that the first two Windows are still in place

driver.quit()  # see that all Windows are closed

 

Results:

{b030dd54-3cbd-4d7b-800a-2ff296f03f5b}

[u'{b030dd54-3cbd-4d7b-800a-2ff296f03f5b}’, u'{7fdacf2e-0c34-4f0d-9a7a-ae34f3af932c}’, u'{f2d79121-8cc2-47ea-bd7d-2035e305ba2f}’]

[u'{7fdacf2e-0c34-4f0d-9a7a-ae34f3af932c}’, u'{f2d79121-8cc2-47ea-bd7d-2035e305ba2f}’]

selenium close browser

The close () method

# Importing webdriver from selenium

from selenium import webdriver

# Here Chrome will be used

driver = webdriver.Chrome()

# URL of website

url = “https://www.geeksforgeeks.org/”

# Opening the website

driver.get(url)

# Closes the current window

driver.close()

 

The quit () method

# Importing webdriver from selenium

from selenium import webdriver

# Here Chrome will be used

driver = webdriver.Chrome()

# URL of website

url = “https://www.geeksforgeeks.org/”

# Opening the website

driver.get(url)

# All windows related to driver instance will quit

driver.quit()

WebGL vs Canvas | How do they relate to Fingerprints?

Do you know what is WebGL? What is canvas? What do they have to do with browser fingerprints? If you don’t know about them, read on!

 

What is a canvas?

Canvas is a label of HTML5. Canvas can use JavaScript to draw images on web pages and manipulate image content.

It’s basically a bitmap that can be manipulated in JavaScript.

Canvas object represents an HTML Canvas element -< Canvas >. It does not have its own behavior but defines an API to support scripted client-side drawing operations.

  • What is HTML?

HTML, called hypertext Markup Language (HTML), is an identifier language. It includes a series of tags. These tags unify the format of documents on the network and connect scattered Internet resources into a logical whole. HTML text is a descriptive text composed of HTML commands that describe text, graphics, animations, sounds, tables, links, etc. The web pages we browse are written in HTML.what are they

The history of the Canvas

This HTML element is designed for client-side vector graphics. It has no behavior of its own, but it presents a drawing API to the client JavaScript so that the script can draw whatever it wants to draw onto a canvas.

The reason for this radical extension to HTML is that HTML’s drawing capabilities in Safari are also used by the Dashboard component on the Mac OS X desktop, and Apple wanted a way to support scripted graphics in Dashboard.

Firefox 1.5 and Opera 9 have followed Safari’s lead. Both browsers support the

We can even use the < Canvas > tag in IE and build compatible canvases with open-source JavaScript code (initiated by Google) based on IE’s VML support.

Efforts to standardize < Canvas > are being advanced by an informal association of Web browser vendors, and < Canvas > has become an official tag in the HTML 5 draft.

Canvas and browser fingerprints

What does Canvas have to do with browser fingerprints?

Using the same HTML Canvas element for drawing operations, Canvas will produce different picture contents on different operating systems and browsers, which can be used to identify and distinguish users. This may be because:

1) In the image format, different Web browsers use different graphics processing engines, different image export options, different default compression levels, etc.

2) At the pixel level, each operating system uses different Settings and algorithms for anti-aliasing and sub-pixel rendering operations.

3) Even if the same drawing operation, the CRC test of the resulting picture data is not the same.

 

What is a WebGL?

Webgl is used to draw and render complex three-dimensional graphics (3D graphics) on web pages and allow users to interact with them.

WebGL (Full Write Web Graphics Library) is a 3D Graphics protocol that allows JavaScript to be combined with OpenGL ES 2.0. By adding a JavaScript binding to OpenGL ES 2.0, WebGL can provide hardware 3D accelerated rendering for HTML5 Canvas so that Web developers can use the system graphics card to display 3D scenes and models more smoothly in the browser. You can also create complex navigation and data visualizations. Obviously, the WebGL technology standard eliminates the need to develop web-specific rendering plugins that can be used to create web pages with complex 3D structures, even to design 3D web games, and so on.

Traditionally, to display three-dimensional graphics, developers have developed a stand-alone application using C or C ++ with a dedicated computer graphics library, such as OpenGL or Direct3D. Now with WebGL, we just need to add some extra 3D graphics code to our already familiar HTML and javascript to display 3D graphics on a web page.

Webgl is embedded in the browser, you don’t have to install plug-ins and libraries to use it, and it’s browser-based, so you can run WebGL applications on multiple platforms.

  • What is the OpenGL?

OpenGL (Open Graphics Library) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics. This interface consists of nearly 350 different function calls to draw everything from simple graphics bits to complex 3d scenes.

The other programming interface system is Direct3D for Microsoft Windows only. OpenGL is commonly used in CAD, virtual reality, scientific visualization programs, and video game development.

The origin of the Webgl

The two most widely used 3d graphics rendering technologies on personal computers are Direct3D and OpenGL. Direct3D is part of Microsoft’s DirectX technology, which is a set of programming interfaces controlled by Microsoft and mainly used on the Windows platform. OpenGL is widely used on many platforms because of its openness and free.

Webgl is rooted in OpenGL, but it is actually derived from a special version of OpenGL, OpenGL ES.

OpenGL is the underlying driver-level graphics interface (which is directly related to the graphics card) similar to DirectX. But this kind of low-level OpenGL is beyond the reach of JavaScript that parasitized the browser. But in order to make the Web more graphics powerful, WebGL was introduced in 2010.

WebGL and browser fingerprints

Webgl has a similar relationship to the browser fingerprint as Canvas. Webgl is also a way to track browser fingerprints. Webgl surveys your device through images displayed by the browser.

fingerprint

WebGL vs Canvas

There is a conceptual difference

Canvas element is an HTML element, introduced in ITS HTML5. This allows its users to use JavaScript to draw on the screen and, therefore, dynamically generate graphics and animations on the client-side. You can think of it as a carrier, simply a blank sheet of paper.

In canvas, once the graph has been drawn, it doesn’t continue to get attention from the browser. If its position changes, the entire scene also needs to be redrawn, including any objects that may have been covered by the graph.

Canvas uses JavaScript to draw 2D graphics. Canvas is rendered pixel by pixel.

Canvas is a feature provided by HTML5, and Canvas 2D is equivalent to acquiring the built-in 2D graphic interface, namely 2D brush. Canvas 3D is a graphical interface based on WebGL, which is equivalent to a 3D brush. You can choose different brushes to paint on it.

WebGL is a non-standardized API and a 3D drawing protocol. Simply put, WebGL is a canvas-based rendering framework that can draw 2D and 3D images on Canvas. Allows you to use JavaScript for OpenGL functionality. 3D can be rendered using a browser.

Browser applicability differences

Canvas supports fewer browsers than WebGL.

Canvas is supported by Microsoft Edge, Chrome, IE, Safari, Konqueror, Opera, and Mozilla. WebGL, however, supports more types of browsers. In addition to the above browsers that support Canvas running, many mobile browsers also support WebGL running. For example, BlackBerry 10, Playbox, IE, Firefox Mobile, Firefox OS, Chrome, Maemo, Meego, MS Edge, Opera Mobile, Ubuntu, WebOS, iOS.

The same point

Both Canvas and WebGL can be used to identify browser fingerprints. By hashing the image data, a computer program can recognize subtle differences in the results rendered by different hardware devices.

However, if the user’s device, operating system, and browser are all the same, the calculated fingerprint will be the same. Therefore, it needs to be combined with other browser fingerprints to further compute a more differentiated fingerprint identifier.

How can browser fingerprints hurt you? It tells the Internet who you are. You think that no one knows what you do on the Internet, that everything is gone. Browser fingerprints have already given you away.

To prevent Canvas and WebGL fingerprints, I think you need ClonBrowser!

ClonBrowser is an excellent virtual privacy browser. It gives you control over your own parameters. These include UserAgent, HTTP Headers, Plugins, MymeTypes, WebGL, and Geopositio. Make your fingerprints completely independent with these Settings. Also, if a website tries to capture your fingerprint, ClonBrowser will use the mask fingerprint to prevent that from happening. You can trust it when it comes to preventing fingerprints from being taken!ClonBrowser

In addition, ClonBrowser allows you to create and share countless configuration files, making multi-account management less of a hassle for you! Want that efficiency and safety? Start your free trial now!

The importance of information security

Our lives are inseparable from numbers, and people rely on information technology more than ever. Information technology is inseparable from the use of medical equipment in hospitals, security systems and smart phones. Computerized equipment plays an important role around people. Information security has become a basic requirement of human life.

Information technology is not only a basic requirement of life, but also very important to work and business. Information is one of the most important intangible assets, and managers have the responsibility to protect the confidentiality of important information, because information technology carries a lot of sensitive data and customer information. Its history can be traced back to 1980, when the use of computers was limited to computer centers, and the security of computers represented the physical computing infrastructure. Today, the openness of the Internet simplifies the process of internal information storage. The world is rapidly transforming from an industrial economy to a digital society. With the development of information technology, people’s demand for information security is increasing.

What is information security?

Information security, also known as Infosec. It is to establish technical management security protection for the data processing system, the purpose is to protect the computer hardware, software, and data from being damaged, modified and leaked by malicious factors. At the same time, it is responsible for protecting data and ensuring its confidentiality, integrity and availability. And, in the concept of information security, they are called information security principles:

1.Confidentiality: data cannot be accessed without authorization;

2.Integrity: the data will remain unchanged and remain valid;

3.Availability: Managers who have the right to access the information can obtain the information.

What are the types of information?

Information is divided into public and confidential. Anyone can access is public, while information that only individuals can access is confidential.

1.Public information

It is generally believed that there is no need to protect public information. Although the principle of confidentiality does not apply to public information, it is still necessary to ensure that public information is complete and accessible. Therefore, information security also applies to handling public information. For example: online store. Product details, blog posts, seller contact information, etc., all key information is publicly available and anyone can view it. But the online store still needs to be protected to ensure that no one will disrupt the work.

2.Confidential information

Personal information: information about a specific person (name, ID, phone number, physical characteristics, marital status and other data), anyone has an obligation to protect it and not to transfer it to others;

Trade secrets: internal information about the company’s work (technology, management methods, customer base). If the outside world knows this data, the company may lose profits. The company has the right to decide on its own trade secrets and publicly available information, but it does not mean that all information is classified as trade secrets, such as legal representative.

Professional secrets: medical, notarization, lawyers and other types of secrets related to professional activities.

Official secrets: including known information such as taxes or registered companies. Government agencies usually store this data, they have a responsibility to protect it, and only provide it on request.

State secrets: including military information, intelligence data, information about the economy, national science and technology, and foreign policy. This data is a high-level secret, and the system security for storing such information is very strict.

Of course, if the company stores personal data, business or professional secrets, that data must be specially protected, and it is also necessary to restrict unauthorized persons from accessing it. You can usually set the access level and password; install security software; configure encryption. The main task of information security is not only to protect confidential information, but to avoid illegal behaviors and adverse consequences caused by malicious behaviors.

Why pay attention to information security?

Before the advent of the digital age, people locked important documents in safes, hired security guards, and encrypted them on paper to protect data. However, with the rapid development of the Internet, data also faces a large number of different types of risks. For example, threats such as computer hackers, malicious code and denial of service DOS attacks have become more and more common. The implementation, maintenance and update of information security are also huge challenges facing the current group. With information security, information and technology can be protected by responding to, preventing, and detecting internal and external threats.

According to McAfee, losses related to information security and cybercrime currently exceed 200 billion U.S. dollars, and have grown to 250 billion U.S. dollars in recent years, indicating that more sophisticated hacking has increased significantly. Because digital information is getting more and more protected, most people will use antivirus software and use encryption methods to encrypt digital information. However, digital information needs not only virtual protection, but also physical protection. If outsiders steal important data, antivirus software will not help. Therefore, they are placed in a protected storage space.

What are the threats to information security?

Understanding potential threats and security vulnerabilities is very important for choosing appropriate information security management and control. In most cases, threats are the result of vulnerabilities in the protection of information systems. Let us introduce the common threats faced by information systems.

1.Free internet facilities

For example: Many people use laptops to run software in public areas. Since other people can also access information, there is a risk of performing operations.

2.Data security threats

Due to the existence of viruses in the programs installed on the user’s computer, security threats are increasing day by day, and the installed protection programs cannot operate normally.

3.Malware

If the user does not click, the malware cannot enter the computer. To penetrate the computer system, it is necessary to use means to trick the victim into running on the PC. Usually, malware hides itself by attaching itself to interesting content (for example: pictures, videos, GIF animations). Malware that is used to damage the system will be classified according to the user’s startup method, working method, etc. The action strategy of malicious software is different from that of viruses. It will cause abnormal system behavior and will not be noticed by the system for a long time. Will deliberately destroy the system, copy and steal information from the computer, create a computer virus or Trojan horse environment.

4.Phishing

Phishing is one of the common types of online fraud, the main purpose is to steal usage data and destroy it. Phishers usually target: personal information; login name and password; access code; personal account data; bank card or account details; service information; database; trade secrets and other information.

5.Ransomware

Ransomware is created by professional programmers. Such a program can infiltrate the victim’s device through an email attachment file, or a virus-infected browser. At the same time, it can also penetrate the user’s device from the local network.

6.Cloud vulnerabilities

Client-side attacks: This type of attack has been practiced in the Web environment, and the same is true for the cloud. Because the client usually uses a browser to connect to the cloud. Including cross-site scripting (XSS), hijacking Web sessions, stealing passwords, “man in the middle” and other attacks.

Virtualization threat: Because cloud component platforms are traditionally virtualized environments, attacks on virtualized systems also threaten the entire cloud. This threat is unique to cloud computing.

Hypervisor attack: The key element of a virtual system is the hypervisor, which can share physical computer resources between virtual machines. If you interfere with the operation of the hypervisor, a virtual machine may be able to access memory and resources, intercept network traffic, occupy physical resources, or even completely remove the virtual machine from the server.

In summary, whether it is an organization or an individual, information security is indeed very important, and every security measure requires continuous improvement and optimization. At present, the only solution is prevention. Using a built-in protection program for all types of viruses and real-time detection of security is an effective solution to prevent data leakage and reduce risks.

hide your identity

Ways to hide your identity online

The amount of digital information in the world doubles every two years, and the number of searches for “how to hide your identity” is also increasing. In most cases, we use smartphones, computers, tablets and other devices to collect and use information. We buy goods online and communicate with friends. The Internet space is changing at an alarming rate, and data privacy issues are becoming more and more serious.

How to hide identity?

Personal information is a valuable asset of people. Common advertisers can find available information from the browser search history. They will find the user’s needs from the search records and provide reasonable pushes. This is completely legal.

For ordinary computer users, browsing the web does not usually bring many hidden dangers, but there will always be malicious hackers who find loopholes to attack others and gain benefits. Therefore, it is essential to ensure the security of personal data. We have collected common solutions that can help people protect their identities and privacy while online.

1.Stealth access mode

A common way to protect personal data online is to use incognito mode. Almost all browsers have an incognito mode, which protects the private information of online users to a large extent. Apple first introduced this feature in the Safari browser in 2005. Since then, between 2008 and 2010, other browsers have followed suit, including Google Chrome.

Although incognito mode can help users hide information, ISP, Wi-Fi owners, website and local network administrators can still see the user’s view. And, even if the user uses the incognito mode, the provider will see all the user’s visits. They provide users with an IP address and associate it with the owner of the computer.

At work, the incognito mode is meaningless. The local system administrator can track any user’s actions on the Internet. Usually, companies will specifically track visits to specific sites (such as social networks, instant messaging programs, etc.) to prevent employees from wasting time to do other things. Moreover, the use of special software can quickly track a certain user.

2.Use anonymous email for communication

Suppose a user wants to send an email to someone, but doesn’t want the other person to know the email address. Generally speaking, there are two ways to solve it. The first is to use aliases, which are forwarding addresses. The recipient will only see the forwarding address, not the user’s real address. Alternatively, users can choose to use a one-time e-mail account and one-time e-mail service. The way these services work is to create a temporary forwarding address that will be deleted after a period of time, which is ideal for registering content on untrusted websites and preventing the inbox from being flooded by spam.

3.Tor browser

Tor is a professional technology that can hide identities on the Internet. Tor was originally a US military project and later opened to sponsors. The main purpose of this network is to provide anonymity and security in a network where most participants do not trust each other. The essence of the network is that the data passes through multiple computers, the IP address is changed, and the user obtains a secure data transmission channel. The principle of Tor: Connect to the site or service that the user needs through multiple servers in turn. Before the request or data enters the network, a special program on the user’s computer encrypts it so that each server can only decrypt part of it.

4.Virtual Private Network

VPN allows users to protect private data when using the Internet, and they must have a valid Internet to connect to the VPN. The main difference between VPN and standard connection is encryption. All data transmitted through a VPN is encrypted, which is another easy way to anonymize and hide your identity, but not 100%.

If a user is working on a computer and wants to use a browser to access blocked sites, he can choose to install a special program on the PC (VPN client), or add a browser extension. However, there are the following key problems when using this technology:

The Internet is slower and additional encryption takes time. In addition, traffic usually travels a long distance, which is related to the remoteness of the VPN server location.

The traffic is suddenly released to the public network on a regular basis, users may often not notice the disconnected connection and personal data leakage, and the VPN connection may not be automatically restored, which is very inconvenient for users.

In fact, DNS queries are usually handled by DNS servers on public networks, rather than virtual secure servers. If the statement they provide is incorrect, the user can obtain the fake address of the requested domain. In addition, using a DNS server, you can determine the user’s approximate geographic location and Internet provider.

5.Don’t blindly agree that the website is a “Terms of Service”

In many cases, users who browse the web unknowingly choose to agree to the terms of service for selling personal data to third parties. Each user will not read the above content carefully when checking and agreeing. If the user is willing to spend a small amount of time reading the terms of service before clicking “I agree”, they will usually not click agree. For example, Facebook’s application will provide smartphone users with a “synchronization” function, and users can synchronize their contact lists from their phones to Facebook. If the user chooses to “synchronize contacts”, it also means that all of the user’s own friends and Facebook’s personal data information are disclosed.

6.Create multiple identities

If users cannot control whether their information is leaked, identity confusion can be carried out. In other words, if users cannot delete all online information, they can choose to create multiple identities and confuse their true identity as much as possible. For example: use your own name and multiple pseudo-alias identifiers, and then choose five different addresses to create multiple Facebook accounts. At the same time, users can also revisit different sites.