Appium studio录制的代码在phthon里面运行不了

Error
Traceback (most recent call last):
File “D:\software\Python\Python37\lib\unittest\case.py”, line 59, in testPartExecutor
yield
File “D:\software\Python\Python37\lib\unittest\case.py”, line 615, in run
testMethod()
File “C:\Users\16621\PycharmProjects\app_auto\testcase\test_111.py”, line 30, in test_1
self.driver = webdriver.Remote(‘http://localhost:4723/wd/hub’, self.dc)
File “C:\Users\16621\PycharmProjects\app_auto\venv\lib\site-packages\appium\webdriver\webdriver.py”, line 144, in init
proxy
File “C:\Users\16621\PycharmProjects\app_auto\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py”, line 157, in init
self.start_session(capabilities, browser_profile)
File “C:\Users\16621\PycharmProjects\app_auto\venv\lib\site-packages\appium\webdriver\webdriver.py”, line 219, in start_session
response = self.execute(RemoteCommand.NEW_SESSION, parameters)
File “C:\Users\16621\PycharmProjects\app_auto\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py”, line 321, in execute
self.error_handler.check_response(response)
File “C:\Users\16621\PycharmProjects\app_auto\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py”, line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created (Call to lock device failed)
Stacktrace:
at java.util.concurrent.FutureTask.get (:-1)
at com.experitest.image.agent.appium.http.AppiumInitSessionCommandHandler.handle (AppiumInitSessionCommandHandler.java:120)
at org.restlet.routing.Filter.doHandle (Filter.java:150)
at org.restlet.routing.Filter.handle (Filter.java:197)
at org.restlet.routing.Router.doHandle (Router.java:422)
at org.restlet.routing.Router.handle (Router.java:641)
at org.restlet.routing.Filter.doHandle (Filter.java:150)
at org.restlet.routing.Filter.handle (Filter.java:197)
at org.restlet.routing.Router.doHandle (Router.java:422)
at org.restlet.routing.Router.handle (Router.java:641)
at org.restlet.routing.Filter.doHandle (Filter.java:150)
at org.restlet.routing.Filter.handle (Filter.java:197)
at org.restlet.routing.Router.doHandle (Router.java:422)
at org.restlet.routing.Router.handle (Router.java:641)
at org.restlet.routing.Filter.doHandle (Filter.java:150)
at org.restlet.engine.application.StatusFilter.doHandle (StatusFilter.java:140)
at org.restlet.routing.Filter.handle (Filter.java:197)
at org.restlet.routing.Filter.doHandle (Filter.java:150)
at org.restlet.routing.Filter.handle (Filter.java:197)
at org.restlet.engine.CompositeHelper.handle (CompositeHelper.java:202)
at org.restlet.Component.handle (Component.java:408)
at org.restlet.Server.handle (Server.java:507)
at org.restlet.engine.connector.ServerHelper.handle (ServerHelper.java:63)
at org.restlet.engine.adapter.HttpServerHelper.handle (HttpServerHelper.java:143)
at org.restlet.engine.connector.HttpServerHelper$1.handle (HttpServerHelper.java:64)
at com.sun.net.httpserver.Filter$Chain.doFilter (:-1)
at sun.net.httpserver.AuthFilter.doFilter (:-1)
at com.sun.net.httpserver.Filter$Chain.doFilter (:-1)
at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle (:-1)
at com.sun.net.httpserver.Filter$Chain.doFilter (:-1)
at sun.net.httpserver.ServerImpl$Exchange.run (:-1)
at java.util.concurrent.ThreadPoolExecutor.runWorker (:-1)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (:-1)
at java.lang.Thread.run (:-1)

Error
Traceback (most recent call last):
File “D:\software\Python\Python37\lib\unittest\case.py”, line 59, in testPartExecutor
yield
File “D:\software\Python\Python37\lib\unittest\case.py”, line 618, in run
self.tearDown()
File “C:\Users\16621\PycharmProjects\app_auto\testcase\test_111.py”, line 35, in tearDown
self.driver.quit()
AttributeError: ‘NoneType’ object has no attribute ‘quit’

Assertion failed
D:\software\Python\Python37\lib\unittest\case.py:643: ResourceWarning: unclosed <socket.socket fd=712, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=(‘127.0.0.1’, 55608), raddr=(‘127.0.0.1’, 4723)>
outcome.errors.clear()

Have you exported the python code from AStudio and running code outside ? Have you checked if other language run is working ?

i try run a python script outside Appium Studio but it doesn’t work

run this command “python.exe prueba2.py”, this shows this:
python.exe .\prueba2.py


Ran 0 tests in 0.000s

OK

if i run “python.exe prueba2.py Untitled” show me this:

E

ERROR: Untitled (unittest.loader._FailedTest)

AttributeError: module ‘main’ has no attribute ‘Untitled’


Ran 1 test in 0.022s

FAILED (errors=1)

other fail tries:
PS C:\Users\User\Documents\appium> python.exe .\prueba2.py testUntitled
E

ERROR: testUntitled (unittest.loader._FailedTest)

AttributeError: module ‘main’ has no attribute ‘testUntitled’


Ran 1 test in 0.000s

FAILED (errors=1)
PS C:\Users\User\Documents\appium> python.exe .\prueba2.py Untitled.testUntitled
E

ERROR: Untitled (unittest.loader._FailedTest)

AttributeError: module ‘main’ has no attribute ‘Untitled’


Ran 1 test in 0.001s

FAILED (errors=1)

my code is this:

import unittest
import time
from appium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions

class Untitled(unittest.TestCase):
reportDirectory = ‘reports’
reportFormat = ‘xml’
dc = {}
testName = ‘Untitled’
driver = None

def setUp(self):
    self.dc['reportDirectory'] = self.reportDirectory
    self.dc['reportFormat'] = self.reportFormat
    self.dc['testName'] = self.testName
    self.dc['udid'] = 'XXXXXXXXXXXXXXXXXXXXXXXXX'
    self.dc['platformName'] = 'ios'
    self.driver = webdriver.Remote('http://localhost:4723/wd/hub',self.dc)

def testUntitled(self):
    self.driver.find_element_by_xpath("xpath=//*[@text='‎WhatsApp']").click()
    self.driver.find_element_by_xpath("xpath=(((//*[@text='‎WhatsApp']/*/*/*/*/*[@class='UIAView' and ./parent::*[@class='UIAView' and ./parent::*[@class='UIAView' and ./parent::*[@class='UIAView' and ./parent::*[@class='UIAWindow']]]]])[2]/*[@class='UIAView'])[2]/*[@class='UIAView' and @height>0])[2]").send_keys('test')
    WebDriverWait(self.driver, 30).until(expected_conditions.presence_of_element_located((By.XPATH,"//*[@text='‎Enviar']")))
    self.driver.find_element_by_xpath("xpath=//*[@text='‎Enviar']").click()
    self.driver.execute_script("seetest:client.deviceAction(\"Home\")")

def tearDown(self):
    self.driver.quit()
    
if __name__ == '__main__':
    unittest.main()

grateful for you help