I want to start Appium server programmatically using C#. when I use Appium window to start Appium manually, It Starts successfully: Appium window
But when I run it automatically often I get an exception:
"An unhandled exception of type ‘OpenQA.Selenium.WebDriverException’ occurred in WebDriver.dll
Additional information: 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:4723"
This is the c# code for starting Appium Server:
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "C:/Program Files (x86)/Appium/node.exe";
startInfo.Arguments = @"""C:/Program Files (x86)/Appium/node.exe lib/server/main.js"" --address 127.0.0.1 --port 4723 --session-override --platform-name Android --platform-version 23 --automation-name Appium --log-no-color";
process.StartInfo = startInfo;
process.Start();
capabilities = new DesiredCapabilities();
capabilities.SetCapability("deviceName", "Samsung S6");
capabilities.SetCapability("platformName", "Android");
capabilities.SetCapability("platformVersion", "5.0.2");
capabilities.SetCapability(CapabilityType.BrowserName, "Chrome");
driver = new RemoteWebDriver(new Uri("http://127.0.0.1:4723/wd/hub"), capabilities, TimeSpan.FromSeconds(30));
I read those questions but it didn’t helped me:
Appium iOS automation using C#/Visual Studio No connection could be made because the target machine actively refused it 127.0.0.1:3446
Why when I start is manually Appium start successfully, but when I Start it the same programmatically I get refused?