Skip to content

Support for Browsing context #57

Open
@togadiyaj

Description

@togadiyaj

Would be great if it supports creating browsing context and tab from it as https://devdocs.io/puppeteer/ does.

try (ChromeDevToolsService parentDevToolService = ChromeServiceExt
.createDevToolsService(chromeService.getVersion().getWebSocketDebuggerUrl())){}

public static ChromeDevToolsService createDevToolsService(String webSocketURL) {
try {
WebSocketService webSocketService = WebSocketServiceImpl.create(new URI(webSocketURL));
CommandInvocationHandler commandInvocationHandler = new CommandInvocationHandler();
Map<Method, Object> commandsCache = new ConcurrentHashMap<>();
ChromeDevToolsService devtools =
(ChromeDevToolsService) 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);
return devtools;
}catch(Exception e) {
throw new SnapshotGenerationException("Couldn't create ChromeDevToolsService for chrome webSocketDebuggerUrl ",e);
}
}

 static ChromeTab createTab(ChromeService chromeService, ChromeDevToolsService parentDevToolService,
		String browserContext) {
	ChromeTab tab;
	String targetId = parentDevToolService.getTarget().createTarget(SnapshotGenConstants.ABOUT_BLANK, null, null,browserContext, null, null, null);
	tab = chromeService.getTabs().stream().filter(chromeTab -> chromeTab.getId().equals(targetId))
			.findFirst().get();
	return tab;
}

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