Method and terminal for detecting WEB website page language

文档序号:1535551 发布日期:2020-02-14 浏览:17次 中文

阅读说明:本技术 一种web网站页面语言的检测方法及终端 (Method and terminal for detecting WEB website page language ) 是由 刘德建 易巧静 谢姝丽 陈强 陈婷 王柟 曹佛宝 俞发仁 林琛 于 2018-07-17 设计创作,主要内容包括:本发明提供一种WEB网站页面语言的检测方法及终端,通过存储WEB网站的所有html网页并进行遍历,自动识别每个html页面的页面语言,对所述页面语言进行检测,将繁琐耗时的人工操作转变为自动化操作,使得测试人员不必花费大量的时间去验证页面中边边角角的文字,节约了测试时间,提高了测试效率。(The invention provides a method and a terminal for detecting WEB page languages of a WEB website, which are used for automatically identifying the page language of each html page by storing and traversing all html pages of the WEB website, detecting the page language and converting tedious and time-consuming manual operation into automatic operation, so that a tester does not need to spend a great deal of time to verify characters at corner angles in the pages, the testing time is saved, and the testing efficiency is improved.)

1. A method for detecting WEB site page language is characterized by comprising the following steps:

s1, storing all html pages of the WEB website;

and S2, traversing all the stored html pages, automatically identifying the page language of each html page, and detecting the page language.

2. The method for detecting WEB site page language of claim 1, wherein the step S1 includes the steps of:

s11, initializing the website, and switching the language version of the WEB website into a first language version;

s12, judging whether the current page exists or not, if so, executing a step S16, otherwise, executing a step S13;

s13, creating a directory locally according to the web page address of the current page, saving the hypertext stream of the current page into an html page by using a UI automation tool, and storing the html page in the created directory;

s14, identifying the jump link in the html page through the DOM locator, and storing the jump link into the path array of the corresponding layer according to the layer to which the jump link belongs;

s15, judging whether the path array of the current layer is empty, if yes: step S16 is executed, otherwise: step S17 is executed;

s16, finishing the traversal of the path array of the current layer, and returning to the path array of the previous layer;

s17, judging whether the traversal of all the hierarchical path arrays is completed, if not, executing the step S18;

s18, taking out the jump link of the next path in the path array of the current layer, simulating click operation by using a UI automation tool, jumping to the html page corresponding to the jump link, and returning to the step S12.

3. The method for detecting WEB site page language of claim 2, wherein the step S2 of automatically identifying the page language of each html page includes:

acquiring tag information of the html page by using a DOM (document object model) locator, and storing IDs (identity) and characters in the tag information into a first temporary set as key value pairs respectively;

traversing the first temporary set, deleting key value pairs corresponding to punctuation marks in the first set, and converting the values in the remaining key value pairs into unicode codes;

storing the converted key-value pairs to a second temporary set.

4. The method for detecting WEB site page language of claim 3, wherein the step S2 of detecting the page language includes:

traversing the second temporary set, identifying the values of the key value pairs in the second temporary set by using a regular expression, judging whether the values are in the first language, and if not, storing the key value pairs corresponding to the values into a third temporary set;

and taking the directory path of the current html page as a key, and recording the third temporary set as a value corresponding to the key into the global set.

5. The method for detecting WEB site page language of claim 4, further comprising the steps of:

and S3, judging whether the global set is empty, if so, indicating that the detection is passed, otherwise, not, writing the global set and the detection result into a test report and outputting the test report.

6. A detection terminal for WEB site page language comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, and is characterized in that the processor implements the following steps when executing the computer program:

s1, storing all html pages of the WEB website;

and S2, traversing all the stored html pages, automatically identifying the page language of each html page, and detecting the page language.

7. The WEB site page language detection terminal as claimed in claim 6, wherein said S1 includes the steps of:

s11, initializing the website, and switching the language version of the WEB website into a first language version;

s12, judging whether the current page exists or not, if so, executing a step S16, otherwise, executing a step S13;

