Robotframework Automated test Framework-selenium Web Automation (-)-open Browser and close Browser

Source: Internet
Author: User
Tags seleniumhq

Selenium has been out for many years, from the initial Selenium1 to later SELENIUM2, has become more and more mature, but also has been widely used by many companies. Selenium development process, divided a lot of modules, here we mainly introduce Webdriver,webdriver has been a lot of browser compatibility. The role that webdriver plays between the automation script and the browser is similar to the Appium described earlier.

Since many browsers are already actively supporting and compatible with Webdriver, Webdriver will confirm that the browser's native component is available and has a version match when it is started. Then start using Selenium's own design-defined protocol (WEBDRIVER wire Protocol) in the target browser, Webdriver wire protocol is generic, meaning whether firefoxdriver or chromedriver , a Web service based on this Protocol is launched on a port after launch, and the Webdriver wire protocol is a restful Web service.

When calling Webdriver, it is actually sending an HTTP request to the RESTful service listener port that is started on the browser, and the request will tell selenium what to expect the browser to do in the JSON-formatted string specified in the Webdriver wire protocol.

Selenium and Robotframework Selenium2library Library Introduction

The selenium website can be accessed via http://www.seleniumhq.org/. From this site can be downloaded to various browsers running the required driver.

From the http://www.seleniumhq.org/docs/address, you can find information about selenium documents and introductions.

Open Browser and Close Browser

In the Selenium2library library, the Open browser keyword is used to open a specified browser that receives the following parameters:

Parameters (Arguments)

Description

Url

URL address to open in the browser

Browser

Specify the type of browser you want to open, including Ie,firefox,chrome,opera, Safari and other popular browsers, using Firefox by default

Alias

Set the alias of the browser instance that can be used for switching between browsers, default to None

Remote_url

Whether to enable access via remote server, default to False

Desired_capabilities

Configuration parameters that can be specified, default to None

Ff_profile_dir

This parameter is mainly for Firefox browser, you can specify the Firefox profile path, the default is None

The close Browser keyword is used to close a current browser that is already open.

Example 1: Open Google Chrome, enter http://www.baidu.com in the URL address

Open Browser http://www.baidu.com Chrome

Execution Result:

Starting test:RobotFrameworkTest1.TestSuite6.TestCase0002

20170529 15:22:55.284:info:opening Browser ' chrome ' to base URL ' http://www.baidu.com '

Ending test:RobotFrameworkTest1.TestSuite6.TestCase0002

Example 2: Open IE browser, enter http://www.baidu.com in the URL address, and then close the browser

Open Browser http://www.baidu.com ie

Close Browser

Execution Result:

Starting test:RobotFrameworkTest1.TestSuite6.TestCase0001

20170529 15:31:01.937:info:opening browser ' ie ' to base url ' http://www.baidu.com '

Ending test:RobotFrameworkTest1.TestSuite6.TestCase0001

In addition, when using IE browser, you need to keep the protection mode consistent in each area under the Security tab in the browser options, either all enabled, or none enabled, as shown, otherwise prone to similar webdriverexception:message: Unexpected error launching Internet Explorer. Protected Mode settings is not the same for all zones. Enable Protected Mode must is set to the same value (enabled or disabled) for all zones error.

"The original is owned by the author, welcome reprint, but retain the copyright, and reproduced, need to indicate the source "

Robotframework Automated test Framework-selenium Web Automation (-)-open Browser and close Browser

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.