Why "Launch(app)" in Python Code Cannot Work?

Hi

I’m trying to use the python code which is generated from Appium Studio to run a test. And I found that “Launch(app)” in Python Code “startActivity(app)” cannot work in my environment.
And there’s an AttributeError: " ‘Webdriver’ object has no attribute ‘startActivity’ " shows in my IDE.
Is there an another appium library I have to import? Or Is there any solution that I can use the ‘Launch(app)’ in python code environment?

below pictures shows the AS script , the python code, the python code error:

Appium Studio Command:

Python Code:


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

    def testUntitled(self):
        self.driver.startActivity("com.experitest.ExperiBank", ".LoginActivity")

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

Python Code Error:

Hi @shane,

We will look into this, for now please use this workaround:
self.driver.execute_script(“seetest:client.launch(“com.experitest.ExperiBank/.LoginActivity”, false, true)”)

Please note that if you are working in instrumented mode, then the first boolean needs to be changed to true.
Regards,

Hi @khaleda,

Thanks a lot !
It works after I make some change to the parameter as below:
self.driver.execute_script(“seetest:client.launch(“com.experitest.ExperiBank/.LoginActivity”, “false”, “true”)”)

And there’s an another question.
How can I use the “ExecuteScirpt(script)” in Appium Studio?
I have tried the command “ExecuteScript(script)” with 2 parameter as below:

  1. seetest:client.launch(“com.experitest.ExperiBank/.LoginActivity”, “false”, “true”)
  2. seetest:client.sendText("{HOME}")

After I press the button “Run Test”, it shows a message “Failed to run javascript”:null ".

Is there a sample that I can make the “ExecuteScript(script)” work in Appium Studio?

Hi @shane,

This indeed does not work, running commands using the internal client is currently supported only from code environment and not from the studio UI.
We will look into supporting this syntax from Appium studio UI as well.

Regards