appium对手机chrome浏览器测试
运行程序后,chrome确实有被打开,但是又立马关闭了,反反复复大概有3次,不知道哪里出错了,跪求大神指导!程序代码如下:
package uu;
import java.io.File;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.apache.log4j.xml.DOMConfigurator;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.CapabilityType;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
public class test3 {
publicAppiumDriverDriver;
@Test
public void f() {
}
@Before
public void setUp() throws Exception {
//配置log4j的配置文件为log4j.xml
//DOMConfigurator.configure("log4j.xml");
//set up appium
//获取当前路径
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName","m3 note");
capabilities.setCapability("platformVersion", "5.1");
System.out.println("1111111111111111111111");
capabilities.setCapability("browserName", "Chrome");
capabilities.setCapability("appPackage", "com.android.chrome");
capabilities.setCapability("appActivity", "org.chromium.chrome.browser.ChromeTabbedActivity");
//capabilities.setCapability("MobileCapabilityType.AUTOMATION_NAME", "AutomationName.ANDROID_UIAUTOMATOR2");
Driver = new AndroidDriver(new URL("http://localhost:4723/wd/hub"), capabilities);
System.out.println("手机自动化开始测试");
Driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
Driver.get("http://www.qq.com");
Thread.sleep(5000);
}
@After
public void afterMethod() {
//Driver.quit();
}
}
你确定 你的appActivity是正确的?
可以看我的帖子
分享appium中如何快速查找app的package和activity的名称
http://bbs.51testing.com/forum.php?mod=viewthread&tid=1121337&fromuid=300896
(出处: 51Testing软件测试论坛 )
如何快速获取 是版本的问题,换了个低版本的CHROME浏览器就可以正常运行了 浏览器版本与你的driver的版本不匹配
页:
[1]