
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Handle Proxy in Selenium with Java
We can handle proxy in Selenium in Java with the help of PROXY class.
import java.io.IOException; import org.openqa.selenium.Proxy; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; public class ProxySelJav { public static void main(String[] args) { // TODO Auto-generated method stub WebDriver driver; String prox = "localhost:8080"; // set browser settings with Desired Capabilities Proxy p = new Proxy(); p.setHttpProxy(prox).setFtpProxy(prox).setSslProxy(prox) .setSocksProxy(prox); DesiredCapabilities c = new DesiredCapabilities(); c.setCapability(CapabilityType.PROXY, p); // utilize capabilities on launching browser driver driver = new Firefox(c); } }
Advertisements