我正在Windows 10上运行Appium var http = require('http');
var url = require('url');
var fs = require('fs');
http.createServer(function(request, response) {
var url_part = url.parse(request.url,true);
var originUrl = url_part.href;
var options = url.parse(originUrl);
var proxy = http.request(options);
proxy.addListener('response', function (proxy_response) {
proxy_response.addListener('data', function(chunk) {
response.write(chunk, 'binary');
});
proxy_response.addListener('end', function() {
response.end();
});
response.writeHead(proxy_response.statusCode, proxy_response.headers);
});
request.addListener('data', function(chunk) {
proxy.write(chunk, 'application/json');
});
request.addListener('end', function() {
proxy.end();
});
}).listen(3128);
,我正在尝试在真实设备上自动化Chrome(在这种情况下,运行Android 1.6.1
的三星Galaxy S7)。我正在使用7.0
和visual studio。我的代码如下所示:
C#
Chrome启动,但它只是位于“数据”;屏幕空白并没有进入网站。 Appium视图的最后一步是:
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Appium.Android;
namespace MobileBrowserTesting{
[TestClass]
public class UnitTest1{
AppiumDriver<IWebElement> Driver;
[TestMethod]
public void TestMethod1(){
DesiredCapabilities caps = new DesiredCapabilities();
caps.SetCapability("deviceName", "hero2lteskt");
caps.SetCapability("udid", "ce11160b3889d43005"); //Give Device ID of your mobile phone
caps.SetCapability("browserName", "Chrome");
//Launch the Android driver
Driver = new AndroidDriver<IWebElement>(new Uri("http://127.0.0.3:4723/wd/hub"), caps);
Driver.Navigate().GoToUrl("http://www.google.com");
string url = Driver.Url;
bool viewable = Driver.FindElement(By.Id("q")).Displayed;
}
}
}
Visual Studio超时时显示错误消息:
[JSONWP Proxy] Proxying [POST /session] to [POST
http://127.0.0.1:8001/wd/hub/session] with body: {"desiredCapabilities":
{"chromeOptions":
{"androidPackage": "com.android.chrome","androidDeviceSerial":"ce11160b3889d43005"}}}
[HTTP] <-- POST /wd/hub/session - - ms - -
过了一会儿,Appium超时了:
Message: Test method MobileBrowserTesting.UnitTest1.TestMethod1 threw
exception:
OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://127.0.0.3:4723/wd/hub/session timed out after 60 seconds. ---> System.Net.WebException: The operation has timed out
Appium以管理员模式启动,在“高级”下勾选“允许会话覆盖”。
正在使用的chromedriver是最新版本([W3C] Encountered internal error running command: Error: Failed to start
Chromedriver session: An unknown server-side error occurred while processing
the command. (Original error: unknown error: Device ce11160b3889d43005 is
already in use
),设备上的chrome版本为2.39
,因此它应该兼容。
为什么它似乎挂起/没有与Chrome互动的任何想法?
提前干杯