Selenium-java Crawler Implementation

Source: Internet
Author: User

Recommended Websites for learning websites

1. Official Document Http://www.seleniumhq.org/docs/

2.selenium Multithreading http://www.cnblogs.com/dingmy/p/3438084.html

Selenium Standalone Server

Build RC Environment

1. Download Selenium Standalone Server (http://www.seleniumhq.org/download/)

2. Download Chrome Drivers in the same directory as the Selenium-server-standalone.jar package (http://www.seleniumhq.org/download/)

Start hub

1. Open the terminal and switch to the directory where the Selenium-server-standalone is located

2. Execution Java-jar selenium-server-standalone-3.2.0.jar-role hub-maxsession 40-port 4444

3. Prompt for information when successful startup

Parameter description:

Maxsession Maximum number of sessions

Port Listener, default 4444, if the listening port is occupied by another program, the program cannot start successfully (customizable)

Start node

Open terminal, cut flower corresponding directory

1. Execution of Java-dwebdriver.chrome.driver=d:\chromedriver\chrodriver.exe-jar Selenium-server-standalone-3.2.0.jar-role Node-hub/http (own IP): 4444/grid/register-maxsession 20-browser "browser=chrome,maxinstances=20"-port 5555

Parameter description:

-dwebdriver.chrome.driver Chrome Drive

-hub Hub Server Address

-browser set Browser parameters, maximum number of processes

-maxsession maximum number of sessions, note that the maximum number of sessions on a branch node cannot exceed the maximum number of sessions defined on the hub server

-port listening port, default 5555

Call RC

Desiredcapabilities capabilities = Desiredcapabilities.chrome ();

Webdriver Driver = new remotewebdriver (new URL ("Http://192.168.199.146:4444/wd/hub"), capabilities);

To always selenium tools in your code, you need to add dependencies in your MAVEN configuration

<dependency>

<groupId>org.seleniumhq.selenium</groupId>

<artifactId>selenium-java</artifactId>

<version>3.2.0</version>

</dependency>

Note: The last choice is best to use the latest version, because it is compatible with the browser (once stepped on the pit).

Selenium-java Crawler Implementation

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.