Saya di UI Menguji salah satu layar proyek saya. Saya memiliki tampilan tabel salah satu selnya berisi satu dan dua sakelar. Saya dapat mengakses sakelar (elemen) sel pertama dengan mudah dengan

         let tablesQuery = app.tables
         let switchPrivateStream     =   tablesQuery.switches["Make Private Stream"]
         switchPrivateStream.tap()

just like this

Tetapi saya tidak dapat menemukan cara untuk mengakses sisa dua sakelar (elemen) berikutnya yang ada di sel samping.

Tolong beri tahu saya apa yang saya lakukan salah di sini?

Deskripsi debug layar ini adalah sebagai Berikut (mungkin bisa membantu)

"Attributes: Application, 0x1c0380410, pid: 11294, {{0.0, 0.0}, {320.0, 568.0}}, label: \'DummyProject\'\nElement subtree:\n →Application, 0x1c0380410, pid: 11294, {{0.0, 0.0}, {320.0, 568.0}}, label: \'DummyProject\'\n Window, 0x1c03800d0, Main Window, {{0.0, 0.0}, {320.0, 568.0}}\n Other, 0x1c0380270, {{0.0, 0.0}, {320.0, 2.5}}\n Other, 0x1c03804e0, traits: 8589934592, {{0.0, 0.0}, {320.0, 568.0}}\n NavigationBar, 0x1c0380680, traits: 35192962023424, {{0.0, 20.0}, {320.0, 44.0}}, identifier: \'Create a Stream\'\n Button, 0x1c03805b0, traits: 8589934593, {{8.0, 20.0}, {27.0, 44.0}}, label: \'back icon\'\n Other, 0x1c0380820, traits: 8590000128, {{86.5, 30.0}, {147.5, 24.0}}, label: \'Create a Stream\'\n Other, 0x1c0380750, traits: 8589934592, {{0.0, 0.0}, {320.0, 568.0}}\n Other, 0x1c03808f0, traits: 8589934592, {{0.0, 0.0}, {320.0, 568.0}}\n Table, 0x1c0380a90, traits: 35192962023424, {{0.0, 64.0}, {320.0, 504.0}}\n Cell, 0x1c0380b60, traits: 8589934592, {{0.0, 64.0}, {320.0, 153.0}}\n Button, 0x1c0380c30, traits: 8589934593, {{276.0, 75.0}, {33.0, 33.0}}, label: \'camera icon cover images\'\n TextField, 0x1c0380d00, traits: 146029150208, {{10.0, 164.0}, {300.0, 50.0}}, placeholderValue: \'Stream Name\'\n Image, 0x1c0380dd0, traits: 8589934596, {{0.0, 64.0}, {320.0, 153.0}}, identifier: \'add-stream-cover-image-placeholder\'\n Other, 0x1c0380ea0, traits: 8589934592, {{15.0, 216.5}, {305.0, 0.5}}\n Cell, 0x1c419e850, traits: 8589934592, {{0.0, 217.0}, {320.0, 170.0}}\n TextView, 0x1c43804e0, traits: 140746078552064, {{10.0, 261.0}, {300.0, 98.0}}\n StaticText, 0x1c4380680, traits: 8589934656, {{10.0, 242.0}, {300.0, 17.0}}, label: \'Stream Caption\'\n Other, 0x1c43805b0, traits: 8589934592, {{15.0, 386.5}, {305.0, 0.5}}\n Cell, 0x1c4380750, traits: 8589934592, {{0.0, 387.0}, {320.0, 60.0}}\n Switch, 0x1c4380820, traits: 9007207844675585, {{263.0, 401.5}, {49.0, 31.0}}, label: \'Make Private Stream\', value: 0\n StaticText, 0x1c43808f0, traits: 8589934656, {{10.0, 408.5}, {138.0, 17.0}}, label: \'Make Private Stream\'\n Other, 0x1c43809c0, traits: 8589934592, {{15.0, 446.5}, {305.0, 0.5}}\n Cell, 0x1c4380a90, traits: 8589934592, {{0.0, 447.0}, {320.0, 80.0}}\n Switch, 0x1c4380b60, traits: 9007207844675585, {{263.0, 449.0}, {49.0, 31.0}}, label: \'Add Collaborators, Any one can edit\', value: 0\n Switch, 0x1c4380c30, traits: 9007207844675585, {{263.0, 494.0}, {49.0, 31.0}}, label: \'Add Collaborators, Any one can edit\', value: 0\n StaticText, 0x1c4380d00, traits: 8589934656, {{10.0, 456.0}, {138.0, 17.0}}, label: \'Add Collaborators\'\n StaticText, 0x1c4380dd0, traits: 8589934656, {{10.0, 501.0}, {138.0, 17.0}}, label: \'Any one can edit\'\n Other, 0x1c4380ea0, traits: 8589934592, {{10.0, 487.0}, {300.0, 0.0}}\n Other, 0x1c4380f70, traits: 8589934592, {{10.0, 487.0}, {300.0, 0.0}}\n CollectionView, 0x1c4381040, traits: 35192962023424, {{24.0, 487.0}, {273.0, 0.0}}\n Image, 0x1c0380f70, traits: 8589934596, {{291.5, 448.0}, {2.5, 36.0}}\n Image, 0x1c0381040, traits: 8589934596, {{26.5, 481.5}, {265.0, 2.5}}\n Other, 0x1c0381110, traits: 8589934592, {{15.0, 526.5}, {305.0, 0.5}}\n Cell, 0x1c03811e0, traits: 8589934592, {{0.0, 527.0}, {320.0, 80.0}}\n Switch, 0x1c03812b0, traits: 9007207844675585, {{104.5, 561.5}, {49.0, 31.0}}, label: \'Collaborators can, Add Content, Add People\', value: 0\n Switch, 0x1c0381380, traits: 9007207844675585, {{263.0, 561.5}, {49.0, 31.0}}, label: \'Collaborators can, Add Content, Add People\', value: 0\n StaticText, 0x1c0381450, traits: 8589934656, {{10.0, 536.0}, {84.0, 17.0}}, label: \'Collaborators can\'\n StaticText, 0x1c0381520, traits: 8589934656, {{10.0, 568.5}, {88.0, 17.0}}, label: \'Add Content\'\n StaticText, 0x1c03815f0, traits: 8589934656, {{167.0, 568.5}, {88.0, 17.0}}, label: \'Add People\'\n Other, 0x1c03816c0, traits: 8589934592, {{15.0, 606.5}, {305.0, 0.5}}\n Cell, 0x1c0381790, traits: 8589934592, {{0.0, 607.0}, {320.0, 80.0}}\n Other, 0x1c0381860, traits: 8589934592, {{0.0, 64.0}, {305.0, 0.5}}\n Button, 0x1c0381930, traits: 8589934593, {{0.0, 64.0}, {137.0, 45.0}}, label: \'done button\'\n Window, 0x1c0381a00, {{0.0, 0.0}, {320.0, 568.0}}\n Other, 0x1c0381ad0, traits: 8589934592, {{0.0, 0.0}, {320.0, 568.0}}\n Window, 0x1c0381ba0, {{0.0, 0.0}, {320.0, 568.0}}\n StatusBar, 0x1c0381c70, {{0.0, 0.0}, {320.0, 20.0}}\n Other, 0x1c0381d40, {{0.0, 0.0}, {320.0, 20.0}}\n Other, 0x1c0381e10, {{0.0, 0.0}, {320.0, 20.0}}\n Other, 0x1c0381ee0, traits: 8388608, {{6.0, 0.0}, {41.0, 20.0}}, label: \'No SIM\'\n Other, 0x1c0381fb0, traits: 8388608, {{52.0, 0.0}, {15.0, 20.0}}, label: \'3 of 3 Wi-Fi bars\', value: SSID\n Other, 0x1c0382080, traits: 8389120, {{138.0, 0.0}, {49.0, 20.0}}, label: \'7:49 PM\'\n Other, 0x1c0382150, traits: 8388608, {{280.0, 0.0}, {35.0, 20.0}}, label: \'100% battery power, Charging\'\nPath to element:\n →Application, 0x1c0380410, pid: 11294, {{0.0, 0.0}, {320.0, 568.0}}, label: \'DummyProject\'\nQuery chain:\n →Find: Target Application 0x1c02a1c80\n Output: {\n Application, 0x1c0380410, pid: 11294, {{0.0, 0.0}, {320.0, 568.0}}, label: \'DummyProject\'\n }\n"

-1
iNoob 11 Desember 2017, 17:23

1 menjawab

Jawaban Terbaik

Saya menemukan solusi untuk ini yang hanya perlu saya lakukan hanyalah menyetel Accessibility Identifier di storyboard untuk tampilan tertentu dalam kasus saya UISwitch.

Adding Accessibility Identifier in storyboard

Sekarang dengan ini saya dapat mengetahui Switch XCUIElement saya sebagai berikut:

     let tablesQuery   = app.tables
     let switch101     =   tablesQuery.switches["Switch101"]
     switch101.tap()
0
iNoob 12 Desember 2017, 06:50