Web automation Framework Lazyui User's Manual (4)--Control Grabber elements Extractor detailed (bulk fetch)

Source: Internet
Author: User
Tags manual xpath setf
Overview

A previous blog post details the design ideas & logic of a single control crawl and how to use it, and this article will detail the bulk control crawl functionality.

Bulk Crawl: Open a Web page, traverse all the elements on the page that can be crawled , get an iframe for each element, an XPath for three unique positioning controls, and a thumbnail display of the captured elements for the user to tick, And generate Java code based on Lazyui framework to solve the problem of getting the whole page element. Download:

http://download.csdn.net/detail/kaka1121/9571942

Drag-and-drop to Chrome to right -click the tool and design ideas in the previous blog post has been described in detail, this article will not repeat. http://blog.csdn.net/kaka1121/article/details/51878346 using:

Take Baidu homepage For example, the page looks like this:

Click the right button

The results are as follows (first 7):

In short, bulk fetching is the result of a single fetch of each control, presented in tabular form, and a visual representation of the control being acquired (the "Control Presentation" column) so that the user can tick the desired control and generate the code.

As shown in the figure above:

The first behavior of Baidu search box crawl results,

The control type is "text",

By default, the generated code is checked because it can be uniquely positioned with ID,

Gives three XPath that can be uniquely positioned on it:

input[@id = ' kw ')
input[@name = ' WD ']
Input[contains (@class, ' s_ipt ')]

The control name and description are default to their IDs and can be modified by themselves.

Click Select All to select all the controls that the tool captures, (can be uniquely positioned with ID or name, tick "generate code" by default)

It is also possible to check the XPath that is captured in the column, and then check out the unstable XPath.

After filling in the Pagebean package name and class name at the bottom, a. java file is generated that contains all the code from the bean layer and is copied directly to the project for use.

