Selenium's Android Use learning

Source: Internet
Author: User

20140507

Selenium is generally used in Web automation, why can Android also use it?

, mobile phone and DB linkage: The client side of the mobile phone to the server to send data flow, the deletion and check operation, this write data update with update, updated counter +1, indicating that the mobile phone side of the server has a visit, there is a deal;

DB (such as MySQL) will be synced to the Web page for everyone to see, send a message to the Web page, said there is a deal,

After the page is displayed, give the DB a message to tell the user what to see.

The server where the DB is located is connected via Httpsocket, which tells the phone client to synchronize the contents of the page.

That is, the mobile phone client only accounted for about one-third of the background of the key value of the check, Web page synchronization display and so on.

On the left is native Driver, and on the right is selenium.

Native driver is a simplified version of Google Selenium, which is an implementation of the Webdriver API that uses the native UI instead of the browser UI's automated test framework to run functional tests for Android applications. Google's decision to reuse the Webdriver API for native applications rather than creating entirely new interfaces should have many similarities between the two--they all control the same UI actions, such as tapping, typing, reading text, and switching windows. And users who are familiar with Webdriver do not need to learn another API to start using Nativedriver immediately. It is run on Android and is incorporated into the framework frame.

If you want to use Nativedriver, when compiling the version, such as Xiaomi, compile the framework to add, and finally generate two jar package, the two jar package into project, you can reference nativedriver for automated testing. Get a cell phone if you don't have the native bag, you won't be able to do the automated test.

The above figure, Native driver There are two things, the yellow part, one is the server, one is the client, look at the left of the figure, apk loaded into the mobile phone, through the framework layer (specifically instrumentation framework) to communicate with the underlying (this is not what good Lin said about the architecture), the server will start a port called 4444, and the apk to communicate, then the port service will read out the framework of the view, read out and then determine which control, Is it a button or a text box? Selenium there are three ways to find controls: 1. Path 2. ID 3. ClassName Then look at the client side of the right, which is to be deployed in your own automation script.

QTP more powerful than selenium, all kinds of browsers support, can screen contrast, assertion, are automatic, but for people, there is no meaning. Selenium is an open source automation framework that can be used wherever it is, and too expensive.

Selenium has four versions, RC is the earliest, now called Webdriver, script beautiful concise.

LR evaluates performance and is used by large enterprises.

Selenium is a powerful family of open-source web functional testing tools for Throughtworks, which now includes the following four main sections:

1. Selenium Core: A test case that supports DHTML (Dynamic Hypertext) (similar to data-driven testing), which is the engine of the Selenium IDE and Selenium RC. The advantage is that writing test cases is simple, support most browsers, the disadvantage is the need to install remotely, selenium language also limits the possibility of complex cases, and there is no good external expansion, this will be a fatal problem. Because a test tool can not be 100% to meet your testing needs, when it does not meet your testing needs, it must have an extension mechanism to allow you to use other ways to meet your needs, otherwise this test software even if the function is powerful, please think again, otherwise when the large amount of resources, Only to find that some problems can not be solved, it was late, this is Mr. Kim's firsthand.

2. Selenium IDE: Firefox is a plugin that only supports Firefox. Download it and drag it directly into Firefox, there is a recorder, very silly to operate.

3. Selenium Server (formerly known as Selenium RC Server): is the primary.

4. Selenium Grid:

The IDE and HTA are not focused, because now 360 browsers are mainstream. The middle of the two emphasis is spoken.

Code Analysis Workflow:

Interview frequently asked: Flick icon format

Server port

Compare Robotium (Get view view find control and call touch)

Select three ways to find WebView the first is path the second is the ClassName method The third is the ID

Selenium's api:http://selenium.googcode.com/git/docs/api/java/index.html

1. Download tortoisesvn (small turtle, the advantage is to download to where, in the local open, download, OK), here is: Http://selenium/googlecode.com/svn/trunk

2. After downloading, there are four files: Thrid-party;selenium-common;server--selenium (can't find, don't know why)

3. Important class: Driverservlet Server Core class in Server--selenium

Location: Server--selenium/src/org/openqa/selenium/remote/server/driverservlet.java

public class Driverservlet extends httpservlet{

protected void service xxxx--service port is 4444, often asked during interview

App Port 5037?

}

Dumpsys Meminfo to see the memory in the Linux adb shell, or use top to view

Total memory RSS physical memory stack memory Dalvik virtual machine memory

After the top command, there is rss--physical memory;

Flick class-Sliding-core is a control-based

Flick.java: Logic

1. Get the webelement, then get its coordinates; go flick (slide), slide from left to right, offset how much

if (ElementID!=null) {

webelement element = Getknowelements (). get (ElementID);

Coordinates elementlocation = ((locatable) Element). getcoordinate

Touchsreen.flick (Elementlocation,xoffset,yoffset,speed);

}else {

Touchsreen.flick (Xspeed,yspeed);

return resulttype.success;

Android Common formats:

Format of JSON [{"Name": "Ianthe",},] key-value pairs

SAX side loading side read into previous memory small common

}

Recall here Robtium: first getview-throw it into the ArrayList, then to determine which control, then GetXXX (x,y,xxx)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.