xctestcase

typeText() is typing inconsistent characters

喜你入骨 提交于 2020-04-18 06:09:40
问题 I'm beginning to dip my toes into Swift alongside writing UI tests and am having a problem with typing text into a textField. Below is the code: func testLoginUsernameField() { let app = XCUIApplication() app.launch() let username = "testusername2" let usernameField = app.textFields["username_field"] XCTAssertTrue(usernameField.exists) usernameField.tap() usernameField.typeText(username) XCTAssertEqual(usernameField.value as! String, username) } The problem occurs when I do usernameField

How to Dynamically add XCTestCase

本小妞迷上赌 提交于 2020-01-13 12:08:13
问题 I'm writing a UI Test for a white label project where each app has a different set of menu items. The test taps on each menu item and takes a screenshot (using fastlane snapshot). Currently this all happens inside one XCTestCase called testScreenshotAllMenuItems() which looks like this: func testScreenshotAllMenuItems() { // Take a screenshot of the menu openTheMenu() snapshot("Menu") var cells:[XCUIElement] = [] // Store each menu item for use later for i in 0..<app.tables.cells.count {

XCTestCase of a UIButton tap

浪子不回头ぞ 提交于 2020-01-06 04:54:06
问题 I am trying to unit test the wiring of button taps in a UIViewController but I'm finding these tests fail even though the code in the running app works fine. I've simplified the failing test by removing the view controller and such leaving simply: import XCTest class ButtonTest: XCTestCase { var gotTap: XCTestExpectation! func test_givenButtonWithTargetForTapAction_whenButtonIsSentTapAction_thenTargetIsCalled() { gotTap = expectation(description: "Button tap recieved") let button = UIButton()

XCTestCase with Auth0: How to dismiss security alert “XXXX” Wants to Use “auth0.com” to Sign In

試著忘記壹切 提交于 2019-12-08 19:42:13
问题 So recently Apple introduced this prompt: “XXXX” Wants to Use “auth0.com” to Sign In Where “XXXX” is the ios app name. This alert/dialog comes up when in the case of Auth0 the user clicks on “Login with Google” or “Login with Facebook”. That’s all nice but when running IOS UI tests, this dialog doesn’t go away when using the usual way of dismissing system dialogs: func doUserLogin(_ app: XCUIApplication) { app.staticTexts["notLoggedInActivelabel"].tap() // this will bring up oauth0 login

XCTestCase not launching application in setUp class method

不想你离开。 提交于 2019-12-08 01:36:22
问题 I am using XCode 8 and XCTestCase. I created a class setUp function to be ran once before all tests, and the other setUp to be ran before each test case. I want the application to be launched once before all test cases. If I use the launch in the class setUp, it never gets executed. If I use the launch in the setUp that is ran before each test, it does launch the test. It prints: IN CLASS SETUP END CLASS SETUP IN SETUP IN TEST METHOD But the application never gets launched. If I uncomment the

XCTestCase not launching application in setUp class method

China☆狼群 提交于 2019-12-06 07:43:05
I am using XCode 8 and XCTestCase. I created a class setUp function to be ran once before all tests, and the other setUp to be ran before each test case. I want the application to be launched once before all test cases. If I use the launch in the class setUp, it never gets executed. If I use the launch in the setUp that is ran before each test, it does launch the test. It prints: IN CLASS SETUP END CLASS SETUP IN SETUP IN TEST METHOD But the application never gets launched. If I uncomment the line to launch the application in the second setUp, it will get launched. How can I have the

In XCTest UI Testing, how to check the background color of button, label , views?

☆樱花仙子☆ 提交于 2019-12-06 00:07:39
问题 I am trying to validate if the background color can be obtained in XCTest UI Testing, I am looking to compare the background color with the set value, so that i don't have to rely on image comparison 回答1: XCTest is for functional testing, rather than asserting visual requirements. To test requirements such as background color, use a unit test to initialize the view controller in question and check the view's background color there. You don't need to rely on image comparison, and unit tests

XCTestCase: Wait for app to idle

痞子三分冷 提交于 2019-12-04 08:41:17
问题 My UI-test fails because the test waits endless until the app idles. I can not see that there is anything happening in the background, like a loading spinner. It just occurs on one tab. All others tabs are tapable but the test fails on Screen 3. I I click on another tab after the test is caught on Screen 3 the test resumes and finishes successfully. Any ideas? - (void)testExample { XCUIElementQuery* tabBarsQuery = self.app.tabBars; [tabBarsQuery.buttons[@"Screen2"] tap]; [tabBarsQuery.buttons

In XCTest UI Testing, how to check the background color of button, label , views?

走远了吗. 提交于 2019-12-04 05:14:14
I am trying to validate if the background color can be obtained in XCTest UI Testing, I am looking to compare the background color with the set value, so that i don't have to rely on image comparison XCTest is for functional testing, rather than asserting visual requirements. To test requirements such as background color, use a unit test to initialize the view controller in question and check the view's background color there. You don't need to rely on image comparison, and unit tests are a lot faster. 来源: https://stackoverflow.com/questions/38667435/in-xctest-ui-testing-how-to-check-the

XCTestCase: Wait for app to idle

假装没事ソ 提交于 2019-12-03 00:46:24
My UI-test fails because the test waits endless until the app idles. I can not see that there is anything happening in the background, like a loading spinner. It just occurs on one tab. All others tabs are tapable but the test fails on Screen 3. I I click on another tab after the test is caught on Screen 3 the test resumes and finishes successfully. Any ideas? - (void)testExample { XCUIElementQuery* tabBarsQuery = self.app.tabBars; [tabBarsQuery.buttons[@"Screen2"] tap]; [tabBarsQuery.buttons[@"Screen3"] tap]; [tabBarsQuery.buttons[@"Screen1"] tap]; [tabBarsQuery.buttons[@"Screen4"] tap]; }