简体   繁体   English

如何确保我的应用程序使用的是代理服务器而不是硒中的IP地址?

[英]How to make sure that my application is using Proxy server and not my IP address in selenium?

I am using Selenium with PhantomJS browser. 我在PhantomJS浏览器中使用Selenium。 I have set up proxy as below: 我已经设置代理如下:

DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
capabilities.setJavascriptEnabled(true);
System.setProperty("phantomjs.binary.path", "../Drivers/phantomjs.exe");

ArrayList<String> cliArgsCap = new ArrayList<String>();
cliArgsCap.add("--proxy=hostname:port");
cliArgsCap.add("--proxy-auth=username:password");
cliArgsCap.add("--proxy-type=http");
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cliArgsCap);

driver = new PhantomJSDriver(capabilities);

My application is running fine. 我的应用程序运行良好。 But how to validate if my application is using the proxy that I have set up? 但是,如何验证我的应用程序是否正在使用已设置的代理?

You can using fiddler to setup a proxy server on your local, after that, change your selenium proxy configuration to proxy you have setup. 您可以使用fiddler在本地上设置代理服务器 ,然后,将硒代理配置更改为已设置的代理。 Let's run your app, if your app going throw proxy then fiddler will catch it. 让我们运行您的应用程序,如果您的应用程序将抛出代理,则提琴手会抓住它。

在运行主脚本之前,向显示客户端当前IP的http://api.ipify.org/发出请求,并检查代码是您的IP还是代理IP。

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

相关问题 如何确保我的应用程序符合 CalDAV? - How to make sure my application is CalDAV compliant? 如何让服务器的外部 IP 地址可以访问 Spring Boot 应用程序? - How to make Spring Boot application accessible by external IP address of the server? 如何从我的Java应用程序中设置Selenium的代理设置? - How to set from my Java application the proxy settings for Selenium? 如何确保我与RabbitMQ的应用程序连接是健康的 - How to make sure that my Application connection to RabbitMQ is healthy 配置静态IP地址到“我的网站”应用程序 - configure static ip address To My website application Java- 为什么 Selenium Chrome webdiver 使用我的真实 IP 地址而不是代理 - Java- Why Selenium Chrome webdiver is using my real IP adress instead of the proxy 如何使用IP地址共享数据库? - How can I share my database using IP Address? 如何使用公共IP地址而不是localhost访问我的webapp? - How to access my webapp using public IP address instead of localhost? 在Java中,当我在代理后面时,网站如何找到我的真实IP地址? - In Java, how can a website find my real IP address while I'm behind a proxy? 如何确保仅使用我的origninal客户端向我的服务器发出请求? - How do I make sure only my origninal client is used to make requests to my server?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM