简体   繁体   English

BrowserMob 代理 - 远程服务器返回错误:(404) 未找到

[英]BrowserMob Proxy - The remote server returned an error: (404) Not Found

I'm trying to use BrowserMob Proxy with Selenium in C#.我正在尝试在 C# 中使用带有Selenium BrowserMob Proxy

I've tried this solution here: http://www.adathedev.co.uk/2012/02/automating-web-performance-stats.html我在这里尝试过这个解决方案: http : //www.adathedev.co.uk/2012/02/automating-web-performance-stats.html

And my code looks like this:我的代码如下所示:

Server server = new Server(@"path_to\\browsermob-proxy.bat");
server.Start();
Client client = server.CreateProxy();
client.NewHar("test");

var seleniumProxy = new Proxy { HttpProxy = client.SeleniumProxy };
var profile = new FirefoxProfile();

profile.SetProxyPreferences(seleniumProxy);
IWebDriver driver = new FirefoxDriver(profile);

When I run the test I get the following error:当我运行测试时,我收到以下错误:

System.Net.WebException: The remote server returned an error: (404) Not Found. System.Net.WebException:远程服务器返回错误:(404) 未找到。

It fails at the third line.它在第三行失败。

Any suggestions on how to get this working?有关如何使其工作的任何建议?

If you can post a more detailed stack trace, that would be useful, along with the remote host you're trying to connect to.如果您可以发布更详细的堆栈跟踪,以及您尝试连接的远程主机,那将非常有用。 In the meantime a few things to try are:在此期间,可以尝试以下几件事:

  • Check the address you're requesting.检查您请求的地址。 It seems you're getting a 404 -- can you hit it through a browser without the proxy?看起来你得到了一个 404——你能在没有代理的情况下通过浏览器点击它吗?
  • Make sure browsermob-proxy.bat is installed at the path on line 1 (is it really in a subdirectory of the working directory called "path_to"?)确保 browsermob-proxy.bat 安装在第 1 行的路径中(它真的在名为“path_to”的工作目录的子目录中吗?)
  • Check your write permissions in the temp directory, which is %TEMP% or %TMP% on Windows.检查您在临时目录中的写入权限,在 Windows 上为 %TEMP% 或 %TMP%。 BMP writes temporary files there. BMP 在那里写入临时文件。
  • Grab the latest source and build the .bat file.获取最新的源代码并构建 .bat 文件。 The instructions are on the browsermob-proxy github page at the bottom (under Creating the batch files from source ).说明位于底部的browsermob-proxy github 页面上(在从源创建批处理文件下)。

Hope that helps!希望有帮助!

This is most likely because your Jetty service is not actually running, did you get a message from BrowserMob batch file saying it couldn't run?这很可能是因为您的 Jetty 服务实际上并未运行,您是否从 BrowserMob 批处理文件中收到一条消息,说它无法运行? In my case it was a situation where the port (by default is set to 8080) but I had something else listening on that port.就我而言,这是端口(默认设置为 8080)但我在该端口上侦听其他内容的情况。 To fix this, you can pass an optional port number.要解决此问题,您可以传递一个可选的端口号。

var server = new Server(@"C:\path\to\bin\browsermob-proxy.bat", 9090);

I had same problem on python.我在python上遇到了同样的问题。 When I had tried to get content of localhost:8080 I got 404 error.当我试图获取 localhost:8080 的内容时,我收到了 404 错误。 It turned out that my other application was using same 8080 port.原来我的另一个应用程序使用相同的 8080 端口。 So I found PID typing in cmd: netstat -o -n -a | findstr :8080所以我发现 PID 在 cmd 中输入: netstat -o -n -a | findstr :8080 netstat -o -n -a | findstr :8080 . netstat -o -n -a | findstr :8080 Then I just terminated process with this PID and browsermob gave me well HAR.然后我就用这个 PID 终止了进程,browsermob 给了我很好的 HAR。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 远程服务器返回错误:(404)找不到-HttpWebResponse - The remote server returned an error: (404) Not Found - HttpWebResponse HttpWebRequest引发“ 404远程服务器返回错误:(404)未找到。” - HttpWebRequest throws “The remote server returned an error: (404) Not Found.” for 404 远程服务器返回错误:(404)找不到。 在GetResponse()中 - The remote server returned an error: (404) Not Found. In GetResponse() Picasa API返回“远程服务器返回错误:(404)Not Found。” - Picasa API returns “The remote server returned an error: (404) Not Found.” WebDriverManager - '远程服务器返回错误:(404)未找到。' - WebDriverManager - 'The remote server returned an error: (404) Not Found.' 服务器返回错误:找不到404 - The server returned an error: 404 not found 远程服务器返回一个错误:(404) Not Found error for API calls after server publish - The remote server returned an error: (404) Not Found error for API calls after server publish 远程服务器返回404 - Remote server returned 404 Microsoft.WindowsAzure.Storage.StorageException:远程服务器返回错误:(404)Not Found - Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (404) Not Found 如果使用Solr.NET将.NET Core与Solr连接,如何解决“远程服务器返回错误:(404)未找到”的问题 - How to fix “The remote server returned an error: (404) Not Found” if connecting .NET Core with Solr using Solr.NET
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM