.NET Core
에서 Selenium은 아직 지원되지 않으므로 프런트 엔드 웹 테스트를 수행하기가 어렵습니다. 다행히도 솔루션에 C# Class Library
인이라는 별도 프로젝트를 추가하면 패키지를 참조 할 수 있습니다..NET Framework 클래스 라이브러리를 사용하는 .NET Core app에서 Selenium WebDriver 연결이 거부되었습니다.
나는이 일을했지만 Selenium 웹 드라이버에서 서버가 히트되었고 응답하지 않고 어떤 이유로 응답하지 않는다고 말하는 No connection could be made because the target machine actively refused it 127.0.0.1:4444
이라는 연결 오류가 발생합니다. 여기
{"Unexpected error. System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:4444
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary'2 parameters)"}
받을오류입니다 그리고 여기에 전체 스택 트레이스 여기
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(Uri remoteAddress, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICapabilities desiredCapabilities)
at JabbR_Core.WebTests.LobbyTests.LoadAndWait() in C:\Users\jaearle\Documents\Code\JabbR-Core\test\JabbR-Core.WebTests\LobbyTests.cs:line 15
내 테스트 클래스가에게 있습니다
using System;
using System.Threading;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Project.WebTests
{
[TestClass]
public class Tests
{
[TestMethod]
public void LoadAndWait()
{
IWebDriver wd = new RemoteWebDriver(new Uri("http://localhost:59395/"), DesiredCapabilities.Chrome());
try
{
wd.Navigate().GoToUrl("http://localhost:59395/");
Thread.Sleep(5000);
if (!(wd.FindElements(By.CssSelector("section#page")).Count != 0))
{
Console.Error.WriteLine("verifyElementPresent failed");
}
}
finally
{
wd.Quit();
}
}
}
}
이 내가 전에 사용하려고 기본 (하지만이 아닌/WD/허브 부분 127.0.0.1:4444)이었고, 나는 일반적으로 응용 프로그램 로컬 호스트 포트와 일치하도록 변경 -이 : 당신은 시도해야 나는 그것이 수정되었을지도 모른다라고 생각했기 때문에 계속된다. 변경 이전에는 작동하지 않았지만 URI에/wd/hub를 추가하려고 시도합니다. – James
예// wd/hub'가 uri에 추가되어야합니다. –