Hostname invalid error when running on localhost as non-admin
See original GitHub issueI am trying to automate starting winappdriver.exe by spawning a background process from Ruby in my Cucumber script. No problem with spawn, as I have tested using it with other commands.
- The first problem is that I have to run winappdriver.exe as administrator. I looked into runas.exe but that still requires input, so it’s bad for scripting. There are other reasons not to chase this.
- The alternative is to use “localhost” as the host, since winappdriver.exe tells me I can run only as localhost without admin privileges.
winappdriver.exe localhost 4723/wd/hub
However, when I try to create the Appium webdriver, I get the following error:
unexpected response, code=400, content-type="text/html"
<!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> (Selenium::WebDriver::Error::WebDriverError)
Now if I just start winappdriver manually as administrator using 127.0.0.1 it works fine…
winappdriver.exe 127.0.0.1 4723/wd/hub
…but the problem is that it’s not great for fully automating my tests (starting and stopping winappdriver between my Cucumber runs would be nice, instead of the choice of either manual or always on).
Seeing that localhost and 127.0.0.1 are essentially the same, I did not expect an error when using one but not the other.
Thanks.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
Hi jsbakker,
I’m also confirming the need to start winappdriver as an admin and the issues you described starting with the 2nd run. I’m using the same version 1.0.1708.10001.
To your error when using hostname instead of the IP => I encountered the same issue in the beginning, unfortunately I can’t remember exactly what fixed it, but I managed to overcome it, I’m now able to start winappdriver with ‘localhost’ or even <hostname> if I use it remotely
winappdriver.exe localhost 4723
Some useful tips:
/wd/hub
inwinappdriver.exe localhost 4723/wd/hub
, as an initial workaround for some errors, perhaps exactly for the hostname error. It works just fine for me without the/wd/hub
Question: Did you manage to find a solution for starting and stopping winappdriver between your tests run? It ys, it would be helpful if you post it here, I’m also searching a way.
@hassanuz I am able to start a session without admin mode with
127.0.0.1
but I am not able to remotely connect to it. I can connect properly when I use the ip address, but unfortunately, using IP needs elevated admin permissions. If I am running in a CI/CD env, I will not be able to get elevated permissions. How do we bypass this?Edit, I was able to do this with url reservation once in admin mode: https://stackoverflow.com/questions/14962334/httplistenerexception-access-denied-for-non-admins