无法使用Appium Android Web驱动程序加载页面

时间:2019-02-05 15:44:18

标签: c# appium appium-android

我在Appium上度过了非常糟糕的时光。

我正在尝试创建一个示例,以导航到网页并使用c#与它的元素进行交互

它会继续做下一系列事情:

异常消息示例:

An unknown server-side error occurred while processing the command. 
Original error: Error attempting to start URI.
Original error: Error: Error executing adbExec.
Original error: 'Command 'C\:\\Users\\vemelin\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb.exe -P 5037 -s RQ3004KL2K shell am start -W -a android.intent.action.VIEW -d https\://www.google.com com.android.chrome' timed out after 20000ms'; Stderr: ''; Code: 'null'

我正在使用dotnet appium版本,我的配置如下所示:

        var capabilities = new AppiumOptions();
        capabilities.AddAdditionalCapability("deviceName", "adb:G3121");
        capabilities.AddAdditionalCapability("platformName", "Android");
        capabilities.AddAdditionalCapability("appPackage", "com.android.chrome");
        capabilities.AddAdditionalCapability("appActivity", "com.google.android.apps.chrome.Main");
        capabilities.AddAdditionalCapability("pageLoadTimeout", "180000");

        void AcceptCertificate(AndroidDriver<AppiumWebElement> webdriver, string url)
        {
            webdriver.Navigate().GoToUrl(url);
            webdriver.FindElementByAndroidUIAutomator("new UiSelector().resourceId(\"details-button\")").Click();
            webdriver.FindElementByAndroidUIAutomator("new UiSelector().resourceId(\"proceed-link\")").Click();
        };

        var service =
            new AppiumServiceBuilder()
                .WithAppiumJS(new FileInfo(("C:\\Program Files\\nodejs\\node_modules\\appium\\build\\lib\\main.js")))
                .UsingPort(4723)
                .Build();

        service.Start();

            var driver = new AndroidDriver<AppiumWebElement>(new Uri("http://127.0.0.1:4723/wd/hub"), capabilities);
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);

            // Arrange
            var flow = new FlexibleApplyFlowModel(CurrentChannel, driver, _writer.WriteLine);
            var jobId = AvailableJobs.GetStandardJobId();

            // Act
            driver.FindElementByAndroidUIAutomator(
                "new UiSelector().resourceId(\"com.android.chrome:id/terms_accept\")").Click();
            driver.FindElementByAndroidUIAutomator(
                "new UiSelector().resourceId(\"com.android.chrome:id/negative_button\")").Click();

            driver.Navigate().GoToUrl("https://www.google.com");

            flow.GoToJobApplyPage(jobId);
        service.Dispose();

0 个答案:

没有答案