Appium (Windows platform): Appium Run Cheat (2)

Source: Internet
Author: User
Tags appium testng android sdk manager lenovo

We will install the software in the article and so on to download, ready, we begin to do the following.

1. After opening eclipse, after expanding Android and testng, make sure you have these displays


If not, click Window->customize perspective->command Groups availability to check the options on Android


2. Click the Android SDK Manager button


3. Ensure that the following SDK are downloaded, this download according to the Android API version of your phone download, my phone is 4.2.1, so download to API17, this is very important, because when running appium need to sync matching.


4. After downloading, create a normal Java project (File->new->java project), then create the package, and then create a Xxx.java file. For example: Appium like this

5. Mail click Appium folder, then to Properties->java Build path->libraries->add External JARS

Import the selenium,java-client-1.5.0,org.testng.eclipse_6.8.6.20141201_2240 into the ( Note: Selenium section, you want to compress all the packages in. All files in the end of the jar are imported. )

6. Write Xxx.java content, such as my example: (This example is for an example of a An Zuojin machine)

Package appium;

Import Io.appium.java_client. Appiumdriver;

Import Java.io.File;
Import java.net.MalformedURLException;
Import Java.net.URL;
Import Java.util.concurrent.TimeUnit;

Import Org.openqa.selenium.WebDriver;
Import Org.openqa.selenium.remote.CapabilityType;
Import org.openqa.selenium.remote.DesiredCapabilities;
Import Org.testng.annotations.Test;

public class Appium {
Webdriver Dr;
@Test
public void testApp () throws malformedurlexception,interruptedexception{
String contact= "1jyot";

File App=new file ("d:\\apk\\com.sina.weibo.apk");//store apk on the phonehere is the address where you store the apk you want to test
Desiredcapabilities capabilities=new desiredcapabilities ();
Capabilities.setcapability (Capabilitytype.browser_name, "");
Capabilities.setcapability ("DeviceName", "lenovo-lenovo_a828t-d1d4c874");//lenovo a828tThis is the name of your machine.
Capabilities.setcapability ("Platformversion", "4.2.1");here is the Android version of your phone, please go to mobile phone information to view
Capabilities.setcapability ("PlatformName", "Android");here is your platform information
Capabilities.setcapability ("PlatformName", "Android");
Capabilities.setcapability ("App", App.getabsolutepath ());here to get your apk
Capabilities.setcapability ("Apppackage", "Com.sina.weibo");here is your apk in the package information, which requires you to use the APK anti-compilation software to view the
Capabilities.setcapability ("Appactivity", ". Maintabactivity ");here is the information about the activity in your apk that launches the app.

Capabilities.setcapability ("Appactivity", ". Switchuser "); Note: The reason for this change here is that there was an error called never start up. Maintabactivity. Current is. Switchuser that this activity is not opened, the currently open page is. Switchuser's activity, so it won't be an error.

Capabilities.setcapability ("Apppackage", "com.broadvision.myvmoso.phone.myvmoso.enterprise");
Capabilities.setcapability ("Appactivity", "com.broadvision.myv_vmoso.myVmoso.MyVmosoMainActivity");// Com.broadvision.myv_vmoso.myVmoso.MyVmosoMainActivity
Capabilities.setcapability ("App-wait-activity", "activity-to-wait-for");
Dr=new Appiumdriver (New URL ("Http://127.0.0.1:4723/wd/hub"), capabilities);

Dr.manage (). Timeouts (). implicitlywait (5, timeunit.seconds);
}
}
7. Connect your phone to your computer.

After you open devices to Eclipse->window->show view->others->devices, you will see the information of your connected phone


8. Open Appium

Set the following

Then, click Start Server.

Note here is that if your phone is Android 4.2 version, then the API is 17,appium only support API18 above, 18 under the selendroid to run, that is, you want to choose this

9. Go back to Eclipse and right click on Xxx.java->run as->testng

10. Finally check the operation of the Appium, there are some problems during operation, these problems may be caused by the app itself, it may be caused by Appium server. Good luck to all of you.

11. Correct running Results


high-end automated test Exchange Group : 310924886



Appium (Windows platform): Appium Run Cheat (2)

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.