Невозможно автоматизировать тестирование приложений Unity с помощью AltUnity Tester для сборок симулятора IOS

#python #selenium #unity3d #automation #ios-simulator

#python #selenium #unity3d #автоматизация #ios-simulator

Вопрос:

Я успешно выполнил сценарии автоматического тестирования на Python для своего приложения Unity с помощью AltUnity Tester, которые запускаются в редакторе Unity. Однако у меня возникают проблемы с выполнением тех же скриптов Python в симуляторе IOS. Я могу установить соединение с сервером 13000, но я получаю ошибки при попытке взаимодействовать с элементами.

Вот код редактора:

 import os
import unittest
import time
from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy
#from altunityrunner import AltrunUnityDriver
#from altunityrunner import By
from altunityrunner import *


class SimulatorTest(unittest.TestCase):
    altdriver = None


    @classmethod
    def setUpClass(cls):
        print("here we go!")
        cls.altdriver = AltUnityDriver(None, 'ios','127.0.0.1',13000,log_flag = True)

    @classmethod
    def tearDownClass(cls):
        print("we're done!")
        cls.altdriver.stop()
        

    def test_play(cls):
        time.sleep(10)
        cls.altdriver.find_object(By.NAME,"AnimatedPlayButton").tap()

        print("Done")

        cls.altdriver.stop()

if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(SimulatorTest)
    result = unittest.TextTestRunner(verbosity=2).run(suite)
    sys.exit(not result.wasSuccessful())
  

Вот код симулятора IOS:

 import os
import unittest
import time
from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy
#from altunityrunner import AltrunUnityDriver
#from altunityrunner import By
from altunityrunner import *
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

class SimulatorTest(unittest.TestCase):
    altdriver = None
    platform = "ios"

    @classmethod
    def setUpClass(cls):
        cls.desired_caps = {}
        cls.desired_caps['platformName'] = 'iOS'
        cls.desired_caps['deviceName'] = 'iPhone 11'
        cls.desired_caps['automationName'] = 'XCUITest'
        cls.desired_caps['platformVersion'] = '13.4'
        app = os.path.abspath('/Users/domenicsorace/Desktop/Build/Products/ReleaseForRunning-iphonesimulator/twodotsdev.app')
        cls.desired_caps['app'] = app
        cls.driver = webdriver.Remote('http://localhost:4723/wd/hub', cls.desired_caps)
        
        wait = WebDriverWait(cls.driver, 5)
        # close the iOS pop up
        element = wait.until(EC.element_to_be_clickable((MobileBy.ID, "Allow")))
        cls.driver.switch_to.context('NATIVE_APP')
        cls.driver.find_element_by_id("Allow").click()
        cls.altdriver = AltUnityDriver(None, 'ios','192.168.0.3',13000,log_flag = True)

    @classmethod
    def tearDownClass(cls):
        cls.altdriver.stop()
        

    def test_play(cls):
        cls.altdriver.find_object(By.NAME,"AnimatedPlayButton").tap()
        print("Done")

if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(SimulatorTest)
    result = unittest.TextTestRunner(verbosity=2).run(suite)
    sys.exit(not result.wasSuccessful())
  

Ошибки:

 2020-09-18 15:41:34.730 | DEBUG    | altunityrunner.commands.base_command:recvall:46 - Received data was: error:unknownError;System.Exception: Expected / or // instead of None
  at Assets.AltUnityTester.AltUnityServer.AltUnityBaseClassFindObjectsCommand.SetCondition (System.Collections.Generic.List`1[T] list) [0x00000] in <00000000000000000000000000000000>:0
  at Assets.AltUnityTester.AltUnityServer.AltUnityBaseClassFindObjectsCommand.ProcessPath (System.String path) [0x00000] in <00000000000000000000000000000000>:0
  at Assets.AltUnityTester.AltUnityServer.Commands.AltUnityFindObjectCommand.Execute () [0x00000] in <00000000000000000000000000000000>:0
  at AltUnityCommand <>c__DisplayClass0_0.<SendResponse>b__0 () [0x00000] in <00000000000000000000000000000000>:0
  at AltResponseQueue.Cycle () [0x00000] in <00000000000000000000000000000000>:0
2020-09-18 15:41:34.730 | DEBUG    | altunityrunner.commands.command_returning_alt_elements:get_alt_element:16 - error:unknownError;System.Exception: Expected / or // instead of None
  at Assets.AltUnityTester.AltUnityServer.AltUnityBaseClassFindObjectsCommand.SetCondition (System.Collections.Generic.List`1[T] list) [0x00000] in <00000000000000000000000000000000>:0
  at Assets.AltUnityTester.AltUnityServer.AltUnityBaseClassFindObjectsCommand.ProcessPath (System.String path) [0x00000] in <00000000000000000000000000000000>:0
  at Assets.AltUnityTester.AltUnityServer.Commands.AltUnityFindObjectCommand.Execute () [0x00000] in <00000000000000000000000000000000>:0
  at AltUnityCommand <>c__DisplayClass0_0.<SendResponse>b__0 () [0x00000] in <00000000000000000000000000000000>:0
  at AltResponseQueue.Cycle () [0x00000] in <00000000000000000000000000000000>:0
  

Ответ №1:

Удалите или прокомментируйте эту строку:

from selenium.webdriver.common.by import By

By определение из altunityrunner переопределяется строкой выше.