【自动化测试】关于Appium Studio 做iOS自动化测试
在windows下,基于Appium Studio 做ios自动化,录制appium脚本
这个工具——Appium Studio, 在官网是这么解释的:
Get your Appium testing projects going within minutes Install Appium Studio with a single click along with all the required development tools. Use the intuitive GUI to easily develop new tests or execute existing Appium testing projects on any local or remote devices.
让Appium测试项目在几分钟内完成
只需单击一下即可安装Appium Studio以及所有必需的开发工具。 使用直观的GUI轻松开发新测试或在任何本地或远程设备上执行现有的Appium测试项目。
是一个可以录制脚本,可以运行测试用例,它可以在windows电脑上,链接ios设备做ios的测试,这里为这个工具点个赞,我们测试ios应用不在用ios设备也能进行测试了。
下载地址:https://experitest.com/mobile-test-automation/appium-studio/
其他需要配置的appium测试环境。安装后,
界面如上。
我们链接设备,点击按钮,增加你的设备,我链接了一台安卓模拟器,一台iphone6,(注意,adb环境可能识别不了设备,去appium studo 安装目录下复制adb.exe 去替换模拟器下面的adb,修改为对应的包就可以)
那么
我们选择安装我们的应用,到指定设备上,也可以关闭启动应用, 可以选择配置,
当我们选择后,
会给我们生成对应的脚本,我们可以切换不同的脚本
都是可以很好的切换。
那么怎么录制我们的脚本呢,启动app,
选择
录制,
然后我们去模拟器去操作就可以
这样就给我们操作完,点击关闭,自动吧录制的步骤给我们添加上去,
下面生成对应的脚本,
我们点击保存按钮进行保存
录制脚本如下python版本
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 sssss(unittest.TestCase): reportDirectory = 'reports' reportFormat = 'xml' dc = {} testName = 'sssss' driver = None def setUp(self): self.dc['reportDirectory'] = self.reportDirectory self.dc['reportFormat'] = self.reportFormat self.dc['testName'] = self.testName self.dc['udid'] = '127.0.0.1:62001' self.dc['app'] = 'C:\\Users\\Administrator\\AppData\\Roaming\\appiumstudio\\apk\\com.aixuetan.onlinecom.aixuetang.mobile.activities.LaunchActivity.2.apk' self.dc['appPackage'] = 'com.aixuetan.online' self.dc['appActivity'] = 'com.aixuetang.mobile.activities.LaunchActivity' self.dc['instrumentApp'] = 'true' self.dc['platformName'] = 'android' self.driver = webdriver.Remote('http://localhost:4723/wd/hub',self.dc) def testsssss(self): self.driver.find_element_by_xpath("xpath=//*[@id='course_image' and (./preceding-sibling::* | ./following-sibling::*)[@text='高一语文通用版(全年班)']]").click() self.driver.find_element_by_xpath("xpath=//*[@text='已报名76423人']").click() self.driver.find_element_by_xpath("xpath=//*[@id='ll_enroll']").click() self.driver.find_element_by_xpath("xpath=//*[@text='03-进行更深层次的阅读(一)——赏析评价能力的提升(上)']").click() self.driver.find_element_by_xpath("xpath=//*[@text='高一语文通用版(全年班)']").click() self.driver.find_element_by_xpath("xpath=//*[@id='course_image']").click() self.driver.find_element_by_xpath("xpath=//*[@id='course_image']").click() self.driver.find_element_by_xpath("xpath=//*[@id='course_image']").click() self.driver.find_element_by_xpath("xpath=//*[@text='已报名76423人']").click() self.driver.find_element_by_xpath("xpath=//*[@text='加入课程']").click() self.driver.find_element_by_xpath("xpath=//*[@id='et_password']").click() self.driver.find_element_by_xpath("xpath=//*[@id='et_username']").send_keys('1111111') self.driver.find_element_by_xpath("xpath=//*[@id='et_password']").send_keys('11111') self.driver.find_element_by_xpath("xpath=//*[@id='tv_login']").click() def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
java版本如下
//package <set your test package>; import io.appium.java_client.remote.AndroidMobileCapabilityType; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; import io.appium.java_client.TouchAction; import java.time.Duration; import io.appium.java_client.remote.MobileCapabilityType; import io.appium.java_client.android.AndroidKeyCode; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.By; import org.testng.annotations.*; import java.net.URL; import java.net.MalformedURLException; import java.util.logging.Level; public class sssss { private String reportDirectory = "reports"; private String reportFormat = "xml"; private String testName = "sssss"; protected AndroidDriver<AndroidElement> driver = null; DesiredCapabilities dc = new DesiredCapabilities(); @BeforeMethod public void setUp() throws MalformedURLException { dc.setCapability("reportDirectory", reportDirectory); dc.setCapability("reportFormat", reportFormat); dc.setCapability("testName", testName); dc.setCapability(MobileCapabilityType.UDID, "127.0.0.1:62001"); dc.setCapability(MobileCapabilityType.APP, "C:\\Users\\Administrator\\AppData\\Roaming\\appiumstudio\\apk\\com.aixuetan.onlinecom.aixuetang.mobile.activities.LaunchActivity.2.apk"); dc.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "com.aixuetan.online"); dc.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, "com.aixuetang.mobile.activities.LaunchActivity"); dc.setCapability("instrumentApp", true); driver = new AndroidDriver<>(new URL("http://localhost:4723/wd/hub"), dc); driver.setLogLevel(Level.INFO); } @Test public void testsssss() { driver.findElement(By.xpath("//*[@id='course_image' and (./preceding-sibling::* | ./following-sibling::*)[@text='高一语文通用版(全年班)']]")).click(); driver.findElement(By.xpath("//*[@text='已报名76423人']")).click(); driver.findElement(By.xpath("//*[@id='ll_enroll']")).click(); driver.findElement(By.xpath("//*[@text='03-进行更深层次的阅读(一)——赏析评价能力的提升(上)']")).click(); driver.findElement(By.xpath("//*[@text='高一语文通用版(全年班)']")).click(); driver.findElement(By.xpath("//*[@id='course_image']")).click(); driver.findElement(By.xpath("//*[@id='course_image']")).click(); driver.findElement(By.xpath("//*[@id='course_image']")).click(); driver.findElement(By.xpath("//*[@text='已报名76423人']")).click(); driver.findElement(By.xpath("//*[@text='加入课程']")).click(); driver.findElement(By.xpath("//*[@id='et_password']")).click(); driver.findElement(By.xpath("//*[@id='et_username']")).sendKeys("1111111"); driver.findElement(By.xpath("//*[@id='et_password']")).sendKeys("11111"); driver.findElement(By.xpath("//*[@id='tv_login']")).click(); } @AfterMethod public void tearDown() { driver.quit(); } }
然后当你没有选中测试用例步骤,他会给你注释掉,点击run按钮,启动测试,
我们可以看到log上面有日志输出,
运行到步骤会选中步骤,运行完,自动生成测试报告
一些重要的信息也会展示出来
还可以看到步骤的dubeg信息,每个步骤都会有截图
可以选择最近的查看测试报告,
选择all summaries reposrt 统计了所有运行的,直观,
下面详细的记录日志。
可以录制,可以运行现有脚本,每个步骤 都有截图,还可以生成批量的测试报告,有没有很简单,关键它可以在windows执行ios测试,
推荐大家去尝鲜。
下载地址:
Appium Studio:http://d242m5chux1g9j.cloudfront.net/AppiumStudio_windows_11_4_83.exe
iTurns:http://221.204.7.14/big.softdl.360tpcdn.com/auto/20190724/50_70cfcce276a3a34d4f49de720bb72dd2.exe
初次打开,安装之后,可以看到几种的默认代码:
JAVA
//package <set your test package>; import io.appium.java_client.remote.AndroidMobileCapabilityType; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidElement; import io.appium.java_client.remote.MobileCapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; import org.junit.*; import java.net.URL; import java.net.MalformedURLException; public class Untitled { private String reportDirectory = "reports"; private String reportFormat = "xml"; private String testName = "Untitled"; protected AndroidDriver<AndroidElement> driver = null; DesiredCapabilities dc = new DesiredCapabilities(); @Before public void setUp() throws MalformedURLException { dc.setCapability("reportDirectory", reportDirectory); dc.setCapability("reportFormat", reportFormat); dc.setCapability("testName", testName); dc.setCapability(MobileCapabilityType.UDID, ""); driver = new AndroidDriver<>(new URL("http://localhost:4723/wd/hub"), dc); } @Test public void testUntitled() { } @After public void tearDown() { driver.quit(); } }
PYTHON
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'] = '' self.dc['platformName'] = 'android' self.driver = webdriver.Remote('http://localhost:4723/wd/hub',self.dc) def testUntitled(self): def tearDown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
C#
//package <set your test package>; using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using OpenQA.Selenium.Appium; using OpenQA.Selenium; using OpenQA.Selenium.Remote; using OpenQA.Selenium.Appium.Android; using OpenQA.Selenium.Appium.iOS; using NUnit; using NUnit.Framework; using OpenQA.Selenium.Appium.Enums; using OpenQA.Selenium.Support.UI; namespace Experitest { [TestFixture] public class Untitled { private string reportDirectory = "reports"; private string reportFormat = "xml"; private string testName = "Untitled"; protected AndroidDriver<AndroidElement> driver = null; DesiredCapabilities dc = new DesiredCapabilities(); [SetUp()] public void SetupTest() { dc.SetCapability("reportDirectory", reportDirectory); dc.SetCapability("reportFormat", reportFormat); dc.SetCapability("testName", testName); dc.SetCapability(MobileCapabilityType.Udid, ""); driver = new AndroidDriver<AndroidElement>(new Uri("http://localhost:4723/wd/hub"), dc); } [Test()] public void TestUntitled() { } [TearDown()] public void TearDown() { driver.Quit(); } } }
Ruby
require 'test/unit' require 'appium_lib' class Untitled < Test::Unit::TestCase def setup desired_caps = { caps: { reportDirectory: 'reports', reportFormat: 'xml', testName: 'Untitled', udid: '', platformName: 'android' }, appium_lib: { server_url: 'http://localhost:4723/wd/hub' } } @driver = Appium::Driver.new(desired_caps, false) @driver.start_driver end def test_Untitled end def teardown @driver.driver_quit end end
Appium Studio 做iOS自动化测试,可以参考着几篇文章:
https://testerhome.com/topics/17619
Appium Studio 11.4 Version - Releases - Appium Studio
今天发现一个神器 Appium Studio · TesterHome
Appium Studio 初体验(windows做ios自动化,录制appium脚本) - 北漂的雷子 - 博客园
Appium Studio - Experitest - Test Development
...
Appium+python自动化19-iOS模拟器(iOS Simulator)安装自家APP【转载】
摘自:https://www.cnblogs.com/caoj/p/7800046.html
做过iOS上app测试的小伙伴应该都知道,普通用户安装app都是从appstore下载安装,安装测试版本的app,一般就是开发给的二维码扫码安装,
或者开发给个.ipa的安装包文件,通过itools安装。对于没有iPhone真机的小伙伴,想在iOS模拟器上安装app测试可不是那么容易的事情。
一、启动iOS Simulator
1.Xcode>Open Developer Tool>iOS Simulator,打开后在hardware里面选对应的iPhone版本就能启动模拟器了
2.第二种方法,通过指令启动模拟器:
$ xcrun instruments -w 'device name'
注意:这里的device name一定要是这种格式:iPhone 6 (10.3)
二、拿到.app包
1.这里科普下了(敲黑板,记重点),在真机上是安装.ipa的包,在模拟器上是安装.app的包。
这是两种不同的打包方法,也就是说从appstore这种渠道下载的.ipa是无法安装到模拟器上的,必须要找你们开发专门针对iOS模拟器打个模拟器的包,后缀是.app 。
(别问我是怎么知道的,都是泪~~~)
2.以https://github.com/appium/sample-code.git 这里的一个.app包为例,在路径/sample-code/apps/TestApp/build/release-iphonesimulator下有个TestApp.app
这种才是可以直接安装到iOS模拟器上的
3.通过指令安装到模拟器上:
$ xcrun simctl install booted /path/to/xxx.app
备注:/path/to/xxx.app 这个是.app包的绝对路径,可以输入前面的指令,然后找到这个包,直接拽到终端就行
4.卸载app的指令:
$ xcrun simctl uninstall booted xxx.app
xxx.app就是包名,这里不需要路径,如:TestApp.app
三、xcode-select
1.要是遇到xcrun报错:xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist
就根据报错提示,输入提示的指令解决:
$ sudo xcode-select --switch path/to/Xcode.app
同样,这里path/to/Xcode.app也是Xcode在application里的绝对路径,直接找到图标拽到终端就行
2.或者输入这个也可以:
$ xcode-select --install
四、总结
1.在iOS模拟器上必须是通过xcode打出来的.app的安装包,真机的包(.ipa)选择Debug-iphone os,模拟器的包(.app)选择Debug-iphone Simulator
2.有以下几个方法都能安装到模拟器上:
--运行脚本,会自动安装上去,参考:Appium+python自动化17-启动iOS模拟器APP源码案例
--通过指令安装,也就是这篇讲的
--通过appium上的配置也能安装,下篇讲appium调试app时候定位元素
--要是会xcode,可以直接拿到拿到源码,用xcode直接运行上去
......
待续...

赠人玫瑰
手留余香
我们曾如此渴望命运的波澜,到最后才发现:人生最曼妙的风景,竟是内心的淡定与从容……我们曾如此期盼外界的认可,到最后才知道:世界是自己的,与他人毫无关系!-杨绛先生
如果,您希望更容易地发现我的新博客,不妨点击一下绿色通道的
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
2017-08-21 关于Selenium Chrome Driver相关的一些资源
2017-08-21 关于Chrome浏览器(Chrome Stable、 Chrome Canary 、Chromium)