我正在使用 XCUITest 和 XCode 版本 8.3.3。该应用程序有一个登录按钮,可启动浏览器窗口。想知道是否有人可以告诉我如何访问打开的 URL 的值。我想验证我们在选择“登录”按钮时启动了正确的 URL。
let app = XCUIApplication()
let loginButton = app.buttons["Login"]
loginButton.tap()
Run Code Online (Sandbox Code Playgroud)
如何获取 xyz.com 的价值?
我正在使用 xcode 8.3.3,swift,并且我试图让tearDown 方法仅运行一次。
我使用此处提供的解决方案启动 应用程序一次:XCTestCase not launch application in setUp class method
在tearDown 方法中,我想注销应用程序。我只想做一次。
XCTest文档有一个类tearDown()方法,但是当我尝试使用它时 - 它不再能够访问应用程序?:https: //developer.apple.com/documentation/xctest/xctestcase/understand_setup_and_teardown_for_test_methods
这就是我在tearDown方法中得到的所有内容,因此它无法再访问应用程序上的任何元素:
如何在所有测试结束时仅运行一次tearDown 中的代码?
pyautogui 的点击方法的问题:我正在从 Spyder 运行脚本,如果我点击 Spyder 窗口上的任何内容,点击工作正常。
如果我执行一个脚本来打开 Outlook,然后点击任何东西,点击不会发生。虽然我能够正确使用“moveTo”功能。
我按照谷歌搜索的建议尝试过的事情:
pyautogui.click()
pyautogui.click()
Run Code Online (Sandbox Code Playgroud)
操作系统:mac os high sierra
注意:为了获得任何定位的图像,我必须做坐标/2,因为它是 Retina 2x 显示器。
任何解决方法或任何帮助将不胜感激。
1)UIATarget [name:(null)value:(null)NSRect:{{2.7520829e-39,2.0667855e-36},{0,1.4012985e-45}}]
2)UIAApplication [name:tosh.0 value:(null)NSRect:{{0,20},{320,460}}]
3)UIAWindow [name:(null)value:(null)NSRect:{{0,0},{320,480}}]
4)....
5)....
3)UIAWindow [name:(null)value:(null)NSRect:{{0,0},{320,480}}]
4)UIAAlert [name:(null)value:(null)NSRect:{{18,180},{284,141}}]
5)UIAStaticText [名称:无法连接值:(null)NSRect:{{30,225},{260,21}}]
5)UIAButton [名称:OK值:( null)NSRect:{{29,262},{262,43}}]
请问如何在第二个UIAWindow上按"OK".给出语法.
我正在为我的程序编写自动化测试,并希望自动化设备方向......我使用下面的代码来设置设备的方向,
UIATarget.localTarget().setDeviceOrientation(UIA_DEVICE_ORIENTATION_LANDSCAPERIGHT);
Run Code Online (Sandbox Code Playgroud)
但我也希望获得该设备的当前方向.我找不到任何getDeviceOrientation()方法来获取方向.
我想出了如何解除系统警报,但我无法等待它显示,因为应用程序没有看到系统警报.我尝试使用app.debugDescription和app.alerts.count进行调试,但没有运气.
我正在使用xcode 8.3.3并编写XCUI测试.
我有以下内容:
let address = XCUIApplication().buttons["URL"].value as! String
查看调试器,我可以看到值是:
如果我设置
expectedURL = "\u{e2}auth.int....net"然后它返回:
如果我设置
expectedURL = "auth.int....net"然后它返回:
如何使测试断言找到两个相等的字符串?
试过以下内容,但它不会取代"\ u {e2}":
let address = value.components(separatedBy: ",").first!.replacingOccurrences(of: "\u{e2}", with: "")
Run Code Online (Sandbox Code Playgroud)
而且(但它不会取代"\ u {e2}"):
let range = Range<String.Index>(uncheckedBounds: (lower: address.startIndex, upper: address.endIndex))
let strippedAddress = address.replacingOccurrences(of:"\\u{e2}", with: "", options: .literal, range: range)
Run Code Online (Sandbox Code Playgroud)
对于断言,我正在使用 XCTAssertEqual(address, expectedURL)
ios ×3
xctest ×3
swift ×2
xcode8 ×2
automation ×1
iphone ×1
javascript ×1
orientation ×1
pyautogui ×1
python ×1
python-3.x ×1
xcode ×1
xctestcase ×1