首页 > 解决方案 > Selenium C# - 无法建立连接,因为目标机器主动拒绝它

问题描述

在这个 If-block 中总是抛出这个异常

 if (browser.Url.StartsWith("https://account"))
 {
      browser.FindElementByCssSelector("input[type='password']").SendKeys(this.Password);
      Thread.Sleep(2000);
                    
      this.SearchClickable(browser, "button[type='button']"); // searches for elements by this selector and clicks first clickable element of result
 }

我搜索了解决方案,一位用户说要启动 Selenium Server。我使用以下命令启动它

java -jar C:\Users\User\Downloads\selenium-server-standalone-3.141.59.jar -role hub

但无论如何,硒仍然会引发该异常。我做错了什么还是问题不同?

标签: c#selenium

解决方案


推荐阅读