diff --git a/SwiftRadio.xcodeproj/project.pbxproj b/SwiftRadio.xcodeproj/project.pbxproj index deaf516..454b960 100644 --- a/SwiftRadio.xcodeproj/project.pbxproj +++ b/SwiftRadio.xcodeproj/project.pbxproj @@ -69,7 +69,6 @@ CF72ACE721F7155200461EED /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CF72ACE621F714D000461EED /* Main.storyboard */; }; DAEBB1E525161E5B0065ECF0 /* MainPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAEBB1E425161E5B0065ECF0 /* MainPage.swift */; }; DAEBB1E825161EE50065ECF0 /* CommonTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAEBB1E725161EE50065ECF0 /* CommonTest.swift */; }; - DAEBB1EA25161F7F0065ECF0 /* CommonPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAEBB1E925161F7F0065ECF0 /* CommonPage.swift */; }; DAEBB1EC251621B50065ECF0 /* StationDetailsPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAEBB1EB251621B50065ECF0 /* StationDetailsPage.swift */; }; DAEBB1EE251622BF0065ECF0 /* StationInfoPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAEBB1ED251622BF0065ECF0 /* StationInfoPage.swift */; }; DAEBB1F0251623960065ECF0 /* RadioInfoPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAEBB1EF251623960065ECF0 /* RadioInfoPage.swift */; }; @@ -160,7 +159,6 @@ CF72ACE621F714D000461EED /* Main.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; DAEBB1E425161E5B0065ECF0 /* MainPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainPage.swift; sourceTree = ""; }; DAEBB1E725161EE50065ECF0 /* CommonTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonTest.swift; sourceTree = ""; }; - DAEBB1E925161F7F0065ECF0 /* CommonPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonPage.swift; sourceTree = ""; }; DAEBB1EB251621B50065ECF0 /* StationDetailsPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StationDetailsPage.swift; sourceTree = ""; }; DAEBB1ED251622BF0065ECF0 /* StationInfoPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StationInfoPage.swift; sourceTree = ""; }; DAEBB1EF251623960065ECF0 /* RadioInfoPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioInfoPage.swift; sourceTree = ""; }; @@ -387,7 +385,6 @@ DAEBB1F1251627690065ECF0 /* AppInfoPage.swift */, DAEBB1EF251623960065ECF0 /* RadioInfoPage.swift */, DAEBB1EB251621B50065ECF0 /* StationDetailsPage.swift */, - DAEBB1E925161F7F0065ECF0 /* CommonPage.swift */, DAEBB1ED251622BF0065ECF0 /* StationInfoPage.swift */, B05F1B1A2CC79582007D10D5 /* BaseScreenProtocol.swift */, ); @@ -542,7 +539,6 @@ DAEBB2082517521D0065ECF0 /* RadioInfoTest.swift in Sources */, DAEBB1F0251623960065ECF0 /* RadioInfoPage.swift in Sources */, B05F1B202CC79893007D10D5 /* XCTest+Allure.swift in Sources */, - DAEBB1EA25161F7F0065ECF0 /* CommonPage.swift in Sources */, DAEBB1FE251633AB0065ECF0 /* SmokeTest.swift in Sources */, B05F1B262CC79929007D10D5 /* XCUIElement+Waiting.swift in Sources */, B05F1B1B2CC79582007D10D5 /* BaseScreenProtocol.swift in Sources */, diff --git a/SwiftRadio.xcodeproj/project.xcworkspace/xcuserdata/lysikovboris.xcuserdatad/UserInterfaceState.xcuserstate b/SwiftRadio.xcodeproj/project.xcworkspace/xcuserdata/lysikovboris.xcuserdatad/UserInterfaceState.xcuserstate index 6c81002..e49001f 100644 Binary files a/SwiftRadio.xcodeproj/project.xcworkspace/xcuserdata/lysikovboris.xcuserdatad/UserInterfaceState.xcuserstate and b/SwiftRadio.xcodeproj/project.xcworkspace/xcuserdata/lysikovboris.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/SwiftRadioUITests/Extensions/XCUIElement+Actions.swift b/SwiftRadioUITests/Extensions/XCUIElement+Actions.swift index 77ca547..c23276d 100644 --- a/SwiftRadioUITests/Extensions/XCUIElement+Actions.swift +++ b/SwiftRadioUITests/Extensions/XCUIElement+Actions.swift @@ -38,13 +38,13 @@ extension XCUIElement { } } - func clearText() -> Self { + func clearText() { guard let stringValue = value as? String else { - return self + return } // workaround for apple bug guard placeholderValue != stringValue else { - return self + return } var deleteString = [String]() @@ -52,8 +52,7 @@ extension XCUIElement { deleteString.append(XCUIKeyboardKey.delete.rawValue) } typeText(deleteString.joined()) - - return self + } func tapElement( @@ -163,22 +162,5 @@ extension XCUIElement { left.press(forDuration: 1, thenDragTo: right) } - - enum SwipeMiniPlayerDirection { - case left - case right - } - - func swipeMiniPlayer(direction: SwipeMiniPlayerDirection) { - let app = XCUIApplication() - let left = app.coordinate(withNormalizedOffset: CGVector(dx: 0.1, dy: 0.88)) - let right = app.coordinate(withNormalizedOffset: CGVector(dx: 0.75, dy: 0.88)) - - switch direction { - case .left: - right.press(forDuration: 0, thenDragTo: left) - case .right: - left.press(forDuration: 0, thenDragTo: right) - } - } + } diff --git a/SwiftRadioUITests/Page/CommonPage.swift b/SwiftRadioUITests/Page/CommonPage.swift deleted file mode 100644 index d937d25..0000000 --- a/SwiftRadioUITests/Page/CommonPage.swift +++ /dev/null @@ -1,60 +0,0 @@ -// -// CommonPage.swift -// SwiftRadioUITests -// -// Created by Борис Лысиков on 19.09.2020. -// Copyright © 2020 matthewfecher.com. All rights reserved. -// - -import XCTest - -class CommonPage { - - // MARK: - UI elements and variables - - let app = XCUIApplication() - let safari = XCUIApplication(bundleIdentifier: "com.apple.mobilesafari") - - private lazy var backButton: XCUIElement = { - app.navigationBars.children(matching: .button).firstMatch - }() - - private lazy var URL: XCUIElement = { - app.buttons["URL"] - }() - - private lazy var nameOfMainPageNavbarTitle: XCUIElement = { - app.navigationBars.otherElements[nameOfMainPageNavbarText] - }() - - private let nameOfMainPageNavbarText = "Swift Radio" - - // MARK: - Actions - -// @discardableResult -// func tapOnBackButton() -> Self { -// backButton.tapElement() -// return self -// } - - // MARK: - Verification - -// @discardableResult -// func checkLabelInBackButton(text: String) -> Self { -// backButton.checkLabelEqualToString(text) -// return self -// } -// -// @discardableResult -// func checkNavbarTitleOnMainPage() -> Self { -// nameOfMainPageNavbarTitle.checkLabelEqualToString(nameOfMainPageNavbarText) -// return self -// } - -// @discardableResult -// func checkMainDomain(domain: String) -> Self { -// XCTAssertTrue((URL.firstMatch.value as! String).contains(domain), "\(domain) not found") -// return self -// } - -} diff --git a/SwiftRadioUITests/Page/MainPage.swift b/SwiftRadioUITests/Page/MainPage.swift index 5c486f1..c2877e2 100644 --- a/SwiftRadioUITests/Page/MainPage.swift +++ b/SwiftRadioUITests/Page/MainPage.swift @@ -22,7 +22,11 @@ struct MainPage: BaseScreen, NavigationBar { app.cells.matching(identifier: stationCell).element(boundBy: index).staticTexts["stationName"].firstMatch.label } - static func getStationDescription(index: Int) -> String { + static func getStationDescription(index: Int) -> XCUIElement { + app.cells.matching(identifier: stationCell).element(boundBy: index).staticTexts["stationDesc"].firstMatch + } + + static func getStationDescriptionName(index: Int) -> String { app.cells.matching(identifier: stationCell).element(boundBy: index).staticTexts["stationDesc"].firstMatch.label } diff --git a/SwiftRadioUITests/Page/StationInfoPage.swift b/SwiftRadioUITests/Page/StationInfoPage.swift index 848b532..6523f2c 100644 --- a/SwiftRadioUITests/Page/StationInfoPage.swift +++ b/SwiftRadioUITests/Page/StationInfoPage.swift @@ -8,50 +8,15 @@ import XCTest -struct StationInfoPage: BaseScreen { +struct StationInfoPage: BaseScreen, NavigationBar { static let stationImage = app.images["stationImage"] static let stationNameLabel = app.staticTexts["stationNameLabel"] static let okayButton = app.buttons["okayButton"] static let stationDeskLabel = app.staticTexts["stationDeskLabel"] static let stationTextView = app.textViews["stationTextView"] - - // MARK: - UI elements and variables - + private let stationDescDescription = "The Music Starts Here" private let textViewDescription = "All your favorite country hits and artists, from Johnny Cash to Taylor Swift, on 1.FM's Absolute Country, playing non-stop crooners and banjos, dance-tunes and fiddles, ballads and harmonicas. Absolute Country focuses on 5th, 6th and 7th generation Country (from the 90s on) but often delves into classic, older tunes as well." - // MARK: - Actions -// -// @discardableResult -// func tapOnOkay() -> Self { -// okayButton.tapElement() -// return self -// } -// -// // MARK: - Verification -// -// @discardableResult -// func checkTextInNavbarButton(stationName: String) -> Self { -// return self -// } -// -// @discardableResult -// func checkStationImage() -> Self { -// stationImage.checkExistence(true) -// return self -// } -// -// @discardableResult -// func checkStationNameLabel(stationName: String) -> Self { -// stationNameLabel.checkLabelEqualToString(stationName) -// return self -// } -// -// @discardableResult -// func checkStationDeskLabel() -> Self { -// stationDeskLabel.checkLabelEqualToString(stationDescDescription) -// return self -// } - } diff --git a/SwiftRadioUITests/Tests/AppInfoTest.swift b/SwiftRadioUITests/Tests/AppInfoTest.swift index 754d822..b71177a 100644 --- a/SwiftRadioUITests/Tests/AppInfoTest.swift +++ b/SwiftRadioUITests/Tests/AppInfoTest.swift @@ -33,51 +33,5 @@ final class AppInfoTest: CommonTest { } } } - -// /* -// Проверка перехода в экран о радио через текущий экран по нажатию на кнопку "About и перехода обратно" -// */ - func testOpenAboutFromAppInfo() { - let nameOfAppText = "Radio App" - - step("Нажать на кнопку инфо") { - MainPage.navigationBarBackButton.tapElement() - } - step("Нажать на кнопку About") { - AppInfoPage.aboutButton.tapElement() - - step("Проверить имя приложения") { - RadioInfoPage.nameOfAppLabel.verifyLabel(equal: nameOfAppText) - } -// step("") { -// <#code#> -// } - } - - - -// mainPage -// .tapOnInfoButton() -// appInfoPage -// .openAbout() -// radioInfoPage -// .checkNameOfApp() -// .tapOnOkay() -// appInfoPage -// .checkAuthors() - } -// -// /* -// Проверка корректного закрытия текущего экрана -// */ -// func testCloseAboutAppPage() { -// mainPage -// .tapOnInfoButton() -// -// AppInfoPage.closeButton.tapElement() -// -// mainPage -// .checkNavbarTitleOnMainPage() -// } } diff --git a/SwiftRadioUITests/Tests/SmokeTest.swift b/SwiftRadioUITests/Tests/SmokeTest.swift index 7bf900d..8009941 100644 --- a/SwiftRadioUITests/Tests/SmokeTest.swift +++ b/SwiftRadioUITests/Tests/SmokeTest.swift @@ -45,17 +45,20 @@ final class SmokeTest: CommonTest { MainPage.playbutton.verifyLabelContain(contain: nameOfStation) } } -// -// /* -// Проверка отображения всех элементов в ячейке -// */ -// func testElementExistOnScreen() { -// mainPage -// .checkStationName(indexOfStation: 0, stationName: "Absolute Country Hits") -// .checkStationDesc(indexOfStation: 0, stationDesk: "The Music Starts Here") -// .checkStationImage(indexOfStation: 0) -// } -// + + /* + Проверка отображения всех элементов в ячейке + */ + func testElementExistOnScreen() { + step("Проверить отображение станции") { + MainPage.getStation(index: 0).verifyLabel(equal: "Absolute Country Hits") + } + step("Проерить отображение песни") { + MainPage.getStationDescription(index: 0).verifyLabel(equal: "The Music Starts Here") + } + } + + // /* // Проверка статуса - пауза для трека с радио // */ diff --git a/SwiftRadioUITests/Tests/StationInfoTest.swift b/SwiftRadioUITests/Tests/StationInfoTest.swift index f016563..e7e0272 100644 --- a/SwiftRadioUITests/Tests/StationInfoTest.swift +++ b/SwiftRadioUITests/Tests/StationInfoTest.swift @@ -11,25 +11,43 @@ final class StationInfoTest: CommonTest { /* Проверка отображение элементов на экране с информацией о станции, также корректную работу переходов по нажатию на кнопку назад(в Navigation bar) и ок на самом экране */ -// func testOpenStationDetailsByTapOnNowPlayingButton() { -// let nameOfStation = mainPage.getStationName(indexOfStation: 0) -// mainPage -// .tapOnStation(index: 0) -// stationDetailsPage -// .tapOnInfoButton() -// stationInfoPage -// .checkStationNameLabel(stationName: nameOfStation) -// .checkStationImage() -// .checkStationDeskLabel() -// .checkLabelInBackButton(text: nameOfStation) -// .tapOnOkay() -// stationDetailsPage -// .checkNavbarTitle(stationName: nameOfStation) -// .tapOnInfoButton() -// stationInfoPage -// .tapOnBackButton() -// stationDetailsPage -// .checkNavbarTitle(stationName: nameOfStation) -// } + func testOpenStationDetailsByTapOnNowPlayingButton() { + let stationName = MainPage.getStationName(index: 0) + + step("Открыть первую станцию") { + MainPage.getStation(index: 0).tapElement() + } + step("Нажать на инфо кнопку") { + StationDetailsPage.infoButton.tapElement() + + step("Проверить отображение названия") { + StationInfoPage.stationNameLabel.verifyLabel(equal: stationName) + + } + step("Проверить отображение картинки") { + StationInfoPage.stationImage.verifyElement() + } + step("Проверить отображение текста") { + StationInfoPage.stationDeskLabel.verifyElement() + } + } + step("Нажать кнопку ОК") { + StationInfoPage.okayButton.tapElement() + + step("Проверить название в Navigation bar") { + StationDetailsPage.navigationBarTitle.verifyLabel(equal: stationName) + } + } + step("Нажать на инфо кнопку") { + StationDetailsPage.infoButton.tapElement() + } + step("Нажать кнопку назад") { + StationInfoPage.navigationBarBackButton.tapElement() + } + step("Проверить название в Navigation bar") { + StationDetailsPage.navigationBarTitle.verifyLabel(equal: stationName) + } + + } }