Simple example of Appium + JUnit

Source: Internet
Author: User
Tags appium

Import static Junit.framework.assert.asserttrue;import static Org.junit.assert.*;import Org.junit.after;import Org.junit.before;import org.junit.test;import java.net.url;import io.appium.java_client. Appiumdriver;import Io.appium.java_client.android.androiddriver;import Org.openqa.selenium.by;import Org.openqa.selenium.remote.capabilitytype;import Org.openqa.selenium.remote.desiredcapabilities;public Class appiumtestcase {appiumdriver driver; @Beforepublic void SetUp () throws Exception {desiredcapabilities capabilities = new D Esiredcapabilities (); Capabilities.setcapability (Capabilitytype.browser_name, ""); Capabilities.setcapability (" Platforname "," Android "); Capabilities.setcapability (" DeviceName "," 05157df53de0042b "); capabilities.setcapability ("Platformversion", "6.0.1"), Capabilities.setcapability ("Apppackage", "Com.sec.android.app.popupcalculator"); Capabilities.setcapability ("Appactivity", ". Calculator ");d river = new Androiddriver (New URL (" Http://127.0.0.1:4723/wd/hub "), capabilities);} @afterpublic void TearDown () throws Exception {Driver.quit ();} @SuppressWarnings ("deprecation") @Testpublic void Test1 () {driver.findelement (By.name ("9")). Click (); Driver.findelement (By.name ("5")). Click ();d river.findelement (by.name ("+")). Click ();d river.findelement (By.name (" 6 "). Click ();d river.findelement (by.name (" = ")). Click (); Asserttrue (" OK ", Driver.findelement (By.name (" 101 ")). Isdisplayed ());} @SuppressWarnings ("deprecation") @Testpublic void Test2 () {driver.findelement (By.name ("9")). Click (); Driver.findelement (By.name ("5")). Click ();d river.findelement (by.name ("+")). Click ();d river.findelement (By.name (" 7 "). Click ();d river.findelement (by.name (" = ")). Click (); Asserttrue (" OK ", Driver.findelement (By.name (" 102 ")). Isdisplayed ());}}

  

Simple example of Appium + JUnit

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.