Recently in the positive efforts of learning Appium, today successfully run the official online demo, here to do a small summary:
Pre-preparatory work:
(1) Install Chrome on the real machine or emulator you want to run.
Note: x86 virtual machine is not supported, but after I tried to do a good job or use the real machine.
(2) Make sure you install the Appium directory: appiumforwindows-1.3.4.1\appium\node_modules\appium\build\chromedriver\windows Whether there are chromedriver.exe in the
Appium configuration such as:
The code is as follows:
PackageCom.wap;Importio.appium.java_client. Appiumdriver;ImportIo.appium.java_client.remote.MobileCapabilityType;ImportJava.net.URL;ImportOrg.junit.After;ImportOrg.junit.Assert;ImportOrg.junit.Before;Importorg.junit.Test;Importorg.openqa.selenium.By;Importorg.openqa.selenium.WebElement;Importorg.openqa.selenium.remote.DesiredCapabilities; Public classwaptest {appiumdriver driver; @Before Public voidSetUp ()throwsException {desiredcapabilities desiredcapabilities=Newdesiredcapabilities (); Desiredcapabilities.setcapability (Mobilecapabilitytype.browser_name,"Chrome"); Desiredcapabilities.setcapability ("PlatformName", "Android"); Desiredcapabilities.setcapability ("DeviceName", "my"); URL URL=NewURL ("Http://127.0.0.1:4723/wd/hub"); Driver=Newappiumdriver (URL, desiredcapabilities); } @After Public voidTearDown ()throwsException {driver.quit (); } @Test Public voidTest () {Driver.get ("Http://saucelabs.com/test/guinea-pig"); Webelement Div= Driver.findelement (By.id ("i_am_an_id")); Assert.assertequals ("I am a div", div.gettext ());//check the text retrieved matches expected valueDriver.findelement (By.id ("comments")). SendKeys ("My comment");//Populate }}
Attention:
The version of Java-client-jar is 1.5
Welcome to Exchange.
Use Appium to manipulate chrome on your mobile device