31.Remote Webdriver

Source: Internet
Author: User

Scene

In a nutshell, we can think of remote Webdriver as running Webdriver scripts on long-range machines.

Imagine the simplest scenario: you and your co-workers develop a webdriver script, and then you need to run the script in a common environment. Why run in a public environment? That's because everyone's development machine is different, but if you use the same test machine, then the factors of environmental differences can be basically excluded. We should often hear development say such words: "This bug in my environment is good ah!" "。 Because of the differences in the operating environment, we need a unified operating environment to eliminate the differences.

In this scenario, we need to use remote webdriver, we develop the script locally, and then call remote Webdriver to perform our tests on the test machine.

Installation

The installation of the Remote Webdriver is simple.

Download Selenium-server-standalone-last-version.jar first.

Then run the java -jar selenium-server-standalone.jar command. If there is no error, the machine has been configured as a remote machine, and later Webdriver will start the browser on this machine, execute the script.

Start driver

The following code can start driver on the remote machine, which, by default, will open localhost, which is the Firefox browser on this computer.

driver = Selenium::WebDriver.for(:remote)

If your remote Webdriver is not running locally and you want to specify a browser other than Firefox, use the following code

    driver = Selenium::WebDriver.for(:remote, :url => "http://myserver:4444/wd/hub", :desired_capabilities => :chrome)

Typically, MyServer can be an IP address such as 192.168.x.x.

In addition, the configuration can be configured Selenium::WebDriver::Remote::Capabilities to achieve a more customized browser configuration, this is beyond the scope of this article, do not describe.

Start driver with Watir-webdriver

You can use the following code to let Watir-webdriver also use remote Webdriver mode

    browser = Watir::Browser.new(:remote, {desired_capabilities: :chrome, url: "http://myserver:4444/wd/hub"})

Python version
c == webdriver. Remote (command_executor='http://127.0.0.1:4444/wd/hub', Desired_capabilities=c)

Note that the code for starting remote Webdriver used in the python binding wiki is not the same as what I gave above, probably because my selenium version is lower (30), and the newest version of the student can try the code on the wiki.

31.Remote Webdriver

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.