0
 func testExample() {
        XCUIApplication()/*@START_MENU_TOKEN@*/.otherElements.matching(identifier: " Menu  Add 10 e-books for mastering DIY electronics with Arduino UK Information Commissioner's Office raids Cambridge Analytica's London office Your passports are full of tech Cambridge Analytica became a US powerhouse thanks Mercer's laundered money and a judas goat named John Bolton These modern-day 1920s' style swimsuits are for any body NASA's got a computer model for predicting landslides You can have a giant lollipop made of your face People who make their own mechanical watches Egypt’s Election Should Be a Lock. So Why Is President Sisi Worried? French Police Officer Wounded in Hostage Standoff Dies Polish Women Protest Proposed Abortion Ban (Again) At Swedish Preschool, Boys Learn to Dance and Girls Learn to Yell North and South Korea to Hold Preparatory Talks for Summit Meeting ‘The Whole World Should Be Concerned’: U.S. Allies React to Bolton’s Appointment Uber's autonomous vehicles require frequent human intervention A tour of the manipulative, creepy bullshit Facebook pulls to stop you deleting your account Trump Just Pushed the World Trade Organization Toward Irrelevance Misreading Trump: Ally Japan Is Spurned on Tariff Exemptions 150 Whales Beached in Australia, as Rescuers Fight to Save Them Responding to Trump, China Plans New Tariffs on U.S. Goods Spectre and Meltdown: CPU bugs put a scare in the air From Capistrano to Kubernetes: Lessons from PhraseApp's transition 9 code and framework trends to watch in 2018 6 reasons to co-locate your app and automation code 5 IT Ops management trends to watch in 2018 GDPR wakeup call: 3 ways dev teams can build in privacy like security 6 levels of AI-based testing: Have no fear, QA pros How to map your DevOps journey Best of TechBeacon 2017: Quality comes first The best agile and lean development conferences of 2018 Dropbox IPOs. Its Founders Are Now Billionaires Uber's Self-Driving Cars Were Struggling Before Arizona Crash British Scientists Develop Wearable MRI Scanner One Startup is Using Phone Calls and Other Inexpensive Means To Save TB Patients Britain's Plan To Build a 2,000 Foot Aircraft Carrier Almost Entirely From Ice New York Councilman Proposes Bill That Would Grant NYC Workers 'Right To Disconnect' Spotify Says 2 Million Users Hacked Apps To Suppress Ads On Its Free Service Apple To Unveil a Cheaper iPad Next Week At Its Educational Event Facebook Gets Hit With Four Lawsuits Over Cambridge Analytica Scandal School Pays To Get an Algorithm To Scan Students' Social Media For Threats and Suicide Risks Posts  Previous Next ").staticTexts["Menu"]/*[[".otherElements[\"RssList\"]",".otherElements[\"rss_list_populated\"]",".scrollViews.otherElements[\" Menu  Add 10 e-books for mastering DIY electronics with Arduino UK Information Commissioner's Office raids Cambridge Analytica's London office Your passports are full of tech Cambridge Analytica became a US powerhouse thanks Mercer's laundered money and a judas goat named John Bolton These modern-day 1920s' style swimsuits are for any body NASA's got a computer model for predicting landslides You can have a giant lollipop made of your face People who make their own mechanical watches Egypt’s Election Should Be a Lock. So Why Is President Sisi Worried? French Police Officer Wounded in Hostage Standoff Dies Polish Women Protest Proposed Abortion Ban (Again) At Swedish Preschool, Boys Learn to Dance and Girls Learn to Yell North and South Korea to Hold Preparatory Talks for Summit Meeting ‘The Whole World Should Be Concerned’: U.S. Allies React to Bolton’s Appointment Uber's autonomous vehicles require frequent human intervention A tour of the manipulative, creepy bullshit Facebook pulls to stop you deleting your account Trump Just Pushed the World Trade Organization Toward Irrelevance Misreading Trump: Ally Japan Is Spurned on Tariff Exemptions 150 Whales Beached in Australia, as Rescuers Fight to Save Them Responding to Trump, China Plans New Tariffs on U.S. Goods Spectre and Meltdown: CPU bugs put a scare in the air From Capistrano to Kubernetes: Lessons from PhraseApp's transition 9 code and framework trends to watch in 2018 6 reasons to co-locate your app and automation code 5 IT Ops management trends to watch in 2018 GDPR wakeup call: 3 ways dev teams can build in privacy like security 6 levels of AI-based testing: Have no fear, QA pros How to map your DevOps journey Best of TechBeacon 2017: Quality comes first The best agile and lean development conferences of 2018 Dropbox IPOs. Its Founders Are Now Billionaires Uber's Self-Driving Cars Were Struggling Before Arizona Crash British Scientists Develop Wearable MRI Scanner One Startup is Using Phone Calls and Other Inexpensive Means To Save TB Patients Britain's Plan To Build a 2,000 Foot Aircraft Carrier Almost Entirely From Ice New York Councilman Proposes Bill That Would Grant NYC Workers 'Right To Disconnect' Spotify Says 2 Million Users Hacked Apps To Suppress Ads On Its Free Service Apple To Unveil a Cheaper iPad Next Week At Its Educational Event Facebook Gets Hit With Four Lawsuits Over Cambridge Analytica Scandal School Pays To Get an Algorithm To Scan Students' Social Media For Threats and Suicide Risks Posts  Previous Next \"]",".otherElements.matching(identifier: \" Menu  Add\")",".otherElements[\"main_header\"]",".otherElements[\" Menu\"].staticTexts[\"Menu\"]",".staticTexts[\"Menu\"]",".otherElements.matching(identifier: \" Menu  Add 10 e-books for mastering DIY electronics with Arduino UK Information Commissioner's Office raids Cambridge Analytica's London office Your passports are full of tech Cambridge Analytica became a US powerhouse thanks Mercer's laundered money and a judas goat named John Bolton These modern-day 1920s' style swimsuits are for any body NASA's got a computer model for predicting landslides You can have a giant lollipop made of your face People who make their own mechanical watches Egypt’s Election Should Be a Lock. So Why Is President Sisi Worried? French Police Officer Wounded in Hostage Standoff Dies Polish Women Protest Proposed Abortion Ban (Again) At Swedish Preschool, Boys Learn to Dance and Girls Learn to Yell North and South Korea to Hold Preparatory Talks for Summit Meeting ‘The Whole World Should Be Concerned’: U.S. Allies React to Bolton’s Appointment Uber's autonomous vehicles require frequent human intervention A tour of the manipulative, creepy bullshit Facebook pulls to stop you deleting your account Trump Just Pushed the World Trade Organization Toward Irrelevance Misreading Trump: Ally Japan Is Spurned on Tariff Exemptions 150 Whales Beached in Australia, as Rescuers Fight to Save Them Responding to Trump, China Plans New Tariffs on U.S. Goods Spectre and Meltdown: CPU bugs put a scare in the air From Capistrano to Kubernetes: Lessons from PhraseApp's transition 9 code and framework trends to watch in 2018 6 reasons to co-locate your app and automation code 5 IT Ops management trends to watch in 2018 GDPR wakeup call: 3 ways dev teams can build in privacy like security 6 levels of AI-based testing: Have no fear, QA pros How to map your DevOps journey Best of TechBeacon 2017: Quality comes first The best agile and lean development conferences of 2018 Dropbox IPOs. Its Founders Are Now Billionaires Uber's Self-Driving Cars Were Struggling Before Arizona Crash British Scientists Develop Wearable MRI Scanner One Startup is Using Phone Calls and Other Inexpensive Means To Save TB Patients Britain's Plan To Build a 2,000 Foot Aircraft Carrier Almost Entirely From Ice New York Councilman Proposes Bill That Would Grant NYC Workers 'Right To Disconnect' Spotify Says 2 Million Users Hacked Apps To Suppress Ads On Its Free Service Apple To Unveil a Cheaper iPad Next Week At Its Educational Event Facebook Gets Hit With Four Lawsuits Over Cambridge Analytica Scandal School Pays To Get an Algorithm To Scan Students' Social Media For Threats and Suicide Risks Posts  Previous Next \")"],[[[-1,7,3],[-1,2,3],[-1,1,2],[-1,0,1]],[[-1,7,3],[-1,2,3],[-1,1,2]],[[-1,7,3],[-1,2,3]],[[-1,6],[-1,5],[-1,4,5],[-1,3,4]],[[-1,6],[-1,5],[-1,4,5]],[[-1,6],[-1,5]]],[0,0]]@END_MENU_TOKEN@*/.tap()

        // Use recording to get started writing UI tests.
        // Use XCTAssert and related functions to verify your tests produce the correct results.
    }

此处的标识符包含来自各种 RSS 提要的文本,这些提要在我每次运行测试时都会更改。

我如何能:

  1. 从 otherElements 或其他条件中按索引选择
  2. 等待那个元素。
4

1 回答 1

0

答案是这样的:

  func testClicksOnMenu() {
    let app = XCUIApplication();
    let containsMenu = NSPredicate(format: "label contains[c] %@", "Menu");
    let other = app.otherElements.containing(containsMenu).staticTexts["Menu"];
    let exists = other.waitForExistence(timeout: 10);
    XCTAssertTrue(exists, "Expected Menu to Exist");
    other.tap();
  }

基本上你只需要一个其他元素的匹配器,它实际上返回11个匹配名称包含菜单的元素,但是对于静态文本的菜单只有一个accessibilityId。测试也运行得相当快速和稳定。

于 2018-03-25T12:04:09.917 回答