This is a migrated thread and some comments may be shown as answers.

Run proxy with selenium test on different machine

0 Answers 121 Views
FiddlerCore
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 13 Dec 2016, 11:27 AM
Hi, 
I want to run a selenium test on my local machine and catch http traffic on different machine.
This is my script:

RemoteWebDriver driver;
ChromeOptions chromeOptions = new ChromeOptions();
FiddlerApplication.Startup(8888, FiddlerCoreStartupFlags.Default);
OpenQA.Selenium.Proxy proxy = new OpenQA.Selenium.Proxy();
proxy.HttpProxy = "{IP of the different machine}:8888";
chromeOptions.Proxy = proxy;
DesiredCapabilities capabilities = (DesiredCapabilities)chromeOptions.ToCapabilities();
driver = new RemoteWebDriver(new Uri({IP of the different machine}:4444/wd/hub), capabilities, TimeSpan.FromSeconds(600));
FiddlerApplication.AfterSessionComplete += CollectDataThroughProxy;



private static List<string> dataStr = new List<string>();


private static void CollectDataThroughProxy(Session sess)
        {
            if (sess == null || sess.oRequest == null || sess.oRequest.headers == null)
                return;
            string headers = sess.oRequest.headers.ToString();
            var reqBody = sess.GetRequestBodyAsString();
            dataStr.Add(reqBody);
        }

When I change IP in the code and run it on my local machine, it works fine. However, when I change IP to different machine, I see the relevant page is open,but I don't get the http traffic from this machine.
I checked "allow remote computers to connect" in Fiddler options.

Can anyone please help me?
Thanks

No answers yet. Maybe you can help?

Tags
FiddlerCore
Asked by
Alexander
Top achievements
Rank 1
Share this question
or