CN113010159A - Script-based task processing method and device - Google Patents

Script-based task processing method and device Download PDF

Info

Publication number
CN113010159A
CN113010159A CN202110310785.2A CN202110310785A CN113010159A CN 113010159 A CN113010159 A CN 113010159A CN 202110310785 A CN202110310785 A CN 202110310785A CN 113010159 A CN113010159 A CN 113010159A
Authority
CN
China
Prior art keywords
task
page
target
script
identifying
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110310785.2A
Other languages
Chinese (zh)
Inventor
杨简闻
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Construction Bank Corp
Original Assignee
China Construction Bank Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Construction Bank Corp filed Critical China Construction Bank Corp
Priority to CN202110310785.2A priority Critical patent/CN113010159A/en
Publication of CN113010159A publication Critical patent/CN113010159A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/73Program documentation

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Library & Information Science (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a task processing method and device based on a script, and relates to the technical field of office automation. One embodiment of the method comprises: acquiring a task script written for a work task to be processed; the task script is used for identifying a target element of a target page, simulating operation indicated by a workflow at the position where the target element is identified, wherein the workflow is used for realizing the work task; and determining that the work task does not meet the set timing execution condition, and executing the task script on the target page to finish the work task. According to the implementation mode, the task script written for the work task is obtained, so that the target elements of the target page can be identified when the task script is executed, operations such as clicking and inputting are further simulated, manual operation is not needed, the labor cost is reduced, and the office efficiency is improved.

Description

Script-based task processing method and device
Technical Field
The invention relates to the technical field of office automation, in particular to a task processing method and device based on a script.
Background
In an office scene, there are many work contents that need to be processed in batches regularly, and these work contents have strong repeatability, tedious process and low execution difficulty, for example: the products under development or after development need to create a dispatch list at each change, such as viewing push content periodically. In order to deal with the above work, it is common in the prior art to arrange the relevant personnel for manual handling.
In the process of implementing the invention, the prior art at least has the following problems:
human resources are wasted, the office efficiency is influenced, and the working enthusiasm of workers is reduced.
Disclosure of Invention
In view of this, embodiments of the present invention provide a script-based task processing method and apparatus, where a task script written for a work task is obtained, so that a target element of a target page can be identified when the task script is executed, operations such as clicking and inputting are further simulated, manual operation is not needed, labor cost is reduced, and office efficiency is improved.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a script-based task processing method.
The task processing method based on the script comprises the following steps: acquiring a task script written for a work task to be processed; the task script is used for identifying a target element of a target page, simulating operation indicated by a workflow at the position where the target element is identified, wherein the workflow is used for realizing the work task; and determining that the work task does not meet the set timing execution condition, and executing the task script on the target page to finish the work task.
Optionally, the target page includes a login page, and the corresponding target elements include an account name input box, a password input box, and a login button; the identifying of the target element of the target page simulates the operation indicated by the workflow at the position where the target element is identified comprises the following steps: identifying an account name input box and a password input box of the login page, filling a set account name in the account name input box by using an input method, and filling a set password in the password input box; and identifying a login button of the login page, and clicking the login button by using a click method.
Optionally, the target page includes a task search page, and the corresponding target element includes a task search input box and a search button; the identifying of the target element of the target page simulates the operation indicated by the workflow at the position where the target element is identified comprises the following steps: identifying a task search input box of the task search page, and filling a set task number in the task search input box by using an input method; identifying a search button of the task search page, and clicking the search button by using a click method.
Optionally, the target page includes a task configuration page, and the corresponding target elements include a task name list, a task phase list, and a creation button; the identifying of the target element of the target page simulates the operation indicated by the workflow at the position where the target element is identified comprises the following steps: identifying a task name list of the task configuration page, and selecting a corresponding task name in the task name list by using a click method; the task configuration page is a page jumped to after the search button is clicked; identifying a task phase list of the task configuration page, and selecting a corresponding task phase in the task phase list by using a click method; and identifying a creating button of the task configuration page, and clicking the creating button by using a click method.
Optionally, the target page includes a task creation page, and the corresponding target element includes a personnel query input box and a submit button; the identifying of the target element of the target page simulates the operation indicated by the workflow at the position where the target element is identified comprises the following steps: identifying a personnel query input box of the task creation page, and searching a set personnel identifier in the personnel query input box; the task creating page is a page to which the search button is clicked or the creating button is skipped to; identifying a submit button of the task creation page, and clicking the submit button by using a click method.
Optionally, the target element further comprises a creation type drop-down box and a task description input box; the identifying of the target element of the target page simulates the operation indicated by the workflow at the position where the target element is identified comprises the following steps: identifying a creation type drop-down box of the task creation page, and selecting a corresponding creation type from the creation type drop-down boxes by using a click method; and identifying a task description input box of the task creation page, and inputting task description information in the task description input box by using an input method.
Optionally, the identifying a target element of a target page includes: and identifying the target elements of the target page according to the set element identification or style characteristics of the target elements.
Optionally, the timing execution condition includes: the tasks are performed periodically and the task parameters are known quantities or regularly varying.
Optionally, the task script is further configured to start a browser and open the target page.
Optionally, the method further comprises: and determining that the work task meets the timing execution condition, and acquiring a timing script to trigger the periodic execution of the task script on the target page by using the timing script.
Optionally, the task script is implemented based on a puppeteer test framework or a selenium test tool.
Optionally, after the step of executing the task script on the target page, the method further includes: and visually displaying an execution result generated by executing the task script.
Optionally, the method further comprises: and configuring a unique element identifier for the target element, and writing the target element and the corresponding element identifier into a configuration file.
To achieve the above object, according to another aspect of embodiments of the present invention, there is provided a script-based task processing apparatus.
The task processing device based on the script of the embodiment of the invention comprises: the acquisition module is used for acquiring a task script written for the work task to be processed; the task script is used for identifying a target element of a target page, simulating operation indicated by a workflow at the position where the target element is identified, wherein the workflow is used for realizing the work task; and the execution module is used for determining that the work task does not meet the set timing execution condition, executing the task script on the target page and finishing the work task.
Optionally, the target page includes a login page, and the corresponding target elements include an account name input box, a password input box, and a login button; the task script is also used for identifying an account name input box and a password input box of the login page, filling a set account name in the account name input box by using an input method, and filling a set password in the password input box; and identifying a login button of the login page, and clicking the login button by using a click method.
Optionally, the target page includes a task search page, and the corresponding target element includes a task search input box and a search button; the task script is also used for identifying a task search input box of the task search page, and filling a set task number in the task search input box by using an input method; and identifying a search button of the task search page, and clicking the search button by using a click method.
Optionally, the target page includes a task configuration page, and the corresponding target elements include a task name list, a task phase list, and a creation button; the task script is also used for identifying a task name list of the task configuration page and selecting a corresponding task name in the task name list by using a click method; the task configuration page is a page jumped to after the search button is clicked; identifying a task phase list of the task configuration page, and selecting a corresponding task phase in the task phase list by using a click method; and identifying a creating button of the task configuration page, and clicking the creating button by using a click method.
Optionally, the target page includes a task creation page, and the corresponding target element includes a personnel query input box and a submit button; the task script is also used for identifying a personnel query input box of the task creation page and searching a set personnel identifier in the personnel query input box; the task creating page is a page to which the search button is clicked or the creating button is skipped to; and identifying a submit button of the task creation page, and clicking the submit button by using a click method.
Optionally, the target element further comprises a creation type drop-down box and a task description input box; the task script is also used for identifying a creation type drop-down box of the task creation page, and selecting a corresponding creation type from the creation type drop-down box by using a click method; and identifying a task description input box of the task creation page, and inputting task description information in the task description input box by using an input method.
Optionally, the task script is further configured to identify a target element of the target page according to a set element identifier or style feature of the target element.
Optionally, the timing execution condition includes: the tasks are performed periodically and the task parameters are known quantities or regularly varying.
Optionally, the task script is further configured to start a browser and open the target page.
Optionally, the apparatus further comprises: and the timing processing module is used for determining that the work task meets the timing execution condition, acquiring a timing script and triggering the periodic execution of the task script on the target page by using the timing script.
Optionally, the task script is implemented based on a puppeteer test framework or a selenium test tool.
Optionally, the apparatus further comprises: and the display module is used for visually displaying the execution result generated by executing the task script.
Optionally, the apparatus further comprises: and the configuration module is used for configuring a unique element identifier for the target element and writing the target element and the corresponding element identifier into a configuration file.
To achieve the above object, according to still another aspect of embodiments of the present invention, there is provided an electronic apparatus.
An electronic device of an embodiment of the present invention includes: one or more processors; a storage device for storing one or more programs, which when executed by the one or more processors, cause the one or more processors to implement a script-based task processing method according to an embodiment of the present invention.
To achieve the above object, according to still another aspect of embodiments of the present invention, there is provided a computer-readable medium.
A computer-readable medium of an embodiment of the present invention has a computer program stored thereon, which, when executed by a processor, implements a script-based task processing method of an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: by acquiring the task script written for the work task, the target element of the target page can be identified when the task script is executed, operations such as clicking and inputting are further simulated, manual operation is not needed, labor cost is reduced, and office efficiency is improved. The account name input box, the password input box and the login button are identified on the login page, and the actions of inputting and clicking are simulated at the identified positions, so that the automatic login function is realized.
The automatic searching function is realized by identifying the task searching input box and the searching button on the task searching page and simulating the actions of inputting and clicking at the identified position. The automatic configuration function is realized by identifying a task name list, a task phase list and a creation button on a task configuration page and simulating a click action at the identified position. The function of automatically creating the task is realized by identifying a person query input box and a submit button on the task creating page, and simulating query and click actions at the identified position.
The creation type drop-down box and the task description input box are identified on the task creation page, and the actions of input and clicking are simulated at the identified positions, so that the task with richer attributes can be created. And identifying the target element based on the element identification or the style characteristic, so that the position of the target element on the target page is convenient to locate. By setting the timing execution condition, the work tasks meeting the timing execution condition can be periodically executed at regular time, and the office efficiency is further improved. When the work task is started to be executed, the browser is started through the task script, and the target page is opened, so that the subsequent work flow can be continued.
Compiling the task script based on puppeteer test frame or selenium test tool, can replace artifical work load in a large number, very big promotion work efficiency releases manpower resources, reduces the human cost, and then can be with more labour distribution on the work post that the degree of difficulty is higher. By visually displaying the execution result, developers can conveniently know the execution condition of the work task. The unique element identifier is set for the target element, so that the position of the target element on the target page can be conveniently identified subsequently.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main steps of a script-based task processing method according to an embodiment of the invention;
FIG. 2 is a main flow diagram of a script-based task processing method according to yet another embodiment of the present invention;
FIG. 3 is a main flow diagram of a script-based task processing method according to yet another embodiment of the present invention;
FIG. 4 is a schematic diagram of the main modules of a script-based task processing apparatus according to an embodiment of the present invention;
FIG. 5 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
FIG. 6 is a schematic diagram of a computer apparatus suitable for use in an electronic device to implement an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Terms related to the embodiments of the present invention are explained below.
puppieneer: js package is a node published by Chrome development team and is used for simulating the operation of Chrome browser. It provides a series of APIs to control the behavior of Chrome or Chrome browsers by the devtols Protocol. Under the default condition, puppeteer starts the Chrome in a header ess mode, the Chrome started in the mode does not display a page, and the Chrome can also be configured to start the Chrome in a non-header mode.
API: application Programming Interface, i.e., Application program Interface. An API is a predefined function that aims to provide applications and developers the ability to access a set of routines based on certain software or hardware, without having to access source code or understand the details of internal working mechanisms.
DevTools: the Web development and debugging tool is a set of Web development and debugging tools built in the Chrome, and can be used for iterating, debugging and analyzing websites.
As described in the background art, in an office scenario, for the work content that needs to be processed regularly in batch, the repeatability is strong, and the flow is tedious, the work content is usually processed manually. However, manual handling may result in waste of human resources, increase of human costs, and affect office efficiency. Therefore, the embodiment of the present invention provides a script-based task processing method, which can greatly reduce the labor cost and greatly improve the office efficiency, and is described in detail below.
Example one
Fig. 1 is a schematic diagram of main steps of a script-based task processing method according to an embodiment of the present invention. As shown in fig. 1, the task processing method based on script according to the embodiment of the present invention mainly includes the following steps:
step S101: and acquiring a task script written for the work task to be processed. The work task herein may have any one or more of the following characteristics: strong repeatability, fussy flow and regular execution. In the embodiment, the high repeatability may mean that the execution frequency of the work task is greater than a set frequency threshold, and the tedious process may mean that the operation steps of the work task are greater than a set number.
For a work task to be processed, the workflow of the work task needs to be combed, and then a task script is written based on a puppetee r test framework or a selenium test tool. The combing of the workflow is used for providing an integral logic framework for writing the task script. The task script includes program code for identifying a target element of the target page, and program code for simulating an operation indicated by the workflow at a location where the target element is identified. The operation here includes operations such as clicking, inputting, and the like.
When the target element of the target page is identified, the target element can be identified according to the preset element identification or the style characteristic. For the way of identifying the target element by using the element identifier, when the program code of the target page is written, a unique element identifier needs to be configured for the target element, and the target element and the corresponding element identifier are written into a configuration file. When the target element is identified, the corresponding target element can be determined by identifying the element identifier of the target page and inquiring the configuration file according to the identified element identifier.
In an embodiment, the Style feature may refer to a CSS (Cascading Style sheets) Style of a page element, including a Style of input box, a Style of button, a Style of list, and the like. For the way of identifying the target element by using the style characteristics, that is, identifying whether the target element of the target page has the specified style characteristics, if the specified style characteristics are satisfied, the target element can be identified as the corresponding target element. For example, if a target element satisfies the input box style, it may be identified as an input box.
In a preferred embodiment, the task script further includes program code for launching a browser, opening the target page, such that a target element of the target page can be subsequently identified, and simulating an operation indicated by the workflow at the location where the target element is identified.
After the task script is written, the task script is stored, and when a work task needs to be executed, for example, a task execution instruction is received, the corresponding task script is directly obtained according to a task identifier carried in the task execution instruction.
Step S102: judging whether the work task meets the set timing execution condition, if not, executing the step S103; otherwise, step S104 is executed. The timing execution condition comprises that the task is executed periodically, and the task parameter is a known quantity or changes regularly. The task parameters are the task scripts of which the known quantity indicates that each time the work task is executed, the task parameters contained in the task scripts do not need to be modified. The task parameters are changed regularly, which means that the task parameters can be modified directly through the program codes when the task script of the work task is executed each time.
The step is to judge whether the work task needs to be executed periodically, and at the same time, judge whether the task parameter is a known quantity or changes regularly. The periodic execution refers to a periodic repeated execution, such as a fixed time per day, a weekly execution, a monthly execution, and the like. The regular change means that the change of the required task parameter has a fixed rule every time the task script is executed, for example, a fixed step length is increased and decreased every time the task script is executed.
If the work task needs to be executed periodically and the task parameters are known quantities, the work task meets the timing execution condition; if the work task needs to be executed periodically and the task parameters are unknown but change regularly, the work task also meets the timing execution condition; and if the work task does not need to be executed periodically or the task parameters are unknown and have irregular change, the work task does not meet the timing execution condition.
Step S103: and executing the task script on the target page to complete the work task. And for the work tasks which do not meet the timing execution condition, directly running the task script on the target page to finish the work tasks.
Step S104: and acquiring the timing script to trigger the periodic execution of the task script on the target page by using the timing script. The timing script can be written for the work tasks which need to be executed periodically and do not need to modify the parameters of each task in each execution and the work tasks which need to be executed periodically and can modify the parameters of the tasks through the program codes in each execution.
Wherein the timing script includes program code for implementing periodic execution. For the work tasks meeting the timing execution condition, a timing script needs to be obtained, the timing script is used for triggering the automatic execution of the task script, and the risk of missing execution caused by manual maintenance is reduced.
Example two
Fig. 2 is a main flow diagram of a script-based task processing method according to still another embodiment of the present invention. As shown in fig. 2, the task processing method based on script according to the embodiment of the present invention, which takes a login task as a to-be-processed work task, mainly includes the following steps:
step S201: and acquiring a task script written for the login task. In this embodiment, the login task needs to be executed at eight am every day, and the account name and password required for login are fixed. For this login task, the work flow of combing out is as follows: open browser → enter page website → enter corresponding login page → enter account name and password → click login button → complete login.
And writing a task script corresponding to the login task based on the puppeteer test framework by combining the work flow. The task script includes an address bar for starting a browser, identifying a home page of the browser, inputting a web address of a page in the address bar, opening a login page, a program code for identifying an account name input box and a password input box in the login page, a program code for filling the account name input box and the password input box with an account name and a password, respectively, a program code for identifying a login button in the login page, and a program code for clicking the login button.
The operation of filling account names and passwords in the task script is realized by using an input method, and the operation of clicking the login button is realized by using a click method. And after the task script is compiled, storing the task script. And when a task execution instruction is received, directly acquiring the task script according to a task identifier carried in the task execution instruction.
Step S202: and determining that the login task meets the set timing execution condition. The timing execution condition comprises that the task is executed periodically, and the task parameter is a known quantity or changes regularly. Since the login task needs to be executed at eight am every day, and the account name and password required for login are fixed, i.e. the login task needs to be executed periodically, and the task parameters are known, so that it meets the timing execution condition, and step S203 is executed.
Step S203: and acquiring the timing script to trigger the periodic execution of the task script on the target page by using the timing script. The timing script includes program code for implementing eight am execution of the login task each day. The timing script is used to trigger the task script to automatically execute eight am each day. The service logic realized by the task script comprises the following steps:
(1) starting a browser, and identifying an address bar of a home page of the browser;
(2) inputting a page website in an address bar, and opening a login page;
(3) identifying an account name input box and a password input box in a login page, filling a set account name in the account name input box by using an input method, and filling a set password in the password input box by using the input method;
(4) and identifying a login button in the login page, and clicking the login button by using a click method to complete a login task.
EXAMPLE III
Fig. 3 is a main flowchart illustrating a script-based task processing method according to still another embodiment of the present invention. As shown in fig. 3, the task processing method based on script according to the embodiment of the present invention uses a dispatch list to create a task as a work task to be processed, and mainly includes the following steps:
step S301: and acquiring a task script for creating a task writing for the work order. The task parameters required to be used by the work order creating task in this embodiment include a task number and a person identifier of the work order to be created. Where the task number is related to the actual demand, is not a known quantity, and is irregular, it needs to be manually configured before each execution of the task script. Meanwhile, the frequency of creating the dispatch list is related to the on-line period of the task, which is generally one month.
For the dispatch order creation task, the combed workflow is as follows: new tab page → jump to login page for creating work order → input account name and password → click login button → enter task search page → input task number → click search button → enter task configuration page → click task name → click task stage → click create button → enter task create page → select create type → input task description information → search personnel identification → click submit button → completion of work order creation.
And writing a task script corresponding to the work order creating task based on the puppeteer testing framework by combining the work flow. A puppieeer is a node.js packet, which is communicated with a Chrome browser by calling an open interface of Chrome DevTo ols, and can be used for simulating the running of the Chrome browser, and after the packet is introduced, the operation of a user on a page can be simulated through a program code, for example, the user jumps to a page address needing to be operated, and inputs, clicks and the like on the page.
In this embodiment, the task script includes a program code for creating a tab page and jumping to a login page, a program code for implementing a login function, a program code for implementing a task search function, a program code for implementing a task configuration function, and a program code for implementing a task creation function. After the task script is written, the task script can be stored, and when a task execution instruction is received, the task script can be obtained directly according to a task identifier carried in the task execution instruction.
Step S302: and determining that the work order creating task does not meet the timing execution condition. The timing execution condition comprises that the task is executed periodically, and the task parameter is a known quantity or changes regularly. Since the task parameter, i.e., the task number required for creating the dispatch list, is not a known quantity and is irregular, it does not satisfy the timing execution condition, and step S303 is executed.
Step S303: and executing the task script on the target page to complete the dispatch list creation task. According to the workflow, the work flow shows that the work order needs to be created by operating a login page, a task search page, a task configuration page and a task creation page, so that the target page in the embodiment comprises the pages. The task script implemented business logic comprises:
(1) building a new label page, and jumping to a login page for creating a work order;
(2) identifying an account name input box and a password input box in a login page, filling a set account name in the account name input box by using an input method, and filling a set password in the password input box by using the input method;
(3) identifying a login button in a login page, clicking the login button by using a click method, and entering a task search page;
(4) identifying a task search input box of a task search page, and inputting a set task number in the task search page by using an input method;
(5) identifying a search button of a task search page, clicking the search button by using a click method, and entering a task configuration page;
(6) identifying a task name list of a task configuration page, and selecting a corresponding task name in the task name list by using a click method; identifying a task phase list of a task configuration page, and selecting a corresponding task phase in the task phase list by using a click method;
(7) identifying a creating button of a task configuration page, clicking the creating button by using a click method, and entering a task creating page;
(8) identifying a creation type drop-down box of a task creation page, and selecting a corresponding creation type from the creation type drop-down boxes by using a click method; identifying a task description input box of a task creation page, and inputting task description information in the task description input box by using an input method;
(9) identifying a personnel query input box of a task creation page, and sequentially searching personnel identification of a work order to be created in the personnel query input box;
(10) and identifying a submission button of the task creation page, clicking the submission button by using a click method, and completing the work order creation task.
It is understood that the business logic implemented by the task script in the third embodiment is only an example, and in the business logic, steps (2) - (3) are used for implementing the login function, steps (4) - (5) are used for implementing the task search function, steps (6) - (7) are used for implementing the task configuration function, and steps (8) - (10) are used for implementing the task creation function. When the method is actually used, business logic in the task script can be increased or decreased according to the workflow corresponding to the work task. For example, when only the search task needs to be implemented, the business logic includes steps (4) - (5).
In another embodiment, when the dispatch list is created, task creation can be directly performed without task configuration, that is, after the search button is clicked in step (5), a jump is directly made to the task creation page. The business logic realized by the task script at this time comprises steps (1) - (5) and steps (8) - (10), or comprises steps (1) - (5) and steps (9) - (10).
According to the script-based task processing method, the worksheet creating task is processed by compiling the task script based on puppeteer, so that the office efficiency is improved, and the labor cost is reduced.
Fig. 4 is a schematic diagram of main modules of a script-based task processing device according to an embodiment of the present invention. As shown in fig. 4, a script-based task processing apparatus 400 according to an embodiment of the present invention mainly includes:
the obtaining module 401 is configured to obtain a task script written for a to-be-processed work task. For a work task to be processed, the workflow of the work task needs to be combed, and then a task script is written based on a puppeteer test framework or a selenium test tool. The combing of the workflow is used for providing an integral logic framework for writing the task script. The task script includes program code for identifying a target element of the target page, and program code for simulating an operation indicated by the workflow at a location where the target element is identified.
When the target element of the target page is identified, the target element can be identified according to the preset element identification or the style characteristic. For the way of identifying the target element by using the element identifier, when the program code of the target page is written, a unique element identifier needs to be configured for the target element, and the target element and the corresponding element identifier are written into a configuration file. When the target element is identified, the corresponding target element can be determined by identifying the element identifier of the target page and inquiring the configuration file according to the identified element identifier.
In an embodiment, style features may refer to CSS styles for page elements, including a checkbox style, a button style, a list style, and so on. For the way of identifying the target element by using the style characteristics, that is, identifying whether the target element of the target page has the specified style characteristics, if the specified style characteristics are satisfied, the target element can be identified as the corresponding target element. For example, if a target element satisfies the input box style, it may be identified as an input box.
After the task script is written, the task script is stored, and when a work task needs to be executed, for example, a task execution instruction is received, the corresponding task script is directly obtained according to a task identifier carried in the task execution instruction.
An executing module 402, configured to determine that the work task does not meet a set timing execution condition, execute the task script on the target page, and complete the work task. The timing execution condition comprises that the task is executed periodically, and the task parameter is a known quantity or changes regularly. And judging whether the work task meets the timing execution condition, if not, executing the task script on the target page to complete the work task.
In addition, the script-based task processing apparatus 400 according to the embodiment of the present invention may further include: a timing processing module, a presentation module and a configuration module (not shown in fig. 4). And the timing processing module is used for determining that the work task meets the timing execution condition, acquiring a timing script and triggering the periodic execution of the task script on the target page by using the timing script.
And the display module is used for visually displaying the execution result generated by executing the task script. And the configuration module is used for configuring a unique element identifier for the target element and writing the target element and the corresponding element identifier into a configuration file.
From the above description, it can be seen that the task script written for the work task is obtained, so that the target elements of the target page can be identified when the task script is executed, operations such as clicking and inputting are further simulated, manual operation is not needed, the labor cost is reduced, and the office efficiency is improved.
Fig. 5 illustrates an exemplary system architecture 500 of a script-based task processing method or a script-based task processing device to which embodiments of the present invention may be applied.
As shown in fig. 5, the system architecture 500 may include terminal devices 501, 502, 503, a network 504, and a server 505. The network 504 serves to provide a medium for communication links between the terminal devices 501, 502, 503 and the server 505. Network 504 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 501, 502, 503 to interact with a server 505 over a network 504 to receive or send messages or the like. The terminal devices 501, 502, 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 505 may be a server that provides various services, such as a background management server that processes a task execution instruction sent by an administrator using the terminal apparatuses 501, 502, and 503. The background management server can acquire the task script, execute the task script, and feed back a processing result (e.g., an execution result) to the terminal device.
It should be noted that the script-based task processing method provided in the embodiment of the present application is generally executed by the server 505, and accordingly, the script-based task processing device is generally disposed in the server 505.
It should be understood that the number of terminal devices, networks, and servers in fig. 5 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
The invention also provides an electronic device and a computer readable medium according to the embodiment of the invention.
The electronic device of the present invention includes: one or more processors; a storage device for storing one or more programs, which when executed by the one or more processors, cause the one or more processors to implement a script-based task processing method according to an embodiment of the present invention.
The computer readable medium of the present invention has stored thereon a computer program which, when executed by a processor, implements a script-based task processing method of an embodiment of the present invention.
Referring now to FIG. 6, shown is a block diagram of a computer system 600 suitable for use with the electronic device implementing an embodiment of the present invention. The electronic device shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU)601 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data necessary for the operation of the computer system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, a mouse, and the like; an output portion 607 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The driver 610 is also connected to the I/O interface 605 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 610 as necessary, so that a computer program read out therefrom is mounted in the storage section 608 as necessary.
In particular, the processes described above with respect to the main step diagrams may be implemented as computer software programs, according to embodiments of the present disclosure. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program containing program code for performing the method illustrated in the main step diagram. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 609, and/or installed from the removable medium 611. The computer program performs the above-described functions defined in the system of the present invention when executed by the central processing unit (CP U) 601.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes an acquisition module and an execution module. The names of these modules do not in some cases constitute a limitation on the module itself, and for example, the acquisition module may also be described as a "module that acquires a task script written for a work task to be processed".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: acquiring a task script written for a work task to be processed; the task script is used for identifying a target element of a target page, simulating operation indicated by a workflow at the position where the target element is identified, wherein the workflow is used for realizing the work task; and determining that the work task does not meet the set timing execution condition, and executing the task script on the target page to finish the work task.
According to the technical scheme of the embodiment of the invention, the task script written for the work task is obtained, so that the target element of the target page can be identified when the task script is executed, the operations such as clicking, inputting and the like are further simulated, manual operation is not needed, the labor cost is reduced, and the office efficiency is improved.
The product can execute the method provided by the embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method. For technical details that are not described in detail in this embodiment, reference may be made to the method provided by the embodiment of the present invention.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (17)