s13, creating a directory locally according to the web page address of the current page, saving the hypertext stream of the current page into an html page by using a UI automation tool, and storing the html page in the created directory;

s14, identifying the jump link in the html page through the DOM locator, and storing the jump link into the path array of the corresponding layer according to the layer to which the jump link belongs;

s15, judging whether the path array of the current layer is empty, if yes: step S16 is executed, otherwise: step S17 is executed;

s16, finishing the traversal of the path array of the current layer, and returning to the path array of the previous layer;

s17, judging whether the traversal of all the hierarchical path arrays is completed, if not, executing the step S18;

s18, taking out the jump link of the next path in the path array of the current layer, simulating click operation by using a UI automation tool, jumping to the html page corresponding to the jump link, and returning to the step S12.

8. The WEB site page language detection terminal of claim 7, wherein the step S2 of automatically identifying the page language of each html page includes:

acquiring tag information of the html page by using a DOM (document object model) locator, and storing IDs (identity) and characters in the tag information into a first temporary set as key value pairs respectively;

traversing the first temporary set, deleting key value pairs corresponding to punctuation marks in the first set, and converting the values in the remaining key value pairs into unicode codes;

storing the converted key-value pairs to a second temporary set.

9. The terminal for detecting WEB site page language of claim 8, wherein the step S2 of detecting the page language includes:

traversing the second temporary set, identifying the values of the key value pairs in the second temporary set by using a regular expression, judging whether the values are in the first language, and if not, storing the key value pairs corresponding to the values into a third temporary set;

and taking the directory path of the current html page as a key, and recording the third temporary set as a value corresponding to the key into the global set.

10. The WEB site page language detection terminal according to claim 9, further comprising the steps of:

and S3, judging whether the global set is empty, if so, indicating that the detection is passed, otherwise, not, writing the global set and the detection result into a test report and outputting the test report.

Technical Field

The invention relates to the field of language detection, in particular to a method and a terminal for detecting WEB page language.

Background

When a system develops to a certain degree, languages of all countries in the world need to be compatible, and the language compatibility comprises dynamic data of background management configuration, static characters rendered by a server, static characters rendered by js and the like.

At present, a detection scheme for WEB page languages is that a tester manually operates to traverse a WEB site, and manually judges whether language versions are correctly switched, wherein dynamic data configured by background management is difficult to be covered in all directions, and a verification result is obtained after operations such as item replacement or data clearing are possibly required. If the website is switched to each language, testers are required to walk through the website without dead angles, the workload required here is undoubtedly huge, the working efficiency is extremely low, meanwhile, information such as prompt boxes, static characters and the like of corners and corners inside the website can be omitted, and in addition, the coverage of dynamic data of background configuration management is not high, so that the obstruction is brought to international language testing.

Disclosure of Invention

The technical problem to be solved by the invention is as follows: the test method and the terminal for WEB website page language detection are provided, so that automatic test is realized, and the test efficiency is improved.

In order to solve the technical problems, the invention adopts the technical scheme that:

a method for detecting WEB site page language is characterized by comprising the following steps:

s1, storing all html pages of the WEB website;

and S2, traversing all the stored html pages, automatically identifying the page language of each html page, and detecting the page language.

In order to solve the technical problem, the invention adopts another technical scheme as follows:

a detection terminal for WEB site page language comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, and is characterized in that the processor implements the following steps when executing the computer program:

s1, storing all html pages of the WEB website;

and S2, traversing all the stored html pages, automatically identifying the page language of each html page, and detecting the page language.

The invention has the beneficial effects that: the page language of each html page is automatically identified by storing and traversing all html pages of a WEB website, the page language is detected, and complicated and time-consuming manual operation is converted into automatic operation, so that a tester does not need to spend a large amount of time to verify characters of corner angles in the page, the testing time is saved, and the testing efficiency is improved.

Drawings

FIG. 1 is a flowchart of a method for detecting WEB page language according to an embodiment of the present invention;

FIG. 2 is a schematic structural diagram of WEB page language detection according to an embodiment of the present invention;

