Open quldude opened 1 year ago
Selenium Grid support in Playwright is highly experimental, not sure what's happening there, will leave open for the others to help if they can.
Same here.
same here. when running playwright with selenium grid 4.10 with playwright appear 2 chrome in Node.
Hi everyone, I'm experiencing the same problem with a Linux node. I don't have an in-depth understanding of Selenium Grid processes, but if I get correctly, when we attach to the node, WebDriver automatically opens a browser instance. If we use the built-in Playwright page fixture, it also opens a browser, resulting in two browser instances.
After some experiments, I managed to avoid the second instance from opening and use the first one. You can create a new project, install the 'playwright' and 'webdriverio' packages, and use the following code:
import { chromium } from 'playwright';
import { remote } from 'webdriverio';
const grid = {
ip: 'my_ip', // your selenium hub ip
port: 4444, // your selenium hub port
};
(async () => {
// Connect to Selenium Grid via WebDriver
const browser = await remote({
capabilities: {
browserName: 'chrome',
platformName: 'linux', // set here desired os
},
hostname: grid.ip,
port: grid.port,
path: '/wd/hub'
});
// Get browser session id
const sessionId = browser['sessionId'];
console.log(`sessionId: ${sessionId}`);
// Get browser end point
const wsEndPoint = `ws://${grid.ip}:${grid.port}/session/${sessionId}/se/cdp`;
console.log(`wsEndPoint: ${wsEndPoint}`);
// Get browser page
const pwBrowser = await chromium.connectOverCDP(wsEndPoint);
const context = pwBrowser.contexts()[0];
const page = context.pages()[0];
// Run test
await page.goto('https://google.com');
await page.waitForTimeout(20_000); // just to have time to check browser in node
const title = await page.title();
// Log result
console.log(title);
// Close
await pwBrowser.close();
await browser.deleteSession();
})();
There is a possibility that my conclusions are not entirely correct and the situation is a little different, but I think that the truth is somewhere nearby.
@pavelfeldman Since Selenium Grid works in experimental mode, I assume that this case will not be processed on the playwright side, but maybe you can suggest another way to get the browser sessionId without installation WebdriverIO? I can see it in logs when running tests through Selenium Grid.
Thanks in advance.
System info
Source code
Steps
Expected
Only 1 chrome browser opened with test site page..
Actual
2 chrome browsers opened. One opens with blank page and the other opens with test site page.