WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

Bad Request message when running winappdriver remotely on C#

Open billytim22 opened this issue 5 months ago • 1 comments

Just recently discovered an issue running WinAppDriver remotely on C#. Getting the following Bad Request error below.

Unhandled exception. OpenQA.Selenium.WebDriverException: Unexpected error. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Invalid Hostname</h2>
<hr><p>HTTP Error 400. The request hostname is invalid.</p>
</BODY></HTML>

Code worked fine weeks ago so I'm not sure what the issue is. I'm able to run it just fine locally. Here is the code.

Test Runner

``winappdriver.exe '10.X.3.0 4723/wd/hub/' This works and is listening.

Test Machine

        public static void Main(String[] args)
        {
            // Launch Calculator application if it is not yet launched
            if (session == null)
            {
                AppiumOptions driver = new();
                driver.AddAdditionalCapability("app", CalculatorAppId);
                driver.AddAdditionalCapability("deviceName", "WindowsPC");

               session = new WindowsDriver<WindowsElement>(new Uri("http://10.X.3.0:4723/wd/hub/"), driver);
                session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(15);
            }
        }

Using Selenium - 3.141.0 Appium - 4.4.5

billytim22 avatar Jul 23 '25 03:07 billytim22

Did you check the host machine. Did the IP change?

anunay1 avatar Jul 24 '25 14:07 anunay1