一、环境 :windows 下 Appuim +eclipse+java+TestNG
二、现象:被测试 App :有一个一闪而过的启动页,运行安装 app 后会自动跳过启动页,停留在欢迎界面,我想定位操作欢迎界面上的元素
但是都无效,我获取当前界面元素发现,获取的都是启动页的元素
三、提问:怎样能跳过启动页定位到欢迎界面上的元素
四、代码如下
public class AppDemo {
private AppiumDriver driver;
@BeforeMethod(alwaysRun=true)
public void setUp() throws Exception {
// set up appium
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "apps/XX");
File app = new File(appDir, "XX.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName","SM_N7508V");
capabilities.setCapability("platformVersion", "4.3");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.qding.community");
capabilities.setCapability("appActivity", "com.qding.community.home.activity.SplashActivity");
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
@AfterMethod(alwaysRun=true)
public void tearDown() throws Exception {
System.out.println("end");
driver.quit();
}
@Test(groups={"testCase"})
public void testCase(){
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.getPageSource();
// System.out.println(driver.findElementById("com.qding.community:id/iv_start"));
System.out.println(driver.getPageSource());
// driver.tap(1, driver.findElementById("com.qding.community:id/iv_start"), 0);
}