FIG. 3 is a schematic view illustrating a page storage process for WEB page language detection according to an embodiment of the present invention;

FIG. 4 is a schematic view illustrating a page identification detection process of WEB page language detection according to an embodiment of the present invention;

description of reference numerals:

1. a WEB website language detection terminal; 2. a memory; 3. a processor.

Detailed Description

In order to explain technical contents, achieved objects, and effects of the present invention in detail, the following description is made with reference to the accompanying drawings in combination with the embodiments.

The most key concept of the invention is to store and traverse all html pages of a WEB website, automatically identify the page language of each html page and detect the page language.

Referring to fig. 1, a method for detecting WEB page languages includes the steps of:

s1, storing all html pages of the WEB website;

and S2, traversing all the stored html pages, automatically identifying the page language of each html page, and detecting the page language.

From the above description, the beneficial effects of the present invention are: the page language of each html page is automatically identified by storing and traversing all html pages of a WEB website, the page language is detected, and complicated and time-consuming manual operation is converted into automatic operation, so that a tester does not need to spend a large amount of time to verify characters of corner angles in the page, the testing time is saved, and the testing efficiency is improved.

Further, the S1 includes the steps of:

s11, initializing the website, and switching the language version of the WEB website into a first language version;

s12, judging whether the current page exists or not, if so, executing a step S16, otherwise, executing a step S13;

s13, creating a directory locally according to the web page address of the current page, saving the hypertext stream of the current page into an html page by using a UI automation tool, and storing the html page in the created directory;

s14, identifying the jump link in the html page through the DOM locator, and storing the jump link into the path array of the corresponding layer according to the layer to which the jump link belongs;

s15, judging whether the path array of the current layer is empty, if yes: step S16 is executed, otherwise: step S17 is executed;

s16, finishing the traversal of the path array of the current layer, and returning to the path array of the previous layer;

s17, judging whether the traversal of all the hierarchical path arrays is completed, if not, executing the step S18;

s18, taking out the jump link of the next path in the path array of the current layer, simulating click operation by using a UI automation tool, jumping to the html page corresponding to the jump link, and returning to the step S12.

According to the description, all the pages of the WEB site can be automatically stored in the specific steps, so that the tedious and time-consuming manual storage operation is avoided, the test coverage rate is improved, and the missing test risk is avoided.

Further, the step S2 of automatically identifying the page language of each html page includes:

acquiring tag information of the html page by using a DOM (document object model) locator, and storing IDs (identity) and characters in the tag information into a first temporary set as key value pairs respectively;

traversing the first temporary set, deleting key value pairs corresponding to punctuation marks in the first set, and converting the values in the remaining key value pairs into unicode codes;

storing the converted key-value pairs to a second temporary set.

According to the description, the tag information of the html page can be completely acquired by acquiring the tag information of the html page through the DOM locator; and respectively storing the ID and the characters in the label information as key value pairs, deleting the key value pairs with punctuation marks, and converting the values in the remaining key value pairs into unicode codes so as to conveniently identify and detect the unicode codes by using a regular expression subsequently to judge whether the html page has a non-first language.

Further, the detecting the page language in step S2 includes:

traversing the second temporary set, identifying the values of the key value pairs in the second temporary set by using a regular expression, judging whether the values are in the first language, and if not, storing the key value pairs corresponding to the values into a third temporary set; and taking the directory path of the current html page as a key, and recording the third temporary set as a value corresponding to the key into the global set.

As can be seen from the above description, by identifying unicode codes of the values of the second temporary set through regular expressions, it can be accurately determined whether the values are in the first language; and storing the key value pairs which are identified and judged by the regular expression and are in the non-first language and the corresponding directory paths, wherein the stored directory paths are convenient for acquiring the page position information of the non-first language in the test report.

Further, the method also comprises the following steps:

and S3, judging whether the global set is empty, if so, indicating that the detection is passed, otherwise, not, writing the global set and the detection result into a test report and outputting the test report.

