霍格沃兹测试学院第五期线上课兼容性测试答疑帖

相关资料

Java 示例代码

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 org.openqa.selenium.remote.DesiredCapabilities;

public class SampleTest {

  private AndroidDriver driver;

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

    URL remoteUrl = new URL("http://127.0.0.1:4730/wd/hub");

    driver = new AndroidDriver(remoteUrl, desiredCapabilities);
  }

  @Test
  public void sampleTest() {
    MobileElement el1 = (MobileElement) driver.findElementById("com.xueqiu.android:id/splash_image");
    el1.click();
    el1.click();
  }

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

Python示例代码

# This sample code uses the Appium python client
# pip install Appium-Python-Client
# Then you can paste this into a file and simply run with Python

from appium import webdriver

caps = {}
caps["appPackage"] = "com.xueqiu.android"
caps["appActivity"] = ".view.WelcomeActivityAlias"
caps["platformName"] = "android"
caps["deviceName"] = "ddd"

driver = webdriver.Remote("http://127.0.0.1:4730/wd/hub", caps)

el1 = driver.find_element_by_id("com.xueqiu.android:id/splash_image")
el1.click()
el1.click()

driver.quit()

bash调度代码示例

while read device
do
  export deviceName=$device
  python xxx.py
done < devices.list

3.2.0版本stf的问题

需要先卸载stf,然后再升级nodejs到最新版本,再重新安装stf即可

brew upgrade nodejs
npm r -g stf
npm i -g stf

课后作业

  • 搭建stf并连接一台物理设备
  • 搭建selenium grid并接入一台物理机和模拟器

以上作业分别把搭建好的stf页面截图和selenium grid的截图发上来进行回帖。这个回帖不用设置为楼主可见。

答疑

相关答疑可直接回帖

关闭