1

I'm getting an error on the line "driver = webdriver.Remote(....)" in the following code:

import unittest
from appium import webdriver
import os
os.startfile('C:\\Program Files (x86)\\Windows Application Driver\\WinAppDriver.exe')    
desired_caps = {}
desired_caps['app'] = "Chrome"
desired_caps['platformName'] = "Windows"
desired_caps['deviceName'] = "WindowsPC"
driver = webdriver.Remote("http://127.0.0.1:4723/", desired_caps)

When I debug on Visual Studio Code, I get this message:

Exception has occurred: WebDriverException
Message: 
  File "C:\Users\....", line 31, in <module>
    driver = webdriver.Remote("http://127.0.0.1:4723/", desired_caps)```

The console log on WinAppDriver.exe is:

Press ENTER to exit.


==========================================
POST //session/ HTTP/1.1
Accept: application/json
Accept-Encoding: identity
Connection: keep-alive
Content-Length: 179
Content-Type: application/json;charset=UTF-8
Host: 127.0.0.1:4723
User-Agent: appium/python 2.6.1 (selenium/4.1.0 (python windows))
X-Idempotency-Key: e7bcc20b-58b0-4239-a551-1a048c935bc6

{"capabilities": {"firstMatch": [{}], "alwaysMatch": {"appium:app": "Chrome", "platformName": "Windows", "appium:deviceName": "WindowsPC"}}}
HTTP/1.1 404 Not Found

I have already tried the following things and they didn't work:

  • Referring to the calculator app by 'C:\ProgramFiles\Google\Chrome\Application\chrome.exe' instead of 'Chrome'
  • Use other applications (instead of Chrome)
  • Starting WebDriverApp manually

Can someone please help me? It's my first time using WebDriverApp.

Thank you!

1 Answers1

0

WinAppDriver uses jsonwire to communicate with selenium/appium-python-client however Selenium 4 and Appium-Python-Client 2.6.1 uses w3c instead.

You can get your code working if you downgrade selenium to v3.141.0 and appium-python-client to v1.3.0

e.g.

pip uninstall selenium
pip uninstall appium-python-client
pip install selenium==3.141.0
pip install appium-python-client==1.3.0

However if you are going to automate webpages via Chrome you would better off using a chromedriver specific to your version of Chrome, then you wouldn't need WinAppDriver.

This code works for me:

from appium import webdriver
import os
os.startfile('C:\\Program Files (x86)\\Windows Application Driver\\WinAppDriver.exe')    
desired_caps = {}
desired_caps['app'] = "Chrome"
desired_caps['platformName'] = "Windows"
driver = webdriver.Remote("http://127.0.0.1:4723", desired_caps)
Javageddon
  • 76
  • 3
  • Thanks! I tried it and it doesn't work. Do you know anything else which could be causing the issue? By the way, I'm not using it to automate Chrome tasks, but tasks on another Windows application. Thanks! – Felipe Platzer Aug 14 '22 at 22:32
  • You might need to take the trailing slash off the remote driver address – Javageddon Aug 15 '22 at 16:45