Hi,
I'm trying to open up Movies & TV app for a test on a remote machine, but opening up WinAppDriver also has to be done from a host machine. So I open it up using psexec by executing this command:
psexec \10.42.111.200 -u TestUser -p Password -h "C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe" 10.42.111.200 4723/wd/hub
I can see that the process start on remote machine. Then I push this python script to open up the app:
class ZuneTest(unittest.TestCase):
@classmethod
def setUpClass(self):
#set up appium
desired_caps = {}
desired_caps["app"] = "Microsoft.ZuneVideo_8wekyb3d8bbwe!microsoft.ZuneVideo"
desired_caps["platformName"] = "Windows"
desired_caps["deviceName"] = "WindowsPC"
self.driver = webdriver.Remote(
command_executor='http://10.42.111.200:4723/wd/hub',
desired_capabilities= desired_caps)
self.title = "Animals"
@classmethod
def tearDownClass(self):
self.driver.quit()
def test_initialize(self):
self.driver.find_element_by_name("Personal").click()
self.driver.find_element_by_name("VIDEOS").click()
# Find specified movie title
self.driver.find_element_by_xpath('//*[contains(@Name,"' + self.title + '")]').click()
time.sleep(4)
# set to full screen
try:
self.driver.find_element_by_name("Full Screen").click()
except:
print("Did not find the button for full screen")
time.sleep(90)
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(ZuneTest)
unittest.TextTestRunner(verbosity=2).run(suite)
On the remote side, I see that the Movies & TV app actually pops up, but the test errors out immediately after that with the message:
C:\Temp\test_remote_cmd>py -3 test_zune.py
ERROR
======================================================================
Traceback (most recent call last):
File "test_zune.py", line 32, in setUpClass
desired_capabilities= desired_caps)
File "C:\Python36\lib\site-packages\appium\webdriver\webdriver.py", line 36, in __init__
super(WebDriver, self).__init__(command_executor, desired_capabilities, browser_profile, proxy, keep_alive)
File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 154, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 243, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "C:\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 237, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Failed to locate opened application window with appId: Microsoft.ZuneVideo_8wekyb3d8bbwe!microsoft.ZuneVideo, and processId: 7724
Ran 0 tests in 5.847s
FAILED (errors=1)
If i look in the Task Manager, the process ID 7724 is Video.UI.exe which seems to be my application. I saw the post about getting a desktop session and taking control over the keyboard and opening up the app with that first, but i have no idea how to do that in python. Any input?
By the way, if i run the winappdriver.exe directly from the remote machine and then push the same test script, everything runs successfully. What should i do?
Thanks much!
You need to add the "-i" argument to psexec. This allows the programs it executes to interact with the desktop, and WinAppDriver needs to do that.
Yup, that's what I was missing, thank you!
Most helpful comment
You need to add the "-i" argument to psexec. This allows the programs it executes to interact with the desktop, and WinAppDriver needs to do that.