How to call this function devtools selenium c#
Asked Answered
R

1

1

I am trying to call this method in the devtools protcol Network.setRequestInterception. So Far I have this:

IDevTools devTools = driver as IDevTools;
DevToolsSession session = devTools.CreateDevToolsSession();
session.Network.Enable(new OpenQA.Selenium.DevTools.Network.EnableCommandSettings());
session.Network.SetRequestInterception(new OpenQA.Selenium.DevTools.Network.SetRequestInterceptionCommandSettings() {
            //Patterns = JsonConvert.DeserializeObject<IEnumerable<AccountDetails>>(json);
            Patterns = new RequestPattern[] { new ResourceType {"Image" }  }



        }

I cant figure out how to call it with the correct paraneters. In the documentation, it shows the type of object it is but it is different in the selenium code. It uses this as one of the parameters and this as the function.

I am trying to call the setRequestInterception with the resourceType Image

Rogerrogerio answered 11/6, 2020 at 10:47 Comment(0)
S
0

Your line of code:

Patterns = new RequestPattern[] { new ResourceType {"Image" }  }

Is trying to assign a ResourceType object into a RequestPattern array.

Instead, try:

Patterns = new RequestPattern[] { new RequestPattern() { ResourceType = ResourceType.Image } }

In your array, create a request pattern object first, and in that assign the resource type.

Schonfeld answered 30/6, 2020 at 13:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.