如何获取您的应用程序 iOS UIA 自动化的 Bundle Id

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8742355/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 16:09:17  来源:igfitidea点击:

How to get Bundle Id of your app iOS UIA automation

iosautomationui-automationios-ui-automation

提问by swathy valluri

How do I get the bundle Id of the app I am in ?

如何获取我所在应用的捆绑 ID?

回答by Tommy

You'd use:

你会使用:

[[NSBundle mainBundle] bundleIdentifier]

+ mainBundle"[r]eturns the NSBundle object that corresponds to the directory where the current application executable is located." and hence will return an NSBundleobject for the application bundle.

+ mainBundle“[r] 返回对应于当前应用程序可执行文件所在目录的 NSBundle 对象。” 因此将为NSBundle应用程序包返回一个对象。

[- bundleIdentifier]Returns "[t]he receiver's bundle identifier, which is defined by the CFBundleIdentifier key in the bundle's information property list."

[ - bundleIdentifier]返回“[t]接收者的包标识符,它由包的信息属性列表中的 CFBundleIdentifier 键定义。”

回答by swathy valluri

Here is how I got the Bundle Id for my APP in the UIA Scripts:

以下是我在 UIA 脚本中为我的应用程序获取 Bundle Id 的方法:

//code to get bundle id
var target = UIATarget.localTarget();
var app_name = target.frontMostApp().bundleID();
UIALogger.logDebug(app_name);

回答by Sanjay

You can findle the bundle id from the plist. Right Click in the app file and click on "show package contents". You will find a plist file there. Open it with any text editor and you will get the bundle id.

您可以从 plist 中找到包 ID。右键单击应用程序文件,然后单击“显示包内容”。你会在那里找到一个 plist 文件。使用任何文本编辑器打开它,您将获得包 ID。