iOS
यूआई परीक्षण
खोज…
वाक्य - विन्यास
- XCUIApplication () // एक आवेदन के लिए प्रॉक्सी। एप्लिकेशन की पहचान करने वाली जानकारी Xcode लक्ष्य सेटिंग्स में "लक्ष्य एप्लिकेशन" के रूप में निर्दिष्ट है।
- XCUIElement () // एक अनुप्रयोग में एक उपयोगकर्ता इंटरफ़ेस तत्व।
Xcode प्रोजेक्ट में टेस्ट फाइल्स जोड़ना
प्रोजेक्ट बनाते समय
आपको प्रोजेक्ट निर्माण संवाद में "यूआई टेस्ट शामिल करें" की जांच करनी चाहिए।
प्रोजेक्ट बनाने के बाद
यदि आप प्रोजेक्ट बनाते समय UI target जाँच करने से चूक गए हैं, तो आप हमेशा बाद में परीक्षण लक्ष्य जोड़ सकते हैं।
setps:
- प्रोजेक्ट ओपन होने पर
File->New->Target -
iOS UI Testing Bundleढूंढें
अभिगम्यता पहचानकर्ता
जब यूटिलिटी में एक्सेसबिलिटी सक्षम हो
-
storyboardचयन करें। -
the Utilitiesविस्तार करें -
Identity Inspectorचयन करें - स्टोरीबोर्ड पर अपने तत्व का चयन करें
- नई पहुंच पहचानकर्ता जोड़ें (उदाहरण के लिए
addButton)
जब यूटिलिटीज में एक्सेसिबिलिटी अक्षम हो गई
-
storyboardचयन करें। -
the Utilitiesविस्तार करें -
Identity Inspectorचयन करें - स्टोरीबोर्ड पर अपने तत्व का चयन करें
-
User Defined Runtime Attributesविशेषताओं में विशेषता जोड़ें -
Key Pathप्रकार के लिए -accessibilityIdentifier -
Type- `स्ट्रिंग -
Value- आपके तत्व के लिए नई पहुंच पहचानकर्ता (उदाहरण के लिएview)
UITest फ़ाइल में सेट अप करना
import XCTest
class StackOverFlowUITests: XCTestCase {
private let app = XCUIApplication()
//Views
private var view: XCUIElement!
//Buttons
private var addButton: XCUIElement!
override func setUp() {
super.setUp()
app.launch()
//Views
view = app.otherElements["view"]
//Buttons
addButton = app.buttons["addButton"]
}
func testMyApp() {
addButton.tap()
view.tap()
}
}
[ ] तत्व के लिए अभिगम्यता पहचानकर्ता जोड़ें।
UIView, UIImageView, UIScrollView
let imageView = app.images["imageView"]
let scrollView = app.scrollViews["scrollView"]
let view = app.otherElements["view"]
UILabel
let label = app.staticTexts["label"]
UIStackView
let stackView = app.otherElements["stackView"]
UITableView
let tableView = app.tables["tableView"]
UITableViewCell
let tableViewCell = tableView.cells["tableViewCell"]
UITableViewCell तत्व
let tableViewCellButton = tableView.cells.element(boundBy: 0).buttons["button"]
UICollectionView
let collectionView = app.collectionViews["collectionView"]
UIButton, UIBarButtonItem
let button = app.buttons["button"]
let barButtonItem = app.buttons["barButtonItem"]
UITextField
- सामान्य UITextField
let textField = app.textFields["textField"]
- पासवर्ड UITextField
let passwordTextField = app.secureTextFields["passwordTextField"]
UITextView
let textView = app.textViews["textView"]
UISwitch
let switch = app.switches["switch"]
अलर्ट
let alert = app.alerts["About yourself"] // Title of presented alert
UI परीक्षण के दौरान एनिमेशन अक्षम करें
एक परीक्षण में आप setUp में जोड़कर एनिमेशन को निष्क्रिय कर सकते हैं:
app.launchEnvironment = ["animations": "0"]
जहां app XCUIApplication का उदाहरण है।
निष्पादित करते समय दोपहर का भोजन और आवेदन समाप्त करें
परीक्षण के लिए दोपहर का भोजन
override func setUp() {
super.setUp()
let app = XCUIApplication()
app.launch()
}
समापन आवेदन
func testStacOverFlowApp() {
app.terminate()
}
उपकरणों को घुमाएं
XCUIDevice.shared().orientation orientation में orientation बदलकर डिवाइस को घुमाया जा सकता है XCUIDevice.shared().orientation
XCUIDevice.shared().orientation = .landscapeLeft
XCUIDevice.shared().orientation = .portrait
Modified text is an extract of the original Stack Overflow Documentation
के तहत लाइसेंस प्राप्त है CC BY-SA 3.0
से संबद्ध नहीं है Stack Overflow



