0

我正在使用 PhantomJs 和 Seleno 来实现一些 UI 测试。但问题是每当我试图在我的页面上找到一个元素时,它都会引发错误。“未知的命令”

初始化服务器的代码如下:

var projectPath =
               new DirectoryInfo(Environment.CurrentDirectory).Parent.Parent.Parent.GetDirectories("Foo")
                   .First()
                   .FullName;

        var loc = ProjectLocation.FromPath(projectPath);

        var service =PhantomJSDriverService.CreateDefaultService();

        service.Port= 123;
        var phantomJs = new PhantomJSDriver(service);

        Func<PhantomJSDriver> newFunc = () => phantomJs;

        var app = new WebApplication(loc, 123);
        Instance.Run(app, c => c
            .UsingLoggerFactory(new ConsoleFactory())
            .WithRemoteWebDriver(newFunc)
        );

它使用端口 123 打开 iisexpress,而 PhantomGhost 指向同一个端口。并显示此错误:

未知命令 - 请求 => {"headers":{"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9, /;q=0.8","Accept-Encoding":"gzip, deflate","Accept-Language":"en-US,en;q=0.5","Cache-Control":"max-age=0", "连接":"保持活动","Cookie":"ASP.NET_SessionId=a2umglrwcaquccg2rar0vzqa; .ASPXAUTH=7CBEDA8FC6170B15E116E77016D2136D4F58C8B73B0B2D54149B96847FE8A26E8D8FA24E41E5F0F0AFFE336D896B53C4628AB5B67B1960CB34727C85B6EF9720F7FF2A792BF1B5ECEECE5429DE212D8B7BA948978F302EF9B3A1040F05902AE92280FF8047D380583465D6CE6C6B103E5286F6FE37E75CFE22910E271BE2BEB4B552124B","Host":"localhost:12346","User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0"},"httpVersion": "1.1","方法":"GET","url":"/","urlParsed":{"

我也可以使用 firefox 浏览它,它也显示相同的错误。显然硒找不到元素,它会显示错误。

4

1 回答 1

0

我发现如果您将 PhantomJS 升级到最新版本,它将解决问题

于 2013-11-14T23:22:19.550 回答