Selenium Chrome Browser Start-up and proxy settings

Source: Internet
Author: User

Although Webdriver has the best support for Firefox, previously written scripts are also running in the Firefox browser, but recently the project has been integrated to find that the newly integrated features are not very supportive of Firefox, and there are no plans to make browser compatibility improvements in the near future. So my automation scripts are going to be re-edited and run on a well-supported Chrome browser. Having said so many backgrounds, let's get down to the chase.

1. You need to download CHROMEDRIVER.HTTP://CHROMEDRIVER.STORAGE.GOOGLEAPIS.COM/INDEX.HTML2 first. Unzip the downloaded file, Copy the Chromedriver.exe to the Chrome root directory, typically in the Appication directory 3. You can use Chromedriver, if you copy Chromedriver to the project root, you don't need setproperty, but I put it in the chrome root. directory, so you set the drive path. System.setproperty ("Webdriver.chrome.driver", "C:\\Program Files" (x86) \\Google\\Chrome\\Application\\ Chromedriver.exe "); Webdriver driver=new chromedriver (); //Initialize browser 4. After three steps, you can actually go directly to the script. However, sometimes it is possible to set the agent and port as needed. Although my own script does not need to be set, it uses the default proxy and port. But before the script made a mistake, I mistakenly think it is a proxy setup has a problem, so also write script to proxy reset the next, later still did not pass, colleagues help me after analysis said no, Magic commented out code incredibly passed, really do not know where the error before, OK, it is learning. You can set the runtime proxy by the following code:/* String proxyipandport= "localhost:8080";  desiredcapabilities cap = new Desiredcapabilities ();  proxy proxy=new proxy ();  proxy.sethttpproxy (proxyipandport). Setftpproxy ( Proxyipandport). Setsslproxy (Proxyipandport);  cap.setcapability (CapabilityType.ForSeleniumServer.AVOIDING_ PROXY, True);  cap.setcapability (CapabilityType.ForSeleniumServer.ONLY_PROXYING_SELENIUM_TRAFFIC, True);  system.setproperty ("http.nonproxyhosts", "localhost");  cap.setcapability (Capabilitytype.proxy, proxy); * * As for Firefox, it also automatically generates a profile every time Firefox is started, instead of using the current Firefox profile, which can be set by Firefoxprofile. Temporarily do not write first, if any need, can leave a message.

Selenium Chrome Browser startup and proxy settings

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.