Ao executar o código abaixo:
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SeleniumComChrome
{
class Program
{
static void Main(string[] args)
{
IWebDriver chrome = new ChromeDriver(@"C:\Program Files");
chrome.Navigate().GoToUrl("http://www.google.com");
IWebElement caixaDeTexto = chrome.FindElement(By.Name("q"));
caixaDeTexto.SendKeys("Caelum");
caixaDeTexto.Submit();
chrome.Close();
}
}
}
Está dandoo seguinte erro na linha:IWebElement caixaDeTexto = chrome.FindElement(By.Name("q"));
An unhandled exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll
Additional information: Unexpected error. System.Net.WebException: Impossível conectar-se ao servidor remoto ---> System.Net.Sockets.SocketException: Nenhuma conexão pôde ser feita porque a máquina de destino as recusou ativamente 127.0.0.1:59658
em System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
em System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
--- Fim do rastreamento de pilha de exceções internas ---
em System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
em System.Net.HttpWebRequest.GetRequestStream()
em OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
em OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
em OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)