Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about dev tools #1

Open
JuanManuelCarames opened this issue Jan 24, 2022 · 0 comments
Open

about dev tools #1

JuanManuelCarames opened this issue Jan 24, 2022 · 0 comments

Comments

@JuanManuelCarames
Copy link

JuanManuelCarames commented Jan 24, 2022

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant