Skip to content

about dev tools #1

Description

@JuanManuelCarames

Hi @boris779 . did you try selenoid?
I created a POC and the devtools feature works fine!
here the code...

version: '3'
services:
  selenoid:
    network_mode: bridge
    image: aerokube/selenoid:latest-release
    volumes:
      - "./config:/etc/selenoid"
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "./video:/opt/selenoid/video"
      - "./config/logs:/opt/selenoid/logs"
    #environment:
     # - OVERRIDE_VIDEO_OUTPUT_DIR=/path/to/config/video
    command: ["-conf", "/etc/selenoid/browsers.json", "-video-output-dir", "/opt/selenoid/video", "-log-output-dir", "/opt/selenoid/logs"]
    ports:
      - "4444:4444"
     
  selenoid-ui:
    image: "aerokube/selenoid-ui"
    network_mode: bridge
    links:
      - selenoid
    ports:
      - "8080:8080"
    command: ["--selenoid-uri", "http://selenoid:4444"]

and the java code requesting the devtools

private void startDevToolsSerice(WebDriver driver) {
		ChromeDevToolsService devtools;
		// Init ChromeDevtools client
		WebSocketService webSocketService;
		try {
			webSocketService = WebSocketServiceImpl.create(new URI(
					String.format("ws://localhost:4444/devtools/%s/page", ((RemoteWebDriver) driver).getSessionId())));
			CommandInvocationHandler commandInvocationHandler = new CommandInvocationHandler();
			Map<Method, Object> commandsCache = new ConcurrentHashMap<>();
			devtools = ProxyUtils.createProxyFromAbstract(ChromeDevToolsServiceImpl.class,
					new Class[] { WebSocketService.class, ChromeDevToolsServiceConfiguration.class },
					new Object[] { webSocketService, new ChromeDevToolsServiceConfiguration() },
					(unused, method, args) -> commandsCache.computeIfAbsent(method, key -> {
						Class<?> returnType = method.getReturnType();
						return ProxyUtils.createProxy(returnType, commandInvocationHandler);
					}));
			commandInvocationHandler.setChromeDevToolsService(devtools);
			System.out.println("started!");
			
//			testPrintNetworkRequests(devtools);
			testPrintPerformanceRequests(devtools);
			
			devtools.close();
			
			System.out.println("Finishes!");
			
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

I hope it be useful. regards!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions