Chrome remote debugging in seleniumgrid

Im launches a selenium grid with several instances of chrome. A selenium grid is two cars (windows) with several nodes. Tests are performed from another computer that connects to the grid. To be able to use the remote debugging features, I need to connect from the executing machine (which can read session hosts and debugUrl drivers) to other machines and, finally, chrome instances.

But chrome refuses something other than localhost.

I can find solutions where people tunnel or redirect the port, which is probably normal when there is only one instance. In the grid, I have no static ports or static rules to provide static forwarding.

In my scenario, the grid is created by an automated rather than a constantly running system.

Can someone tell me how to solve this?

+1
source share
1 answer

Since I found the solution myself, I want to share. I will post only parts of the code to give hints, not the complete code, as it works a lot here, but for an experienced developer this should be enough.

In order to be able to access the correct browser and access its websocket remote debugger, I implemented my own servlet for my nodes.

First servlet:

public class DebugServlet extends RegistryBasedServlet

registered through node.json as

"servlets" :["com.....ui.util.DebugServlet"],

node ( ), , :

"http://" + hubHost + ":" + hubPort + "/grid/api/testsession?session=" + sessionId

"sessionid" .

json node , url.

url = JSONUtil.get(response.getBody(), "proxyId")

, URL- websocket . BasicAuth.

url+ "/extra/DebugServlet"

java ( , http)

new BasicHeader("BrowserUrl", webSocketDebuggerUrl), new BasicHeader("Name", name),
                new BasicHeader("Value", value)

- URL- .

:

public static final String networkDebugging = "{\"id\": 1,\"method\": \"Network.enable\",\"params\": {\"maxTotalBufferSize\": 10000000,\"maxResourceBufferSize\": 5000000 }}";

public static final String addHeader = "{\"id\": 2,\"method\": \"Network.setExtraHTTPHeaders\",\"params\": { \"headers\": {\"${key}\": \"${value}\"}}}";


ws.connect();
ws.setAutoFlush(true);
ws.sendText(networkDebugging);

String payload = TemplateUtil.replace(addHeader, name, value);
ws.sendText(payload);
0

Source: https://habr.com/ru/post/1682387/


All Articles