0

I have a website that I want to test through automation. My client wants to test the website using a proxy of another country as we can testing manual using Browserc Extension. How we can perform it in selenium using java. Below is the code I tried but how can I check this is the same country that proxy I used.

`

    Proxy proxy= new Proxy();
    proxy.setHttpProxy("localhost:8888");
    DesiredCapabilities cap = new DesiredCapabilities();
    cap.setCapability(CapabilityType.PROXY,  proxy);
    System.setProperty("webdriver.gecko.driver", "G:\\Selenium\\Driver\\geckodriver.exe");
    WebDriver driver = new FirefoxDriver();
    driver.get("https://vapesuite.co.uk/#/");`
8
  • i think you are trying to verify the country and to do so try to open the mylocation.org and check whether you are able to get the desired location or not. This will confirm the correct working of your proxy. Commented Jul 3, 2021 at 4:47
  • @AbhishekDhoundiyal yes you are right, can you please guide me how to implement this. Commented Jul 5, 2021 at 4:36
  • Please check this stackoverflow.com/a/53774638/5372079 Commented Jul 5, 2021 at 7:13
  • @AbhishekDhoundiyal I try this but it not loading the page and through timeout error on browser. Commented Jul 5, 2021 at 11:38
  • Are you sure your VPN is working fine? Open normal firefox browser and set the proxy manually and verify that your proxy is working or not. Commented Jul 5, 2021 at 11:40

2 Answers 2

1

I think the issue is with your code and proxy and it is not working properly.

I have tried the free proxy and it was working fine for me, please see the attached screenshot.

Code Used:

    FirefoxOptions options = new FirefoxOptions();
    FirefoxProfile profile = new FirefoxProfile();

    profile.setPreference("network.proxy.type", 1);
    profile.setPreference("network.proxy.http", "116.80.41.12");
    profile.setPreference("network.proxy.http_port", 80);
    profile.setPreference("network.proxy.ssl", "116.80.41.12");
    profile.setPreference("network.proxy.ssl_port", 80);

    options.setProfile(profile);

    WebDriver driver = new FirefoxDriver(options);
    driver.get("https://vapesuite.co.uk/#/");

https://free-proxy-list.net/ enter image description here

enter image description here

https://mylocation.org/ enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

if you are using maven this should work for you : https://maven.apache.org/guides/mini/guide-proxies.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.