Chapter: Basic Principles of--selenium Automation (fifth lecture)
NetEase Cloud Classroom:
http://study.163.com/course/courseLearn.htm?courseId=712011#/learn/video?lessonId=878101&courseId=712011
Note: In fact, all things should be used first, but the basic tools are the same, the bottom is the most basic content of the implementation, the test should do is:
(1) Skilled use of tools to understand the pros and cons of each tool, to achieve the tool optimization, due to the purpose of local conditions
(2) Read the source code, understand the principle, can be open source source code for two times re-creation, adapted to the tool for their own products, or directly write a suitable tool for testing
(3) to be able to analyze and locate the anomalies that occur during the test, and to evaluate the test results in detail and systematically (need to be able to analyze the positioning problem, we must understand their products, but more need is the underlying code and operating system in-depth analysis and understanding, this is the key)
Today's companies are testing development and testing is too open, test development is just the development of tools for the so-called test use: The two should be combined, the test must be in-depth understanding of the function, in accordance with functional requirements and testing requirements to self-production of better testing tools
Main content and notes:
First, the reason of learning selenium
Project needs
Logical understanding of:
The mobile app client initiates a request to the database, returns the content to the mobile app, and simultaneously updates the Web page to get instructions to the database side, and vice versa.
Web display and app client need to communicate in real time, web display and test related need to use selenium.
Native Driver: A simplified version of Google's selenium, a simplified version of selenium in Android, used to test the phone's local app and provide a Webdriver-style API. This must be compiled at the time to generate a relative jar package, if the native driver jar package, you can not use native driver do automated testing, the limitations are relatively large, but the principle is similar to selenium
The basic principles are described below:
1, after installing the APK to the simulator, will communicate with the framework framework, the server will be a 4444 port, through this port to communicate with the framework, through this port can get all the controls, and then according to the three different ways (Path, ID and classname) to locate the control.
2, the client program needs to be deployed in the automation script, and then you can write your own test program, the program for the client side of the androiddriver, give it instructions, and then the client will pass http+ The Jscon method accesses the server on the emulator to perform the appropriate simulation operation.
On the principle of selenium
1, Selenium Introduction: web-based automated testing tools, compatibility is very good, Chrome, Firefox, IE and other browser can be good use,
2, Download: On the official web page can see the following four items
Selenium IDE: A Firefox plugin (a Firefox Plugin)
Selenium Server (formerly named: Selenium RC Server)
The Internet Explorer Driver Server
Selenium Client & Webdriver Language Bindings (language-specific, suggested Java, Python)
Recommended for use with selenium RC
Look at the source code:
1. Server--driverservlet (CORE)
Inherit HttpServlet, can get this request and response HTTP, you can set the response header in the service function, and then be able to transfer
(Consolidation: ADB port is 5037,selenium server port is 4444)
Note: Android Dumpsys meminfo, Memory analysis contains four: Total, Rss (physical memory), stack memory, virtual memory
2, flick--sliding--the core is based on the control
Like Robotium, get all the element--> of the web get the coordinates point--call the Flick method to slide, the parameter is Elementlocation,xoffset,yoffset,speed
Another: Setjsonparameter, which sets Jason's parameters,
Format of network data transmission:
(1) Json, format: [{' xxx ': xxx, ' xxx ': xxx},{...}], in fact, compared to a Python dictionary, anyway, is defined by a format, convenient for you to transfer and parse, parsing is through a special format for you to find a field, And then get to the value of this field
(2) SAX: Dynamic parsing
(3) XML, format: all pairs appear,<xxx></xxx>
(4) INI? Should generally use INI relatively little bar, recently wrote a project with the INI, the other did not do research, anyway INI is unable to change line
3, Longpresselement (similar to Robotium's Clicklongonscreen method):
The basic principles are all the same, get the element, get the coordinate point, call the Longpress method
How to find element: (the basic principles are similar: pass parameters, and then find a match with this parameter, but can be obtained by the following three ways)
1. Path
2. ID
3, ClassName
Core: Coordinates interact with controls--find controls, position coordinates, manipulate coordinates
Three, selenium demo
Write script:
1. Initialization
2, TestCase
3, after the teardown inside Selenium.stop ()
"Golden Sun Test" Android Automation-learning process: Selenium principle Preliminary