我正在尝试在Android Studio中为我的Android应用程序构建UI测试.问题是我无法运行它们.我收到消息:任务'app:prepareDebugAndroidTestDependencies'的执行失败,我无法找到它的内容.当我运行我的应用程序时,它启动完美,但当我尝试运行测试时,它会显示上述消息.我的build.gradle在下面是lsited:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
defaultConfig {
applicationId "ba.etf.pkks.eldaralmin.libraryapp"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
maven {
url "https://raw.github.com/embarkmobile/zxing-android-minimal/mvn-repo/maven-repository/"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:support-v4:22.0.0'
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
// Supports Android 4.0.3 and later (API level 15)
compile 'com.embarkmobile:zxing-android-minimal:2.0.0@aar'
// Supports Android 2.1 and later (API level 7), but not …Run Code Online (Sandbox Code Playgroud) android ui-testing android-studio build.gradle android-gradle-plugin
我无法在我正在测试的应用程序的屏幕上找到XCUIElements.我意识到你可以通过以下方式访问按钮:
app.buttons[].elementBoundByIndex(0)
Run Code Online (Sandbox Code Playgroud)
但问题是有时候,找不到组件.就像我在UITableView中的单元格中有一个Button的情况一样.我尝试使用XCUIElementQuery来查找按钮,但它不在那里.我尝试查找表或tableviews或集合视图,即使它们在视图控制器中,它们也不会在UI测试中找到.返回数组的计数将为零.
我最初尝试记录测试,但单击我尝试访问的元素不起作用.Xcode将其检测为"其他元素",并且在尝试点击期间,播放应用程序不会前进.
是否有一种高级方法来访问UI层次结构中的UIView高级组件以进行级联?
所以这是我的层次结构的细分:
RecyclerView --> LinearLayout --> RecyclerView --> FrameLayout -> FrameLayout
Run Code Online (Sandbox Code Playgroud)
这是一个截图:
我希望能够验证FrameLayout显示的文本.这是我到目前为止所尝试的:
onView(withRecyclerView(R.id.container_list).atPositionOnView(0, R.id.row_content))
.check(matches(withRecyclerView(R.id.row_content).atPositionOnView(0, R.id.info_field)))
.check(matches(isDisplayed()));
Run Code Online (Sandbox Code Playgroud)
但它导致了AmbiguousViewMatcherException.关于如何验证嵌套视图的任何想法?应该提到我从这里使用ViewMatcher .谢谢.
我开始尝试使用EarlGrey一点点,现在已经使用XCUITest进行了UI测试.我遇到了无法解除系统警报的经典问题,这很奇怪,因为看起来Google实现了一个名为grey_systemAlertViewShown()的系统警报匹配器.我正在尝试使用GREYCondition检测系统警报.这是我尝试过的:
- (void)waitForAndDismissSystemAlertForSeconds:(NSInteger)seconds {
GREYCondition *interactableCondition = [GREYCondition conditionWithName:@"isInteractable" block:^BOOL{
// Fails if element is not interactable
NSError *error;
[[EarlGrey selectElementWithMatcher:grey_systemAlertViewShown()] assertWithMatcher:grey_interactable() error:&error];
if (error) {
return NO;
} else {
NSError *allowButtonError;
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Allow")] assertWithMatcher:grey_notNil() error:&allowButtonError];
if (!allowButtonError) {
[[EarlGrey selectElementWithMatcher:grey_accessibilityLabel(@"Allow")] performAction:grey_tap()];
}
return YES;
}];
[interactableCondition waitWithTimeout:seconds];
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过使用这里描述的addUIInterruptionMonitorWithDescription(但是使用EarlGrey代码来完成我在上面的中断监视器中所做的事情):Xcode 7 UI测试:如何在代码中解除一系列系统警报
两种方法都不奏效.我的GREYCondition中的非错误情况不会触发断点,并且中断监视器也不会解除我的警报.
有人知道EarlGrey是否支持解雇系统警报?
我正在尝试为我的控制器创建UI测试。我填充了文本字段并点击了按钮,现在我想等待对话框出现,当对话框停止时,我想点击确定按钮并检查显示的控制器。
这是我的测试方法的结尾:
let alert = app.alerts["Error"]
let exists = NSPredicate(format: "exists == 1")
self.expectationForPredicate(exists, evaluatedWithObject: alert, handler: nil)
self.waitForExpectationsWithTimeout(5.0) { (error) in
XCTAssertNil(error, "Something went horribly wrong")
alert.buttons["Ok"].tap()
XCTAssertEqual(app.navigationBars.element.identifier, "RegistrationViewController")
}
Run Code Online (Sandbox Code Playgroud)
问题是测试被评估为失败,但是当我看着电话时,出现对话框,点击确定按钮,控制器也很好。
我在调试窗口中遇到此故障:
UI测试失败-未找到与警报匹配的内容
我想那把Tap有某种问题。我该如何解决?我做错了什么?谢谢
我一直在Xcode 7.3中编写UI测试,最近想添加一个启动参数来在应用程序中启用一些测试代码.我最初尝试设置,XCUIApplication().launchArguments因为有几个人在各种帖子中做过,但他们不会工作.
周围挖看来,两者launchArguments并launchEnvironment不能成为UI测试中设置好,即使API文档说,他们可以.
此外,当我尝试在UI测试方案中设置启动参数和环境变量时,它们也没有传递到应用程序,在单元测试或运行应用程序时,它们是.
这是我为证明这一点所做的快速测试的副本,所有这些测试都失败了.
import XCTest
class LaunchDebugUITests: XCTestCase {
func testLaunchArgumentsSetting() {
XCUIApplication().launchArguments = ["abc"]
print("Arguments \(XCUIApplication().launchArguments)")
XCTAssertTrue(XCUIApplication().launchArguments.contains("abc"))
}
func testLaunchArgumentsAppending() {
XCUIApplication().launchArguments.append("abc")
print("Arguments \(XCUIApplication().launchArguments)")
XCTAssertTrue(XCUIApplication().launchArguments.contains("abc"))
}
func testLaunchEnvironmentSetting() {
XCUIApplication().launchEnvironment = ["abc":"def"]
print("Environment \(XCUIApplication().launchEnvironment)")
XCTAssertEqual("def", XCUIApplication().launchEnvironment["abc"])
}
func testLaunchEnvironmentAppending() {
XCUIApplication().launchEnvironment["abc"] = "def"
print("Environment \(XCUIApplication().launchEnvironment)")
XCTAssertEqual("def", XCUIApplication().launchEnvironment["abc"])
}
}
Run Code Online (Sandbox Code Playgroud)
有人遇到过这种情况么?你有工作吗?
我有问题,如果我尝试允许系列系统警报,只工作一次,下一个警报不"允许"我谷歌搜索更多时间,并知道该帖子:(Xcode 7 UI测试:如何解雇一系列系统警报代码)没什么..不行.这是我当前的代码,首先警告"允许"成功,未检测到下一个警报..
XCUIApplication *app = [[XCUIApplication alloc] init];
app.launchEnvironment = @{
@"isUITest" : @YES,
@"withFakeData" : fakeData
};
[app launch];
for (int i = 1; i <= self.possibleSystemAlerts; i++) {
NSLog(@"%d", i);
XCTestExpectation *expectation = [self expectationWithDescription:@"High Expectations"];
id monitor = [self addUIInterruptionMonitorWithDescription:@"Push notifications" handler:^BOOL(XCUIElement *_Nonnull interruptingElement) {
XCUIElement *element = interruptingElement;
XCUIElement *allow = element.buttons[@"Allow"];
XCUIElement *ok = element.buttons[@"OK"];
if ([ok exists]) {
[ok tap];
[expectation fulfill];
return YES;
}
if ([allow exists]) {
[allow forceTap]; …Run Code Online (Sandbox Code Playgroud) 我正在写一些UITests使用该Xamarin.UITest库.但是我运行的每个测试总是运行两次,无论它是通过还是失败?
我的应用配置如下所示:
app = ConfigureApp.Android.ApkFile(PathToAPK).WaitTimes(new WaitTimes()).EnableLocalScreenshots().StartApp(Xamarin.UITest.Configuration.AppDataMode.DoNotClear);
Run Code Online (Sandbox Code Playgroud)
我的所有测试类都标有以下属性:
[TestFixture(Platform.Android)]
[TestFixture(Platform.iOS)]
Run Code Online (Sandbox Code Playgroud)
我在Android上运行测试,它将在Android上运行两次,无论它是通过还是失败.
我怎么阻止这个?/这是什么造成的?
我正在测试iOS应用程序,目前我检查特定的存在XCUIElement使用isHittable。
我想知道我们是否还可以检查XCUIElement在视图上的位置。例如,如果我们在视图的右下角有一个按钮,是否可以使用XCTest框架检查它实际上是否在右下角?
我看了XCTest框架的Apple文档,但是没有任何线索。任何帮助将不胜感激。
因此,我一直在尝试阅读有关UI和集成测试(专门针对iOS开发)的信息。尽管这些测试始终是不同的,但我看到的许多集成测试示例似乎都是我所谓的UI测试。
所以现在我很好奇,UI和集成测试之间有什么区别?你能举个例子吗?
ui-testing ×10
ios ×7
xcode ×3
android ×2
swift ×2
alert ×1
build.gradle ×1
c# ×1
earlgrey ×1
objective-c ×1
unit-testing ×1
xamarin ×1
xcode7 ×1
xctest ×1