aerokube / windows-images

Step by step instructions for building Docker images with Windows
Apache License 2.0
221 stars 44 forks source link

Selenium test requests times out on windows images (MicrosoftWebDriver.exe) #47

Open nar21 opened 1 month ago

nar21 commented 1 month ago

Hello. I have setup a Windows 11 VM on a Ubuntu 24.04 host. The Windows guest starts up successfully. I am also able to connect via VNC to it (using qemu's inbuilt VNC) and use the Windows VM. My qemu command looks like this:

sudo  qemu-system-x86_64 -enable-kvm -cpu host \
-machine q35 -smp sockets=1,cores=4,threads=4 -m 8196 \
-usb -device usb-kbd -device usb-tablet -rtc base=localtime \
-net nic,model=virtio -net user,hostfwd=tcp::4444-:4444 \
-drive file=snapshot.img,media=disk,if=virtio \
-vnc :0 \
-monitor unix:qemu-monitor-socket,server,nowait \
-loadvm windows

My problem is when I try to run selenium tests on this VM. The request to the WebDriver server times out when I connect it using selenium 4 Python library.

So I tried calling a static URL using curl, even this times out and is stuck at a stage shown below:

#From Linux Host to Windows Guest
$ curl -v 127.0.0.1:4444/wd/hub/static/resource/hub.html 
*   Trying 127.0.0.1:4444...
* Connected to 127.0.0.1 (127.0.0.1) port 4444
> GET /wd/hub/static/resource/hub.html HTTP/1.1
> Host: 127.0.0.1:4444
> User-Agent: curl/8.5.0
> Accept: */*
>

What I have observed so far:

  1. I face this issue even in the Dockerized version, but I am trying to troubleshoot by running it directly on the host.
  2. This endpoint works when I call it within the Windows VM curl.exe 10.0.2.15:4444/wd/hub/static/resources/hub.html

I have a doubt if there is something going wrong in qemu's networking config. Any help would be highly appreciated! :-)