0
votes

public class PerfTestt {

public static void main(String[] args) throws Exception {



    ProxyServer server = new ProxyServer(8080);
    server.start();



    Proxy proxy = server.seleniumProxy();

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.PROXY, proxy);

    WebDriver driver = new FirefoxDriver(capabilities);

    server.newHar("yahoo.com");

    driver.get("http:/yahoo.com");



    Har har = server.getHar();
    FileOutputStream fos = new FileOutputStream("C:\\Users\\nergiz\\output.txt");
    har.writeTo(fos);
    server.stop();
    driver.quit();
}

}

Driver info: driver.version: FirefoxDriver at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:118) at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:251) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:110) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:195) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:190) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:107) at com.beam.testo.selenium.PerfTestt.main(PerfTestt.java:32) Caused by: org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms.

1
The error indicates that selenium is trying to connect to port 7055, yet your code starts a server on port 8080. Why?Husman
I don't know. I set port:8080 but trying to connect 7055 :/Tester

1 Answers

0
votes

I solved. I was getting failre a browser options. I edit my codes:

            String PROXY = "localhost:8080";

    ProxyServer server = new ProxyServer(8080);
    server.start();

    Proxy proxy = server.seleniumProxy();
    proxy.setHttpProxy(PROXY).setFtpProxy(PROXY).setSslProxy(PROXY);

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.PROXY, proxy);

    WebDriver driver = new FirefoxDriver(capabilities);

    server.newHar("yahoo.com");

    driver.get("http://yahoo.com");


    Har har = server.getHar();
FileOutputStream fos = new                           FileOutputStream("C:\\Users\\ner\\output.txt");
    har.writeTo(fos);
    server.stop();
    driver.quit();