首页 > 解决方案 > 从会话 ID 获取主机名

问题描述

C# 代码我们的代码在 3 个节点上运行。我们有一个特殊要求,我们需要在脚本运行的运行时知道主机名。我已经得到了会话ID

     string sessionId = ((RemoteWebDriver)this.Driver).SessionId.ToString();

已经尝试过以下方法。但是在阅读器中没有主机名参数

       string url = "http://localhost:8080/grid/api/testsession?session=" + sessionId;
        WebClient client = new WebClient();
        Stream stream = client.OpenRead(url);
        StreamReader reader = new StreamReader(stream);

我想从我已经收到的会话 id 中获取主机名

标签: seleniumhostname

解决方案


推荐阅读