• 大佬的微信号加密过的

  • import io.appium.java_client.MobileElement;
    import io.appium.java_client.android.AndroidDriver;
    import org.junit.After;
    import org.junit.Before;
    import org.junit.Test;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.util.concurrent.TimeUnit;

    import org.openqa.selenium.remote.DesiredCapabilities;

    public class CloudMusic {

    private AndroidDriver driver;

    @Before
    public void setUp() throws MalformedURLException {
    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
    desiredCapabilities.setCapability("platformName", "android");
    desiredCapabilities.setCapability("appPackage", "com.netease.cloudmusic");
    desiredCapabilities.setCapability("appActivity", ".activity.LoadingActivity");
    desiredCapabilities.setCapability("deviceName", "CloudMusic");
    desiredCapabilities.setCapability("noReset", true);

    URL remoteUrl = new URL("http://localhost:4723/wd/hub");

    driver = new AndroidDriver(remoteUrl, desiredCapabilities);
    driver.manage().timeouts().implicitlyWait(5,TimeUnit.SECONDS);
    }

    @Test
    public void sampleTest() throws InterruptedException {

    //点击搜索
    driver.findElementByAccessibilityId("搜索").click();
    Thread.sleep(3000);

    //搜索框输入
    driver.findElementById("com.netease.cloudmusic:id/search_src_text").sendKeys("Good Time");

    //回车
    driver.pressKeyCode(66);

    Thread.sleep(3000);

    //选中歌曲,开始播放
    MobileElement el1 =(MobileElement) driver.findElementByXPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.RelativeLayout/android.support.v4.view.ViewPager/android.widget.ListView/android.widget.LinearLayout[2]/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.TextView");
    el1.click();

    Thread.sleep(3000);

    //3秒后暂停播放
    driver.findElementByAccessibilityId("播放暂停").click();

    }

    @After
    public void tearDown() {
    driver.quit();
    }
    }

  • import io.appium.java_client.MobileElement;
    import io.appium.java_client.TouchAction;
    import io.appium.java_client.android.AndroidDriver;
    import io.appium.java_client.android.GsmCallActions;
    import io.appium.java_client.android.NetworkSpeed;
    import io.appium.java_client.touch.TapOptions;
    import io.appium.java_client.touch.WaitOptions;
    import io.appium.java_client.touch.offset.PointOption;
    import junit.framework.TestCase;
    import org.apache.commons.io.FileUtils;
    import org.apache.tools.ant.taskdefs.Sleep;
    import org.junit.After;
    import org.junit.Before;
    import org.junit.Test;

    import java.io.File;
    import java.io.IOException;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.time.Duration;
    import java.util.concurrent.TimeUnit;

    import org.openqa.selenium.Dimension;
    import org.openqa.selenium.OutputType;
    import org.openqa.selenium.ScreenOrientation;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.interactions.touch.TouchActions;
    import org.openqa.selenium.remote.DesiredCapabilities;

    public class xiuqiu_test {

    private AndroidDriver driver;

    @Before
    public void setUp() throws MalformedURLException {
    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
    desiredCapabilities.setCapability("platformName", "android");
    desiredCapabilities.setCapability("appPackage", "com.xueqiu.android");
    desiredCapabilities.setCapability("appActivity", ".view.WelcomeActivityAlias");
    desiredCapabilities.setCapability("deviceName", "xueqiu");
    desiredCapabilities.setCapability("automationName", "UiAutomator2");
    desiredCapabilities.setCapability("noReset", true);

    URL remoteUrl = new URL("http://localhost:4723/wd/hub");
    driver = new AndroidDriver(remoteUrl, desiredCapabilities);
    driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
    }


    @Test
    public void testGsmCall() throws IOException, InterruptedException {

    //打开个人消息页
    driver.findElementById("user_profile_icon").click();
    //切换后台3秒
    driver.runAppInBackground(Duration.ofSeconds(3));
    //模拟电话
    driver.makeGsmCall("18768167460",GsmCallActions.CALL);
    Thread.sleep(3000);

    //截图
    FileUtils.copyFile(
    driver.getScreenshotAs(OutputType.FILE),
    (new File("/tmp/GsmCall.png")));
    driver.getScreenshotAs(OutputType.FILE);


    }

    @Test
    public void testH5() throws InterruptedException, IOException {

    //点击交易
    driver.findElementByXPath("//*[@text='交易']").click();
    //点击基金
    driver.findElementById("com.xueqiu.android:id/page_type_fund").click();
    //点击蛋卷基金安全开户
    driver.findElementByAccessibilityId("蛋卷基金安全开户").click();
    //输入手机号
    driver.findElementByAccessibilityId("请输入手机号").sendKeys("18711111111");
    //截图
    FileUtils.copyFile(
    driver.getScreenshotAs(OutputType.FILE),
    (new File("/tmp/testH5.png")));

    }

    @After
    public void tearDown() {
    driver.quit();
    }
    }


  • import io.appium.java_client.MobileElement;
    import io.appium.java_client.android.AndroidDriver;
    import junit.framework.TestCase;
    import org.junit.After;
    import org.junit.Before;
    import org.junit.Test;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.util.concurrent.TimeUnit;

    import org.openqa.selenium.remote.DesiredCapabilities;

    public class login_test {

    private AndroidDriver driver;

    @Before
    public void setUp() throws MalformedURLException {
    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
    desiredCapabilities.setCapability("platformName", "android");
    desiredCapabilities.setCapability("appPackage", "com.xueqiu.android");
    desiredCapabilities.setCapability("appActivity", ".view.WelcomeActivityAlias");
    desiredCapabilities.setCapability("deviceName", "xueqiu");
    desiredCapabilities.setCapability("noReset", true);

    URL remoteUrl = new URL("http://localhost:4723/wd/hub");

    driver = new AndroidDriver(remoteUrl, desiredCapabilities);
    driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
    }

    @Test
    public void sampleTest() {
    //进入我的页面
    MobileElement el1 = (MobileElement) driver.findElementById("com.xueqiu.android:id/user_profile_icon");
    el1.click();
    //点击登入按钮
    MobileElement el2 = (MobileElement) driver.findElementById("com.xueqiu.android:id/tv_login");
    el2.click();
    //选择手机及其他登入
    MobileElement el3 = (MobileElement) driver.findElementById("com.xueqiu.android:id/tv_login_by_phone_or_others");
    el3.click();
    //输入手机号
    MobileElement el4 = (MobileElement) driver.findElementById("com.xueqiu.android:id/register_phone_number");
    el4.click();
    el4.sendKeys("18768167460");
    //输入验证码
    MobileElement el5 = (MobileElement) driver.findElementById("com.xueqiu.android:id/register_code");
    el5.click();
    el5.sendKeys("1234");
    //登入
    MobileElement el6 = (MobileElement) driver.findElementById("com.xueqiu.android:id/button_next");
    el6.click();
    }

    @After
    public void tearDown() {
    driver.quit();
    }
    }

  • VirtualBox启动模拟器报以下错误:

    不能为虚拟电脑 Google Nexus 4 - 4.4.4 - API 19 - 768x1280 打开一个新任务.

    The virtual machine 'Google Nexus 4 - 4.4.4 - API 19 - 768x1280' has terminated unexpectedly during startup with exit code 1 (0x1).

    返回 代码:NS_ERROR_FAILURE (0x80004005)
    组件:MachineWrap
    界面:IMachine {85cd948e-a71f-4289-281e-0ca7ad48cd89}