Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
1.24/5 (3 votes)
See more:
I am using Selenium in my Windows Form project. In Visual Studio, it works without problems. It does not work after setup. It is giving this error:

Unable to obtain chorome using selenium manager.


What I have tried:

C#
var driverService = ChromeDriverService.CreateDefaultService();
driverService.HideCommandPromptWindow = true;
var driver = new ChromeDriver(driverService, new ChromeOptions());
driver.Manage().Window.Maximize();
driver.Navigate().GoToUrl("https://***************.aspx");

IWebElement MisafirDropDownElement = driver.FindElement(By.Name("ddlMisafirSayisi"));
SelectElement SelectAnMisafir = new SelectElement(MisafirDropDownElement);
SelectAnMisafir.SelectByText(comboBox1.Text.Trim());
Posted
Updated 14-Sep-23 6:11am
v4
Comments
Richard MacCutchan 17-Aug-23 11:22am    
You forgot to show the error.
Member 12505620 18-Aug-23 1:36am    
Sorry I added the error.
Richard MacCutchan 18-Aug-23 3:35am    
Well the error message is clear, the app cannot access the chrome driver. So you beed to investigate why that is so.
Member 12505620 18-Aug-23 4:01am    
Yes, I know the reason. But I do not know the solution.
Richard MacCutchan 18-Aug-23 4:25am    
The first thing you need to do is to find out why it cannot access the driver. And that is not something anyone here can do. We have no access to the system that is causing the problem.

Since the error is specific to Selenium, and not a programming issue, you will probably get better support at the Selenium[^] website.
 
Share this answer
 
Selenium can be sensitive to different environments, versions, and configurations. You error could be due to a misconfiguration or incorrect setup. As you did not provide full code, I am guessing as to whether you have imported the correct files/namespaces -
C#
//Import necessary namespaces...
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

//Create a ChromeDriverService with default settings...
var driverService = ChromeDriverService.CreateDefaultService();

//Hide the command prompt window of the ChromeDriver...
driverService.HideCommandPromptWindow = true;

//Create a ChromeDriver instance with the configured service and options...
var driver = new ChromeDriver(driverService, new ChromeOptions());

//Maximize the browser window...
driver.Manage().Window.Maximize();

//Navigate to your specified URL...
driver.Navigate().GoToUrl("https://***************.aspx");

//Find the dropdown element by its name attribute...
IWebElement MisafirDropDownElement = driver.FindElement(By.Name("ddlMisafirSayisi"));

//Create a SelectElement instance to work with the dropdown...
SelectElement SelectAnMisafir = new SelectElement(MisafirDropDownElement);

//Select an option from the dropdown based on the text in comboBox1...
SelectAnMisafir.SelectByText(comboBox1.Text.Trim());


Some other checks you can perform -
Make sure that the ChromeDriver executable is in a directory that is included in your system's PATH environment variable. You might need to specify the full path to the ChromeDriver executable in the ChromeDriverService.CreateDefaultService() call.

Make sure that your Chrome browser and ChromeDriver version are compatible. If you've recently updated your browser, you might need to update your ChromeDriver as well.

Check that you've installed the necessary NuGet packages for Selenium and ChromeDriver in your project.

Ccheck if your firewall or other security software is maybe blocking the execution of ChromeDriver.

Try running the code in debug mode to check for errors or issues.
 
Share this answer
 
Comments
Member 12505620 19-Aug-23 3:40am    
There is no debug problem. It woks fine. Only it is not working after setup.
I have  solved the problem by adding this line by myself.. 

string path = "";
var driverService = ChromeDriverService.CreateDefaultService(path);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900