import XCTest final class ReaderAnnotationTests: XCTestCase { private let app = XCUIApplication() override func setUpWithError() throws { continueAfterFailure = false } func testSelectionMenuCreatesHighlight() { app.launchAndOpenSampleBook(pageNumber: 2) app.waitForReader() let content = app.textViews[IDs.readerSelectionText].firstMatch XCTAssertTrue(content.waitForExistence(timeout: 5), "阅读内容区域未出现") let start = content.coordinate(withNormalizedOffset: CGVector(dx: 0.35, dy: 0.42)) let end = content.coordinate(withNormalizedOffset: CGVector(dx: 0.68, dy: 0.42)) start.press(forDuration: 0.6, thenDragTo: end) app.waitForReaderState(containing: "selection=1", timeout: 5) let highlightMenuItem = app.menuItems["高亮"] let highlightButton = app.buttons["高亮"] let highlightActionButton = app.buttons[IDs.readerSelectionHighlight] if highlightMenuItem.waitForExistence(timeout: 3) { highlightMenuItem.tap() } else if highlightActionButton.waitForExistence(timeout: 3) { highlightActionButton.tap() } else { XCTAssertTrue(highlightButton.waitForExistence(timeout: 3), "选中文本后未出现高亮菜单") highlightButton.tap() } app.waitForReaderState(containing: "highlights=1", timeout: 8) } }