[英]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:
在此期间,可以尝试以下几件事:
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.