Unable to execute Python Code generated in Appium Studio

Hello Team,

Thanks for release 11.2.23 of Appium Studio. I had written a sample test case for Android Web to launch google and enter some text in to text box.
I can successfully execute using Appium Studio UI. But when i am trying to extract code generated from Appium Studio and saved in Python file for execution.

However when i tried to execute the Python file it shows 0 tests executed.

Ran 0 tests in 0.000s
OK

Please find the below error…

Code in the python file as follows :


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’] = ‘ZY223Q2DXH’
self.dc[‘platformName’] = ‘android’
self.driver = webdriver.Remote(‘http://localhost:4723/wd/hub’,self.dc)

def testUntitled(self):
self.driver.execute_script(“client:client.setDevice(“adb:MotoG”)”)
self.driver.startActivity(“chrome: http:\www.google.com”, “”)
self.driver.find_element_by_xpath("//*[@name=‘q’]").send_keys(‘Capemini india pvt ltd’)

def tearDown(self):
self.driver.quit()

if name == ‘main’:
unittest.main()


Please help how to execute Python code generated in Appium Studio.
Also, Please let us know if this is a know issue…

Thanks in advance

HI,

Are you using any IDE for Python? I’ll recommend you to consider working with JetBrains PyCharm Community Edition

It will make your life easier and help you understand which lib is missing

Give it a try, if you face any issues, let me know and I’ll prepare project which will run in the IDE

Hello Tom,

Thanks for your response…
I tried using pycharm IDE as well…
Still facing some issues in running the script from Python PL.

Can you pls. kindly share sample test project for executing scripts in python language.

Thanks in advance

1 Like

Hi

this code works fine for me from Pycharm

can you test and send me the error that you have?

import unittest

from appium import webdriver

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['platformName'] = "android"

        self.driver = webdriver.Remote('http://localhost:4723/wd/hub', self.dc)

    def testUntitled(self):
        self.driver.find_element_by_xpath("//*").click()

    def tearDown(self):
        self.driver.quit()

    if __name__ == '__main__':
        unittest.main()
1 Like

I still face this issue. Is there any library to be imported ? Is there any settings or preferences in the pycharm to be done?

I tried (Settings -> Click + and add the following libraries shown in lib by searching the Available packages)

Hi Kishore, Thank you for responding. But i already have all these in my settings as well. Can you tell me if you are using appium studio community version or the corporate version.
Is python supported only with the paid version?

Thanks and Regards,
Ranjani Sundaradesikan

I think even with community edition it should work.

But then in your post you haven’t put any details like error, screenshot … etc

Hi Kishore,
I am using the community version of appium studio and want to run scripts on eclipse. For which i followed all the steps mentioned in this URL, https://docs.experitest.com/display/TDB/SeeTestAutomation-+Executing+Tests+In+Python+From+Eclipse
But am unable to locate Experitest.py file under Clients\Python from step 3 to complete the setup.
Please guide me to complete my setup & run my scripts.

Thank you

Sorry I haven’t tried with Eclipse as of now as I usually use pycharm

Pycharm will work and the step I have already mentioned in my screenshot in my previous post.

I will try Eclipse and let you know

Sure, Its great if you help me out from this issue
thank you…

Hi I am facing similar issue. I am able to bring up the application from Appium studio code to code put in Pycharm, but bit seems find_element(locator) does not work in my pycharm where as same find_element(locator) works in appium studio