Package Bean; 
Import lazy.test.ui.annotations.*; 
Import Lazy.test.ui.beans.PageBean; 
Import lazy.test.ui.controls.*;
Import Lazy.test.ui.browser.BrowserEmulator; Public class Baidu extends Pagebean {@Xpath (xpath={"//input[@id = ' kw ']", "//input[@name = ' wd ']", "//input[contains (@cla
    SS, ' S_ipt ')] "}) @Frame (frame=" ") @Description (description=" kw ") public Text kw; @Xpath (xpath={"//input[@id = ' su ']", "//input[contains (@value, ' Baidu ')]", "//input[contains (@class, ' bg s_btn ')"}) @
    Frame (frame= "") @Description (description= "su") public click Su; @Xpath (xpath={"//a[@name = ' ime_hw ']", "//a[contains (Text (), ' handwriting ')]", "/html/body/div[3]/div[1]/div/div[1]/div/form
    /span[3]/span/ul/li[1]/a "}) @Frame (frame=" ") @Description (description=" IMEHW ") public click IMEHW; @Xpath (xpath={"//a[@name = ' ime_py ']", "//a[contains (Text (), ' Pinyin ')]", "/html/body/div[3]/div[1]/div/div[1]/div/form /span[3]/span/ul/li[2]/a "}) @Frame (frame=" ") @Description (description= "Imepy") public click Imepy; @Xpath (xpath={"//a[@name = ' ime_cl ']", "//a[contains (Text (), ' Close ')]", "/html/body/div[3]/div[1]/div/div[1]/div/form
    /span[3]/span/ul/li[4]/a "}) @Frame (frame=" ") @Description (description=" imecl ") public click Imecl; @Xpath (xpath={"//a[@name = ' Tj_trnuomi ']", "//a[contains (Text (), ' glutinous rice ')]", "/html/body/div[3]/div[1]/div/div[3]/a[1"
    "}) @Frame (frame=" ") @Description (description=" Tjtrnuomi ") public click Tjtrnuomi; @Xpath (xpath={"//a[@name = ' tj_trnews ']", "/html/body/div[3]/div[1]/div/div[3]/a[2"}) @Frame (frame= "") @Descripti
    On (description= "Tjtrnews") public click Tjtrnews; @Xpath (xpath={"//a[@name = ' tj_trhao123 ']", "//a[contains (Text (), ' hao12 ')]", "/html/body/div[3]/div[1]/div/div[3]/
    A[3] "}) @Frame (frame=" ") @Description (description=" tjtrhao123 ") public click tjtrhao123; @Xpath (xpath={"//a[@name = ' Tj_trmap ']", "/html/body/div[3]/div[1]/div/div[3]/a[4"}) @Frame (frame= "") @DEscription (description= "Tjtrmap") public click Tjtrmap; @Xpath (xpath={"//a[@name = ' tj_trvideo ']", "/html/body/div[3]/div[1]/div/div[3]/a[5"}) @Frame (frame= "") @Descript
    Ion (description= "Tjtrvideo") public click Tjtrvideo; @Xpath (xpath={"//a[@name = ' Tj_trtieba ']", "/html/body/div[3]/div[1]/div/div[3]/a[6"}) @Frame (frame= "") @Descript
    Ion (description= "Tjtrtieba") public click Tjtrtieba; @Xpath (xpath={"//div[@id = ' u1 ']//a[@name = ' tj_login ']", "//a[@name = ' Tj_trnuomi ']/parent::d iv/a[7]", "/html/body/ 
    DIV[3]/DIV[1]/DIV/DIV[3]/A[7] "}) @Frame (frame=" ") @Description (description=" Tjlogin ") public click Tjlogin; @Xpath (xpath={"//div[@id = ' u1 ']//a[@name = ' Tj_settingicon ']", "//a[@name = ' Tj_trnuomi ']/parent::d iv/a[8]", "/html/ BODY/DIV[3]/DIV[1]/DIV/DIV[3]/A[8] "}) @Frame (frame=" ") @Description (description=" Tjsettingicon ") public Cli
    CK Tjsettingicon; @Xpath (xpath={"//a[@name = ' Tj_briicon ']", "//a[contains (Text (), ' more Products ')]", "//a[contains (@class, ' BRI ')] "}) @Frame (frame=" ") @Description (description=" Tjbriicon ") Public click Tjbriicon
    ; @Xpath (xpath={"//a[@name = ' Tj_mp3 ']", "/html/body/div[3]/div[1]/div/div[4]/div/div[2]/div[1]/div/a[1]"}) @Frame (
    Frame= "") @Description (description= "Tjmp3") public click Tjmp3; @Xpath (xpath={"//a[@name = ' tj_img ']", "/html/body/div[3]/div[1]/div/div[4]/div/div[2]/div[1]/div/a[2]"}) @Frame (
    Frame= "") @Description (description= "tjimg") public click tjimg; @Xpath (xpath={"//a[@name = ' Tj_zhidao ']", "/html/body/div[3]/div[1]/div/div[4]/div/div[2]/div[1]/div/a[3]"}) @
    Frame (frame= "") @Description (description= "Tjzhidao") public click Tjzhidao; @Xpath (xpath={"//a[@name = ' Tj_wenku '", "/html/body/div[3]/div[1]/div/div[4]/div/div[2]/div[1]/div/a[4]"}) @Frame
    (frame= "") @Description (description= "Tjwenku") public click Tjwenku; @Xpath (xpath={"//a[@name = ' Tj_bang ']", "//a[contains (Text (), ' leaderboards ')]", "/html/body/DIV[3]/DIV[1]/DIV/DIV[4]/DIV/DIV[2]/DIV[1]/DIV/A[5] "}) @Frame (frame=" ") @Description (description=" Tjbang ")
    Public Click Tjbang; @Xpath (xpath={"//a[@name = ' Tj_tuiguang ']", "//a[contains (Text (), ' Baidu Promotion ')]", "/html/body/div[3]/div[1]/div/div[4]/ DIV/DIV[2]/DIV[1]/DIV/A[6] "}) @Frame (frame=" ") @Description (description=" Tjtuiguang ") Public click Tjtuigua
    Ng @Xpath (xpath={"//a[@name = ' Tj_more ']", "//a[contains (Text (), ' All Products > ')]", "/html/body/div[3]/div[1]/div/div[4]/
    div/div[2]/div[1]/div/div/a "}) @Frame (frame=" ") @Description (description=" Tjmore ") public click Tjmore; @Xpath (xpath={"//a[@id = ' setf ']", "//a[contains (@style, ' display:inline; ')]", "/html/body/div[3]/div[3]/div/div[2"
    /P[1]/A[2] "}) @Frame (frame=" ") @Description (description=" SETF ") public click setf; Public Baidu (Browseremulator is) {super (BE);}}


Summary

Using this plug-in, you can quickly complete the acquisition of the control and automatically generate the Bean Layer Code (which provides its specific method based on 8 different control types), almost completely releasing the amount of work the control gets.

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.