Note: Based on how the question is formulated I assume we are talking about node URI, which it's not always precise IP address of it. Having the URI it shouldn't be difficult to find the real ip, if indeed needed. Taking this into account...
GraphQL endpoint is the place to go. You can narrow the results by querying for specific sessionID (which you can get from webdriver as you pointed out).
cUrl example:
curl -X POST -H "Content-Type: application/json" --data '{"query":"{ session (id: \"<session-id>\") { id, capabilities, startTime, uri, nodeId, nodeUri, sessionDurationMillis, slot { id, stereotype, lastStarted } } } "}' -s <LINK_TO_GRAPHQL_ENDPOINT>
Prototype in node.js:
const { Builder } = require('selenium-webdriver');
const axios = require('axios').default;
async function main() {
let driver = await new Builder()
.usingServer('http://localhost:4444')
.forBrowser('chrome')
.build();
try {
await driver.get('https://www.cogitovirus.com/');
const title = await driver.getTitle();
console.log(`Sanity check. Title is: ${title}`);
const sessionId = (await driver.getSession()).getId()
console.log(`Session id: ${sessionId}`)
const res = await axios.post('http://localhost:4444/graphql', {
query: `{ session (id: \"${sessionId}\") { id, uri, nodeId, nodeUri} }`
});
console.log(res.data)
} catch (err) {
console.log(err)
} finally {
await driver.quit()
}
}
main()
Prints out:
Sanity check. Title is: cogitovirus.com
Session id: ce19fd89269af93327655537a1b65330
{
data: {
session: {
id: 'ce19fd89269af93327655537a1b65330',
uri: 'http://172.18.0.3:5555',
nodeId: 'ea5414e7-ac40-4744-aea5-8ff6faeeb8e2',
nodeUri: 'http://172.18.0.3:5555'
}
}
}
Tested using a quick setup of selenium grid docker
Grid GraphQL documentation