无法在公司代理后面的browserstack上运行自动化测试(使用selenium,C#) [英] Unable to run automation test (using selenium, C#) on browserstack, behind corporate proxy

查看:119
本文介绍了无法在公司代理后面的browserstack上运行自动化测试(使用selenium,C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在创建RemoteWebDriver实例时遇到以下错误

 driver = new RemoteWebDriver(new Uri(http://hub-cloud.browserstack.com/wd/hub/),capability); 



无法连接到远程服务器---> System.Net.Sockets.SocketException:连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机无法响应XXX.XXX.XXX.XXX:Port 



我尝试过:



 var browserStackLocal = new Local(); 
var localArgs = new List< KeyValuePair< string,string>>
{
新KeyValuePair<串,串>( 键, XXXXXXXXXXXXXXXXXXXXX),
新KeyValuePair<串,串>( 力, 真),
new KeyValuePair< string,string>(binarypath,/ temp),
new KeyValuePair< string,string>(logfile,/ temp / logs.txt),
new KeyValuePair<串,串>( v, 真),
新KeyValuePair<串,串>( ProxyHost的, 主机名),
新KeyValuePair<串,串>( proxyPort, 端口号),
新KeyValuePair<串,串>( PROXYUSER, 用户名),
新KeyValuePair<串,串>( PROXYPASS, 密码)
};

browserStackLocal.start(localArgs);

DesiredCapabilities capability = new DesiredCapabilities();
capability.SetCapability(浏览器,Chrome);
capability.SetCapability(browser_version,62.0);
capability.SetCapability(os,Windows);
capability.SetCapability(os_version,7);
capability.SetCapability(resolution,1024x768);
capability.SetCapability(browserstack.local,true);
capability.SetCapability(browserstack.debug,true);
capability.SetCapability(browserstack.user,UserXXXXXX);
capability.SetCapability(browserstack.key,KeyXXXXXX);

driver = new RemoteWebDriver(new Uri(http://hub-cloud.browserstack.com/wd/hub/),capability);
driver.Navigate()。GoToUrl(http://google.co.uk);







选项1)我可以使用以下代码建立连接:
browserStackLocal.start(localArgs);

但是,仍然无法连接到远程服务器---> System.Net.Sockets.SocketException:连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机无法响应185.44.131.194:80,在以下代码中:

driver = new RemoteWebDriver(new Uri(http://hub-cloud.browserstack.com/wd/hub/),capability);


选项2)还尝试了以下命令
BrowserStackLocal.exe --key XXXXXX --proxy-host Host --proxy-port Port --proxy-user用户名 - -proxy-pass密码--force-local --force-proxy

并添加以下代码
capability.SetCapability(browserstack.local,true);







如果有人遇到此问题,请分享您的经验和解决方案。

解决方案

该网站本身正在运行并提供响应,虽然是错误消息,但确实有效。请检查您是否在防火墙或网络隔离环境后运行此程序。是的,IP地址是您的主机名的基础IP地址(您传递构造函数的地址)。



此外,我不知道发生了什么在该对象后面 - 请检查文档以查看请求的其他位置,因为我们无法从此处为您检查。 :)

I am getting following error on creating instance of RemoteWebDriver

driver = new RemoteWebDriver(new Uri("http://hub-cloud.browserstack.com/wd/hub/"), capability);


Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond XXX.XXX.XXX.XXX:Port



What I have tried:

var browserStackLocal = new Local();
            var localArgs = new List<KeyValuePair<string, string>>
            {
                new KeyValuePair<string, string>("key", "XXXXXXXXXXXXXXXXXXXXX"),
                new KeyValuePair<string, string>("force", "true"), 
                new KeyValuePair<string, string>("binarypath", "/temp"), 
                new KeyValuePair<string, string>("logfile", "/temp/logs.txt"),
                new KeyValuePair<string, string>("v", "true"),
                new KeyValuePair<string, string>("proxyHost", "HostName"),
                new KeyValuePair<string, string>("proxyPort", "PortNumber"),
                new KeyValuePair<string, string>("proxyUser", "Username"),
                new KeyValuePair<string, string>("proxyPass", "Password")
            };

              browserStackLocal.start(localArgs);

                DesiredCapabilities capability = new DesiredCapabilities();
                capability.SetCapability("browser", "Chrome");
                capability.SetCapability("browser_version", "62.0");
                capability.SetCapability("os", "Windows");
                capability.SetCapability("os_version", "7");
                capability.SetCapability("resolution", "1024x768");
                capability.SetCapability("browserstack.local", "true");
                capability.SetCapability("browserstack.debug", "true");
                capability.SetCapability("browserstack.user", "UserXXXXXX");
                capability.SetCapability("browserstack.key", "KeyXXXXXX");

                driver = new RemoteWebDriver(new Uri("http://hub-cloud.browserstack.com/wd/hub/"), capability);
                driver.Navigate().GoToUrl("http://google.co.uk");




Option 1) I am able to establish a connection using the following code:
browserStackLocal.start(localArgs);

But, still getting "Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 185.44.131.194:80", in the following code:

driver = new RemoteWebDriver(new Uri("http://hub-cloud.browserstack.com/wd/hub/"), capability);


Option 2) Also tried the following command 
BrowserStackLocal.exe --key XXXXXX --proxy-host Host --proxy-port Port --proxy-user Username --proxy-pass Password --force-local --force-proxy

And adding the following code
capability.SetCapability("browserstack.local", "true");




If anyone faced this issue, please share your experience and solution.

解决方案

That website itself is running and does provide a response, although an error message but it does work. Please check that you are not running this program behind a firewall or a network isolated environment. And yes, the IP address is the underlying IP address for your hostname (the one you are passing the constructor).

Also, I am not sure of what goes on behind that object—please check the documentation to see where else is the request being made as we cannot check that for you, from here. :)


这篇关于无法在公司代理后面的browserstack上运行自动化测试(使用selenium,C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