public void TestUCBrowser()
        {
            string appPath = @"D:\git-zjs\Appium-Test-ios-android\AppiumDriverDemo\Apps\UCBrowser_V9.8.0.435_Android_pf145_(Build14052717).apk";

            DesiredCapabilities cap = new DesiredCapabilities();
            //cap.SetCapability("appium-version", "1.0");
            cap.SetCapability(CapabilityType.BrowserName, "");
            cap.SetCapability("platformName", "Android");
            cap.SetCapability("browserName", "UC Browser");
            cap.SetCapability("udid", "EAZSRK6HIJHEAYSK");  //三星手机 //4d00627749d2a037  //三星手机2  1844d244  红米手机 //EAZSRK6HIJHEAYSK   小米3 //bba1bd7
            cap.SetCapability("app", appPath);

            //UC Browser设置
            cap.SetCapability("appPackage", "com.UCMobile");
            cap.SetCapability("appActivity", "com.uc.browser.InnerUCMobile");

            driver = new AppiumDriver(new Uri("http://localhost:4723/wd/hub"), cap);
            Thread.Sleep(2000);
            IList<IWebElement> ltEle = driver.FindElements(By.ClassName("android.view.View"));
            ltEle[ltEle.Count - 1].Click();
            Thread.Sleep(2000);

            //IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
            //Hashtable keycodes = new Hashtable();

            //keycodes.Add("KEYCODE_C", "31");
            //js.ExecuteScript("mobile:keyevent", keycodes);

            //Thread.Sleep(5000);

            CommonFunction comFun = new CommonFunction();
            comFun.ITakesScreenshots(driver);
            Thread.Sleep(2000);
            driver.Quit();
        }
Пример #2
0
        /// <summary>
        /// 模拟器通过Appium跑H5用例----> 有问题 
        /// </summary>
        public void TestH5Appium()
        {
            DesiredCapabilities capabilities = new DesiredCapabilities();
            //capabilities.SetCapability("appium-version", "1.0");
            capabilities.SetCapability("deviceName", "android");
            capabilities.SetCapability("udid", "EAZSRK6HIJHEAYSK");
            capabilities.SetCapability("BrowserName","UC Browser");
            driver = new AppiumDriver(new Uri("http://localhost:4723/wd/hub"), capabilities);

            driver.Navigate().GoToUrl("http://www.baidu.com");
            Thread.Sleep(7000);

            CommonFunction comFun = new CommonFunction();
            comFun.ITakesScreenshots(driver);
            driver.Quit();
        }