1. A task processing method based on script is characterized by comprising the following steps:
acquiring a task script written for a work task to be processed; the task script is used for identifying a target element of a target page, simulating operation indicated by a workflow at the position where the target element is identified, wherein the workflow is used for realizing the work task;
and determining that the work task does not meet the set timing execution condition, and executing the task script on the target page to finish the work task.
2. The method of claim 1, wherein the target page comprises a login page, and wherein the corresponding target elements comprise an account name entry box, a password entry box, and a login button;
the identifying of the target element of the target page simulates the operation indicated by the workflow at the position where the target element is identified comprises the following steps:
identifying an account name input box and a password input box of the login page, filling a set account name in the account name input box by using an input method, and filling a set password in the password input box;
and identifying a login button of the login page, and clicking the login button by using a click method.
3. The method of claim 1, wherein the target page comprises a task search page, and the corresponding target elements comprise a task search input box and a search button;
the identifying of the target element of the target page simulates the operation indicated by the workflow at the position where the target element is identified comprises the following steps:
identifying a task search input box of the task search page, and filling a set task number in the task search input box by using an input method;
identifying a search button of the task search page, and clicking the search button by using a click method.
4. The method of claim 3, wherein the target page comprises a task configuration page, and wherein the corresponding target elements comprise a task name list, a task phase list, and a create button;
the identifying of the target element of the target page simulates the operation indicated by the workflow at the position where the target element is identified comprises the following steps:
identifying a task name list of the task configuration page, and selecting a corresponding task name in the task name list by using a click method; the task configuration page is a page jumped to after the search button is clicked;
identifying a task phase list of the task configuration page, and selecting a corresponding task phase in the task phase list by using a click method;
and identifying a creating button of the task configuration page, and clicking the creating button by using a click method.
5. The method of claim 4, wherein the target page comprises a task creation page, and the corresponding target elements comprise a people query input box and a submit button;
the identifying of the target element of the target page simulates the operation indicated by the workflow at the position where the target element is identified comprises the following steps:
identifying a personnel query input box of the task creation page, and searching a set personnel identifier in the personnel query input box; the task creating page is a page to which the search button is clicked or the creating button is skipped to;
and identifying a submission button of the task creation page, and clicking the submission button by using a click method.
6. The method of claim 5, wherein the target element further comprises a create type drop-down box and a task description input box;
the identifying of the target element of the target page simulates the operation indicated by the workflow at the position where the target element is identified comprises the following steps:
identifying a creation type drop-down box of the task creation page, and selecting a corresponding creation type from the creation type drop-down boxes by using a click method;
and identifying a task description input box of the task creation page, and inputting task description information in the task description input box by using an input method.
7. The method of claim 1, wherein identifying the target element of the target page comprises:
and identifying the target elements of the target page according to the set element identification or style characteristics of the target elements.
8. The method of claim 1, wherein the timing execution condition comprises: the tasks are performed periodically and the task parameters are known quantities or regularly varying.
9. The method of claim 1, wherein the task script is further configured to launch a browser to open the target page.
10. The method of claim 1, further comprising:
and determining that the work task meets the timing execution condition, and acquiring a timing script to trigger the periodic execution of the task script on the target page by using the timing script.
11. The method of any one of claims 1 to 10, wherein the task script is implemented based on a puppeteer test framework or a selenium test tool.
12. The method of claim 11, wherein after the step of executing the task script on the target page, the method further comprises:
and visually displaying an execution result generated by executing the task script.
13. The method of claim 7, further comprising:
and configuring a unique element identifier for the target element, and writing the target element and the corresponding element identifier into a configuration file.
14. A script-based task processing apparatus, comprising:
the acquisition module is used for acquiring a task script written for the work task to be processed; the task script is used for identifying a target element of a target page, simulating operation indicated by a workflow at the position where the target element is identified, wherein the workflow is used for realizing the work task;
and the execution module is used for determining that the work task does not meet the set timing execution condition, executing the task script on the target page and finishing the work task.
15. The apparatus of claim 14, wherein the target page comprises a login page, and wherein the corresponding target elements comprise an account name entry box, a password entry box, and a login button;
the task script is also used for identifying an account name input box and a password input box of the login page, filling a set account name in the account name input box by using an input method, and filling a set password in the password input box; and
and identifying a login button of the login page, and clicking the login button by using a click method.
16. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-13.
17. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-13.
CN202110310785.2A 2021-03-23 2021-03-23 Script-based task processing method and device Pending CN113010159A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110310785.2A CN113010159A (en) 2021-03-23 2021-03-23 Script-based task processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110310785.2A CN113010159A (en) 2021-03-23 2021-03-23 Script-based task processing method and device

