Use Appium to manipulate chrome on your mobile device

Source: Internet
Author: User

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

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.