A simple test case implemented by Appium

Source: Internet
Author: User

A few days ago in the construction of appium environment, suffering from project emergency, did not solve a sliding problem, after the network of data search, now I learn the process of stepping on the pit record down.

Issue: App installation implementation, launch implementation, but no swipe. The reason: The sliding code is not placed under the @test, and the sleep time is too short, the latter coordinates are too small. The code is implemented as follows:

Package Com.glen.demo;

Import Io.appium.java_client. Appiumdriver;
Import Io.appium.java_client.android.AndroidDriver;

Import Org.junit.After;
Import Org.junit.Before;
Import Org.junit.Test;
Import Org.openqa.selenium.By;
Import Org.openqa.selenium.remote.CapabilityType;
Import org.openqa.selenium.remote.DesiredCapabilities;

Import Java.io.File;
Import Java.net.URL;


public class Contactstest {
private static Appiumdriver driver;
@Before

public void SetUp () throws Exception {
Set the path of the APK
File Classpathroot = new file (System.getproperty ("User.dir"));
File Appdir = new file (Classpathroot, "apps");
File app = new file (appdir, "dreamhouse.apk");
Setting Automation-related parameters
Desiredcapabilities capabilities = new Desiredcapabilities ();
Capabilities.setcapability (Capabilitytype.browser_name, "");
Capabilities.setcapability ("PlatformName", "Android");
Capabilities.setcapability ("DeviceName", "Dreamhouse");
Setting up the Android system version
Capabilities.setcapability ("Platformversion", "4.2.2");
Set APK path
Capabilities.setcapability ("App", App.getabsolutepath ());
Set the app's main package name and main class name
Capabilities.setcapability ("Apppackage", "COM.UAMA.DREAMHOUSEFORLC");
Capabilities.setcapability ("Appactivity", "com.uama.dreamhouseforlc.actvity.LaunchActivity");
Initialization
Driver = new Appiumdriver (New URL ("Http://127.0.0.1:4723/wd/hub"), capabilities);
Driver = new Androiddriver (New URL ("Http://127.0.0.1:4723/wd/hub"), capabilities);
}

@After
public void TearDown () throws Exception {
Driver.quit ();
System.out.println ("Fww");
}


@Test
public void swipe () throws interruptedexception{
Thread.Sleep (10000);
int width = driver.manage (). window (). GetSize (). width;
int height = driver.manage (). window (). GetSize (). Height;
Driver.swipe (width *7/8, HEIGHT/6, WIDTH/8, HEIGHT/6, 500);
System.out.println ("Slide the first page");
Driver.swipe (width *7/8, HEIGHT/6, WIDTH/8, HEIGHT/6, 500);
Thread.Sleep (5000);
System.out.println ("Slide second page");
Driver.swipe (width *7/8, HEIGHT/6, WIDTH/8, HEIGHT/6, 500);
System.out.println ("Sliding the third page");
Thread.Sleep (5000);
Thread.Sleep (5000);
Driver.findelement (By.name ("Enable Now"). Clear ();
}

}


The eclipse structure jar is as follows:

650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/84/3C/wKioL1eI8CnQh5bbAAIC9-85VsA896.jpg-wh_500x0-wm_3 -wmp_4-s_176203552.jpg "title=" 11.jpg "alt=" Wkiol1ei8cnqh5bbaaic9-85vsa896.jpg-wh_50 "/>

The key is the jar package, please email me if you have any questions: [email protected]

or join Hangzhou appium Automation Test Professional Group: 239226112

This article is from "Ghost" blog, please make sure to keep this source http://fangwei009.blog.51cto.com/5234706/1826852

A simple test case implemented by Appium

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.