As can be seen from the above description, writing the global set and the detection result into the test report and outputting the test report facilitates the analysis of the problems and defects found by the tester when reading the test report.

Referring to fig. 2, a test terminal for WEB page language includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the following steps when executing the computer program:

s1, storing all html pages of the WEB website;

and S2, traversing all the stored html pages, automatically identifying the page language of each html page, and detecting the page language.

From the above description, the beneficial effects of the present invention are: the page language of each html page is automatically identified by storing and traversing all html pages of a WEB website, the page language is detected, and complicated and time-consuming manual operation is converted into automatic operation, so that a tester does not need to spend a large amount of time to verify characters of corner angles in the page, the testing time is saved, and the testing efficiency is improved.

Further, the S1 includes the steps of:

s11, initializing the website, and switching the language version of the WEB website into a first language version;

s12, judging whether the current page exists or not, if so, executing a step S16, otherwise, executing a step S13;

s13, creating a directory locally according to the web page address of the current page, saving the hypertext stream of the current page into an html page by using a UI automation tool, and storing the html page in the created directory;

s14, identifying the jump link in the html page through the DOM locator, and storing the jump link into the path array of the corresponding layer according to the layer to which the jump link belongs;

s15, judging whether the path array of the current layer is empty, if yes: step S16 is executed, otherwise: step S17 is executed;

s16, finishing the traversal of the path array of the current layer, and returning to the path array of the previous layer;

s17, judging whether the traversal of all the hierarchical path arrays is completed, if not, executing the step S18;

s18, taking out the jump link of the next path in the path array of the current layer, simulating click operation by using a UI automation tool, jumping to the html page corresponding to the jump link, and returning to the step S12.

According to the description, all the pages of the WEB site can be automatically stored in the specific steps, so that the tedious and time-consuming manual storage operation is avoided, the test coverage rate is improved, and the missing test risk is avoided.

Further, the step S2 of automatically identifying the page language of each html page includes:

acquiring tag information of the html page by using a DOM (document object model) locator, and storing IDs (identity) and characters in the tag information into a first temporary set as key value pairs respectively;

traversing the first temporary set, deleting key value pairs corresponding to punctuation marks in the first set, and converting the values in the remaining key value pairs into unicode codes;

storing the converted key-value pairs to a second temporary set.

According to the description, the tag information of the html page can be completely acquired by acquiring the tag information of the html page through the DOM locator; and respectively storing the ID and the characters in the label information as key value pairs, deleting the key value pairs with punctuation marks, and converting the values in the remaining key value pairs into unicode codes so as to conveniently identify and detect the unicode codes by using a regular expression subsequently to judge whether the html page has a non-first language.

Further, the detecting the page language in step S2 includes:

traversing the second temporary set, identifying the values of the key value pairs in the second temporary set by using a regular expression, judging whether the values are in the first language, and if not, storing the key value pairs corresponding to the values into a third temporary set; and taking the directory of the current html page as a key, and recording the third temporary set as a value corresponding to the key into the global set.

As can be seen from the above description, by identifying unicode codes of the values of the second temporary set through regular expressions, it can be accurately determined whether the values are in the first language; and storing the key value pairs which are identified and judged by the regular expression and are in the non-first language and the corresponding directory paths, wherein the stored directory paths are convenient for acquiring the page position information of the non-first language in the test report.

Further, the method also comprises the following steps:

and S3, judging whether the global set is empty, if so, indicating that the detection is passed, otherwise, not, writing the global set and the detection result into a test report and outputting the test report.

As can be seen from the above description, writing the global set and the detection result into the test report and outputting the test report facilitates the analysis of the problems and defects found by the tester when reading the test report.

Referring to fig. 1, fig. 3 and fig. 4, a first embodiment of the present invention is:

a method for detecting WEB site page language includes the following steps:

s1, storing all html pages of the WEB website;

and S2, traversing all the stored html pages, automatically identifying the page language of each html page, and detecting the page language.

Wherein the S1 includes the steps of:

s11, initializing the website, and switching the language version of the WEB website into a first language version, such as a non-Chinese version;

s12, judging whether the current page exists, if so, representing that the html page is cached, and executing a step S16, otherwise, executing a step S13;

s13, creating a directory locally according to the web page address of the current page, saving the hypertext stream of the current page into an html page by using a UI automation tool, and storing the html page in the created directory;

s14, identifying the jump link in the html page through the DOM locator, and storing the jump link into the path array of the corresponding layer according to the layer to which the jump link belongs;

s15, judging whether the path array of the current layer is empty, if yes: step S16 is executed, otherwise: step S17 is executed;

s16, finishing the traversal of the path array of the current layer, and returning to the path array of the previous layer;

s17, judging whether the traversal of all the hierarchical path arrays is completed, if not, executing the step S18;

s18, taking out the jump link of the next path in the path array of the current layer, simulating click operation by using a UI automation tool, jumping to the html page corresponding to the jump link, and returning to the step S12 until the website traversal is completed.

Wherein the step S2 includes the steps of:

and S21, traversing and taking out the html page according to the html page directory saved in the step S1.

S22, acquiring html page tag information by using a DOM locator, wherein the html page tag information comprises dynamic data returned by a server, characters in a page js, static characters rendered at the head and the bottom of the page and the like, and the ID and the characters in the tag information are respectively used as keys and values and stored in a first temporary set, such as mapA, as key value pairs, namely key and value.

S23, traversing mapA, deleting the key value pair corresponding to the punctuation mark in the mapA median (for example, "classmate, hello", change to "classmate hello" after the processing is completed), converting the values in the rest key value pairs into unicode codes, and storing the converted key and value into a second temporary set, such as mapB.

S24, traversing the mapB, and identifying the value in the mapB set by using the regular expression.

S25, judging whether the value is Chinese or not, if not: step S27 is executed, if yes: storing the value with non-Chinese and the corresponding key into a third temporary set, such as mapC, and recording the directory path of the current html page into the ArrayList set.

S26, judging whether the traversal of mapB is finished, if so: step S27 is executed, otherwise: step S24 is executed.

S27, taking the directory path of the current html page as a key, and storing the mapC as a value corresponding to the key into the global map.

S28, judging whether the directory of the html page is traversed and finished, if not: step S21 is executed, if yes: judging whether the global map has a value, if so: and when the Chinese character is detected, the test fails, and the global map data is recorded into the test report, otherwise: the verification of the web page language version is passed;

and finally outputting a test report (the test report comprises a test result, namely pass/fail, and if the test result is fail, the path address, Chinese characters and the like of the html page containing Chinese are recorded in the test report).

Referring to fig. 2, the second embodiment of the invention is:

a detection terminal 1 for WEB site page language comprises a memory 2, a processor 3 and a computer program which is stored on the memory 2 and can run on the processor 3, wherein the steps in the first embodiment are realized when the processor 3 executes the computer program.

In summary, according to the detection method and the terminal for WEB pages of a WEB site provided by the invention, all html pages of the WEB site are stored and traversed, the page language of each html page is automatically identified, the page language is detected, and tedious and time-consuming manual operation is converted into automatic operation, so that a tester does not need to spend a great deal of time to verify the characters of the corner angles in the pages, the test time is saved, and the test efficiency is improved; an automatic tool is used for scanning the html page and automatically identifying the language, so that the test coverage rate is improved, the integrity of page test is ensured, and the test missing risk is avoided; taking the current directory path as a key value, taking the temporary mapC set as a value, and recording the value into the global set, wherein the directory path stored in the key is convenient for acquiring page position information of a non-first language in a test report subsequently, so that the recorded information of a test result is complete, the positioning problem of a tester is convenient, and a guarantee is provided for international testing; through the unicode coding of the values of the mapB set in the regular expression form, whether Chinese exists in the html page tag information or not can be accurately judged.

The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all equivalent changes made by using the contents of the present specification and the drawings, or applied directly or indirectly to the related technical fields, are included in the scope of the present invention.

11页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:基于地质本体的地质报告文本信息提取方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!