Publications (1)

Publication Number Publication Date
CN113010159A true CN113010159A (en) 2021-06-22

Family

ID=76405735

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110310785.2A Pending CN113010159A (en) 2021-03-23 2021-03-23 Script-based task processing method and device

Country Status (1)

Country Link
CN (1) CN113010159A (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108920146A (en) * 2018-06-05 2018-11-30 广州衡昊数据科技有限公司 Page control assembly and visual Simulation operating system
CN109783389A (en) * 2019-01-22 2019-05-21 未来电视有限公司 Element control automatic test approach, device and electronic equipment
WO2020006864A1 (en) * 2018-07-06 2020-01-09 平安科技(深圳)有限公司 Browser input box display method and apparatus, computer device, and storage medium
CN110888709A (en) * 2019-12-04 2020-03-17 中山市凯能集团有限公司 Intelligent operation method and device of monitoring screen, computer equipment and storage medium
CN111090864A (en) * 2019-12-12 2020-05-01 中国信息安全测评中心 Penetration test frame system, penetration test platform and penetration test method
CN111597485A (en) * 2019-02-21 2020-08-28 北京易数科技有限公司 Information presentation method and device
CN111881392A (en) * 2020-07-08 2020-11-03 中国建设银行股份有限公司 Page display method and device

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108920146A (en) * 2018-06-05 2018-11-30 广州衡昊数据科技有限公司 Page control assembly and visual Simulation operating system
WO2020006864A1 (en) * 2018-07-06 2020-01-09 平安科技(深圳)有限公司 Browser input box display method and apparatus, computer device, and storage medium
CN109783389A (en) * 2019-01-22 2019-05-21 未来电视有限公司 Element control automatic test approach, device and electronic equipment
CN111597485A (en) * 2019-02-21 2020-08-28 北京易数科技有限公司 Information presentation method and device
CN110888709A (en) * 2019-12-04 2020-03-17 中山市凯能集团有限公司 Intelligent operation method and device of monitoring screen, computer equipment and storage medium
CN111090864A (en) * 2019-12-12 2020-05-01 中国信息安全测评中心 Penetration test frame system, penetration test platform and penetration test method
CN111881392A (en) * 2020-07-08 2020-11-03 中国建设银行股份有限公司 Page display method and device

Similar Documents

Publication Publication Date Title
CA2915619C (en) Method and apparatus for customized software development kit (sdk) generation
US11389960B2 (en) Systems and methods for robotic process automation
CN110597564A (en) Installation package construction and service component loading method, device and terminal equipment
CN112015654A (en) Method and apparatus for testing
CN110795181A (en) Application program interface display method and device based on skip protocol and electronic equipment
CN109002282B (en) Method and device for realizing animation effect in web page development
CN112988185A (en) Cloud application updating method, device and system, electronic equipment and storage medium
CN109814957B (en) Label adding method and device for IOS (input/output system)
CN112181477A (en) Complex event processing method and device and terminal equipment
CN112835568A (en) Project construction method and device
CN113760736A (en) Test method, device and system
CN112905225A (en) Method and device for creating continuous integration tool construction task
CN116661936A (en) Page data processing method and device, computer equipment and storage medium
CN113010159A (en) Script-based task processing method and device
CN110928672B (en) Task arranging method, device and equipment and storage medium
CN113326079A (en) Service version switching method, switching device, electronic equipment and storage medium
CN113095060A (en) Method, device, equipment and computer readable medium for processing data
CN113312900A (en) Data verification method and device
CN111176982A (en) Test interface generation method and device
CN111124386A (en) Unity-based animation event processing method, device, equipment and storage medium
CN111367641B (en) Timing method and system based on Internet of things
CN111367597A (en) Color switching method and device and electronic equipment
EP4216097A1 (en) Method, system, equipment and medium for modifying the layering layer information of finite element model unit
CN118132069A (en) Page circulation control method and device and electronic equipment
CN111367517B (en) Information generation method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination