Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of locating bug in Web Test

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

In the process of web testing, we often encounter errors in the display of content or data on the page, or even do not display them. The first reaction is BUG. To learn more about the problem with this BUG, testers need to master it. You can simply use the browser to bring its own developer tools and database tools to check.

Common tools for bug positioning

Firefox--firebug 、 web developer 、 live http headers 、 http fox

IE plug-in-httpwatch

Third-party tool-fiddler

Slow Network Simulation tool-- firefox throttle

Front desk error

The bug of the foreground is usually related to function, interface and compatibility, and there are many aspects related to jstl,jsp,js,css,html. There are mainly two pieces of bug, the first is that there is a problem with JS, which you can press F12 to open the console and view the error information in console, the general browser will display the error report jS, for the error js can view the corresponding error resource file under Sources, basically will find the cause of the error variables are not defined, parameters are not defined, JS errors are easy to solve.

The second is the bug in the page, now the web project basically does not do static pages are dynamic, so your page either uses a small script or uses EL expressions to store values. If you report an error on the page, you can see your error line number and nearby code on the console, you can find it yourself.

If the image is not displayed, right-click the image in Google browser and click "check", (Firefox right-click "use firebug to view elements") find out the properties of the image on the open console and enter it into the browser's address. If you can open the picture, then the problem of not displaying the picture is the problem in the background; if the browser cannot open the picture, it is the problem at the front end.

Use of developer tools (chrom browser)

(1) Open developer tools and select tools-developer tools in the browser menu bar. The shortcut key is F12.

(2) switch to the Network tab after opening it, and you can see the request response.

(3) Select the response link and switch to the Preview tab to see the result data of the response. Switch to the Headers tab to see the requested address, method, result and other information.

(4) you can see the returned data fields and values in the Response result.

You can judge where some bug is based on the value of the response.

(1) if there is no data in the response, the backend data is not returned, and if the frontend display is empty, it is a backend problem. For example, a new data is added to the list, but it is not displayed. If you can see that the data total is 0 in the request, the backend data is not returned.

(2) there is data in the response, but the front-end display is wrong. You can judge whether there is a wrong field display in the front-end display according to the field value, and you can judge that it is the front-end problem. For example, if the content on the B side is wrong and the login user name shows the login account number, you can see whether the data is returned correctly in the response, and if the data is returned correctly and displays an error, it may be an error in the front-end binding field.

(3) there is data in the response, but it is not consistent with the result of your operation. You can query according to the database. If there is no record in the database, there may be something wrong with the code and your operation is not recorded. For example, if you register an account, but you are prompted with the wrong account or password when you log in, you can check whether there is any registered data in the database table.

Background error

Look for errors according to the background log file

Background involves servlet,jms,ejb, there are many frameworks, struts,hibernate,spring,ibatis and so on. Bug is difficult to change, but easy to find. The main thing is to check the console to report an error, and then locate the error line number. If there is nothing wrong with the configuration file, the general error is a null pointer, or the array subscript is out of bounds. Look at the nearby variables, look at the parameters of the method can basically locate the error.

General situation of restart:

(1) Hot deployment (add some features, or modify some bug) (2) release a new version (the whole system) (3) memory overflow, restart the server at this time

Because there is a thread program in the project, the. / shutdown script closes the tomcat program and cannot shut down all the started threads, resulting in an error that the server startup thread is not closed, so

General steps to restart Tomcat in a Linux system: (usually shut down the process and then restart it. If / to delete a file: rm file name, or a folder that is not empty: rm-rf folder name)

Cd usr/local/ Test server name / bin

Ps-exf / / look at the main process of the project running under the test server (the first number is the PID process number)

Kill-9 PID / / forcibly shuts down the main process of a project

. / startup.sh /. / * * .sh executes the restart shell script file. At this time, under the bin of the test server, you can directly execute it. The rest can also be executed by adding the chmod axix shell script file. /

(little knowledge:

Differences between ps aux and ps-ef commands

Ps aux uses BSD format to display the java process.

The items displayed are: USER,PID,%CPU,%MEM,VSZ,RSS,TTY,STAT,START,TIME,COMMAND

Ps-ef displays the java process in a standard format

The items displayed are: UID,PID,PPID,C,STIME,TTY,TIME,CMD)

How to view logs

Multiple applications can be deployed on one server

Cd usr/local/ test server name / logs / / go to the server's logs directory first

Tail-f catalina.out / / monitors the tail of the catalina.out file (default 10 lines)

Common problems in the log

Get the problems commonly encountered in log files:

(1) Encoding problem: tomcat is new and needs to be changed to modify tomcat's server.xml file.

In particular, projects under windows are redeployed to the linux system.

(2) Null pointer: program problems, generally do not take into account the null situation, or the data constrained by the main foreign key is empty, or delete the associated data, resulting in null

(3) the length is too long, exceeding the maximum length. After the test environment modifies the database field length, the production environment is not modified, resulting in an error!

(4) illegal data

(5) memory overflow: restart

Summary of the causes of general problems

Program: empty judgment, add, delete, change and check, and the interfaces called by different official accounts are also different.

Data initialization: database table structure and data initialization, permission configuration

The fault cannot be repeated at present:

(1) look at the log and locate the reason according to the log, then construct a test case test with the same conditions according to the log prompt in the test environment, and try to reproduce the problem in the test environment. Ask about development

(2) what are the differences between the test environment and configuration and the actual engineering environment and configuration, etc. At the same time, take the initiative to discuss with development leaders, project implementers and experienced project managers to analyze the possible causes.

Inconsistent configuration environment leads to

Test environment ok, failed to save when the production environment is added, check the backend log report length overflow, database content field requirements are inconsistent with the production environment

Accessibility: linux and SQL

Linux View Log

SQL is used to filter data or modify data status directly, and it is often used to connect front and back processes during integration testing.

Jsp can't tell the difference between foreground and background, because it involves a run-time problem, and their run-time is different. After the user makes the request, the server parses the user's request and goes to the corresponding jsp. At this time, it can be said that the entire jsp is the daemon. After the Jsp responds, the content of the response is returned to the browser. At this time, the browser only sees html,css,javascript, and at this time all programs are foreground programs.

Web console of Firefox browser

Open it as follows: click [tools] on the menu

Web console page display

Google browser developer tools

Press F12 to open it, and the page appears as follows:

Element tag: this tag is used to view the HTML tag elements of the page, that is, to view the source code, we can see the layout, we can see the styles used, the links used, and so on.

Console tag: this is a web console that allows you to view messages, errors or warnings, and output after a web page is running.

Sources tag: this is to display the resource file, you can view the running script, debugging is generally in the Sources debugging

1. The selection box is used to select resources, and the files requested from the server when the web page is loaded include files such as .html. Ccs. JS.

two。 The place where this place is used to debug js code is very important. You can see that there is a blue label on the line number, and this label is power off. When we need to debug the program, make a power outage, and then debug it through the 3 toolbar. Then the debugging process will not be explained in detail, that is, turning on a power outage and then refreshing the page program will be adjusted to the place where you break the point. Then use 4 to see the value of the variable in the program.

3. The first button in the stop state indicates whether the program has stopped (in debug), followed by the program continuing to skip the method, skipping the next statement, and calling to the previous statement.

Network tag: this is the common tool for grabbing packages. You can see when the scripts and resources are loaded on the web page, and you can also see some resources that cannot be loaded successfully.

So this page is used to grab the package. We need to analyze the request of the page. For example, simulating login and everything needs to analyze how the program is executed in the background. Then, we can see Headers (request message header) Preview (Preview) Timing (request time) Cookie and so on.

There is also a toolbar at the top, with a red dot and a button with a still symbol, so these two buttons, when they are red, indicate that the current request is not empty (but the request here is a request not to jump to the page. When you jump to a new page, the request will also be cleared), and the latter button clears the request.

There is also a toolbar below, which is mainly used to select and filter request messages.

Below you can see the timeline, which is to record the time from the beginning to the end of a request.

Note: when you need to request to another page, you need to check Preserve log when your request is not empty, and let the red button show red.

TimeLiness tag: this is the request time

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 224

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report