Element click taking 16 seconds

Attempting to click an element is consistently taking a very long time, which is slowing down my tests a ton.

  • iPad 2 Simulator
  • iOS 9.3
  • Swift 3.2
  • appium_lib (9.4.4)

Element in question (I know people say not to use xpath but I’m having trouble getting accessibility IDs showing up as expected):

organization = find_element :xpath, '//XCUIElementTypeTable[@name="TypeAheadSearchResults"]/XCUIElementTypeCell/XCUIElementTypeStaticText'

Log printed by me:

Clicking organization #<Selenium::WebDriver::Element:0x..f032f1938fd7b47c id="1092CE78-0E17-4A68-B494-F1C02AB68795">
Start time: 2017-05-18 10:15:48 -0400
End time: 2017-05-18 10:16:04 -0400

Relevant line from appium log:

[HTTP] <-- GET /wd/hub/session/6ec22214-b77a-4269-9de3-cc0fce8ee9f7/source 200 125 ms - 24046
[HTTP] --> POST /wd/hub/session/6ec22214-b77a-4269-9de3-cc0fce8ee9f7/element/1092CE78-0E17-4A68-B494-F1C02AB68795/click {"{}":""}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[debug] [XCUITest] Executing command 'proxyReqRes'
[debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/6ec22214-b77a-4269-9de3-cc0fce8ee9f7/element/1092CE78-0E17-4A68-B494-F1C02AB68795/click] to [POST http://localhost:8100/session/810EFB7F-4E88-4179-93CE-AE8E1C23372A/element/1092CE78-0E17-4A68-B494-F1C02AB68795/click] with body: {"{}":""}
[debug] [JSONWP Proxy] Got response with status 200: {"status":0,"id":"1092CE78-0E17-4A68-B494-F1C02AB68795","sessionId":"810EFB7F-4E88-4179-93CE-AE8E1C23372A","value":""}
[JSONWP Proxy] Replacing sessionId 810EFB7F-4E88-4179-93CE-AE8E1C23372A with 6ec22214-b77a-4269-9de3-cc0fce8ee9f7
[HTTP] <-- POST /wd/hub/session/6ec22214-b77a-4269-9de3-cc0fce8ee9f7/element/1092CE78-0E17-4A68-B494-F1C02AB68795/click 200 16081 ms - 118

The click response took 16081 ms. Any ideas on a workaround? This only happens with this element, which is a label; I don’t have a problem clicking buttons or other labels.

Full page source:

<?xml version="1.0" encoding="UTF-8"?><AppiumAUT><XCUIElementTypeApplication type="XCUIElementTypeApplication" name="Rounding" label="Rounding" enabled="true" x="0" y="0" width="768" height="1024">
  <XCUIElementTypeWindow type="XCUIElementTypeWindow" enabled="true" x="0" y="0" width="768" height="1024">
    <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="768" height="1024">
      <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="0" height="20"/>
      <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="768" height="1024">
        <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="-320" y="0" width="320" height="1024">
          <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="-320" y="0" width="320" height="1024">
            <XCUIElementTypeOther type="XCUIElementTypeOther" name="ProfileSectionStack" enabled="true" x="-320" y="0" width="320" height="154">
              <XCUIElementTypeOther type="XCUIElementTypeOther" name="ProfileSection" enabled="true" x="-320" y="0" width="320" height="154"/>
              <XCUIElementTypeImage type="XCUIElementTypeImage" name="UserImage" enabled="true" x="-310" y="40" width="72" height="72"/>
              <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="[email protected]" name="UserTitle" label="[email protected]" enabled="true" x="-310" y="116" width="300" height="28"/>
            </XCUIElementTypeOther>
            <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="-320" y="0" width="396" height="870"/>
            <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="0" height="20"/>
            <XCUIElementTypeTable type="XCUIElementTypeTable" enabled="true" x="-320" y="154" width="320" height="870"/>
            <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="1024" width="0" height="0"/>
          </XCUIElementTypeOther>
        </XCUIElementTypeOther>
        <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="768" height="1024"/>
        <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="768" height="1024">
          <XCUIElementTypeNavigationBar type="XCUIElementTypeNavigationBar" name="RoundingView.OrganizationSearchView" enabled="true" x="0" y="20" width="768" height="44">
            <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="0" y="0" width="768" height="64">
              <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="0" y="64" width="768" height="1"/>
            </XCUIElementTypeImage>
            <XCUIElementTypeButton type="XCUIElementTypeButton" name="BackButton" label="ic chevron left white" enabled="true" x="9" y="23" width="58" height="36"/>
            <XCUIElementTypeButton type="XCUIElementTypeButton" name="Back" label="Back" enabled="true" x="12" y="32" width="21" height="21"/>
          </XCUIElementTypeNavigationBar>
          <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="768" height="1024">
            <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="768" height="1024">
              <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="64" width="768" height="960">
                <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="64" width="0" height="0"/>
                <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="20" y="64" width="728" height="960">
                  <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="28" y="72" width="712" height="160">
                    <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="28" y="72" width="712" height="160">
                      <XCUIElementTypeOther type="XCUIElementTypeOther" name="CardTitleToolBar" enabled="true" x="28" y="72" width="288" height="53">
                        <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="Where are you rounding today?" name="Where are you rounding today?" label="Where are you rounding today?" enabled="true" x="38" y="82" width="268" height="33"/>
                      </XCUIElementTypeOther>
                      <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="28" y="125" width="0" height="2"/>
                      <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="28" y="127" width="712" height="105">
                        <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="36" y="135" width="696" height="89">
                          <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="36" y="135" width="696" height="69">
                            <XCUIElementTypeTextField type="XCUIElementTypeTextField" value="Choose an organization..." name="OrganizationSearchText" label="" enabled="true" x="46" y="160" width="281" height="34"/>
                            <XCUIElementTypeTextField type="XCUIElementTypeTextField" value="Choose a location..." name="LocationSearchText" label="" enabled="false" x="352" y="160" width="280" height="34"/>
                          </XCUIElementTypeOther>
                        </XCUIElementTypeOther>
                      </XCUIElementTypeOther>
                      <XCUIElementTypeOther type="XCUIElementTypeOther" name="CardBottomToolBar" enabled="true" x="28" y="232" width="0" height="0"/>
                    </XCUIElementTypeOther>
                  </XCUIElementTypeOther>
                  <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="28" y="240" width="712" height="776">
                    <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="28" y="240" width="712" height="776">
                      <XCUIElementTypeOther type="XCUIElementTypeOther" name="CardTitleToolBar" enabled="true" x="28" y="240" width="204" height="53">
                        <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="Select an audit round" name="Select an audit round" label="Select an audit round" enabled="true" x="38" y="250" width="184" height="33"/>
                      </XCUIElementTypeOther>
                      <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="28" y="293" width="0" height="1"/>
                      <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="28" y="294" width="712" height="722">
                        <XCUIElementTypeScrollView type="XCUIElementTypeScrollView" enabled="true" x="36" y="302" width="696" height="706">
                          <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="726" y="263" width="3" height="36"/>
                          <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="36" y="302" width="696" height="116">
                            <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="Device must be connected to the internet to start a round. Please check the Wi-Fi settings on the device." name="Device must be connected to the internet to start a round. Please check the Wi-Fi settings on the device." label="Device must be connected to the internet to start a round. Please check the Wi-Fi settings on the device." enabled="true" x="36" y="322" width="696" height="0"/>
                            <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="36" y="322" width="696" height="76">
                              <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="36" y="322" width="696" height="76">
                                <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="36" y="330" width="696" height="60">
                                  <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="36" y="330" width="696" height="60">
                                    <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="330" width="0" height="0"/>
                                    <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="36" y="330" width="696" height="60">
                                      <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="36" y="330" width="348" height="60">
                                        <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="Mock Audit Round Title" name="Round Name" label="Mock Audit Round Title" enabled="true" x="46" y="340" width="180" height="22"/>
                                        <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="46" y="366" width="0" height="14">
                                          <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="46" y="366" width="0" height="14">
                                            <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" name="Round Description" enabled="true" x="0" y="64" width="0" height="0"/>
                                            <XCUIElementTypeButton type="XCUIElementTypeButton" name="Expand Button" label="See more" enabled="true" x="0" y="64" width="55" height="0">
                                              <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="See more" name="See more" label="See more" enabled="true" x="0" y="55" width="55" height="17"/>
                                            </XCUIElementTypeButton>
                                          </XCUIElementTypeOther>
                                        </XCUIElementTypeOther>
                                      </XCUIElementTypeOther>
                                      <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="374" y="330" width="174" height="60"/>
                                      <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="548" y="330" width="174" height="60">
                                        <XCUIElementTypeButton type="XCUIElementTypeButton" name="Start Round" label="Start" enabled="true" x="642" y="340" width="70" height="38"/>
                                      </XCUIElementTypeOther>
                                    </XCUIElementTypeOther>
                                    <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="390" width="0" height="0"/>
                                  </XCUIElementTypeOther>
                                </XCUIElementTypeOther>
                              </XCUIElementTypeOther>
                            </XCUIElementTypeOther>
                          </XCUIElementTypeOther>
                          <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="-3" y="1002" width="36" height="3"/>
                        </XCUIElementTypeScrollView>
                      </XCUIElementTypeOther>
                      <XCUIElementTypeOther type="XCUIElementTypeOther" name="CardBottomToolBar" enabled="true" x="28" y="1016" width="0" height="0"/>
                    </XCUIElementTypeOther>
                  </XCUIElementTypeOther>
                </XCUIElementTypeOther>
                <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="1024" width="0" height="0"/>
              </XCUIElementTypeOther>
            </XCUIElementTypeOther>
          </XCUIElementTypeOther>
          <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="768" height="20"/>
          <XCUIElementTypeToolbar type="XCUIElementTypeToolbar" enabled="true" x="0" y="1024" width="768" height="44">
            <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="0" y="1023" width="768" height="1"/>
            <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="0" y="1024" width="768" height="44">
              <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="1024" width="768" height="44">
                <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="1024" width="768" height="44"/>
              </XCUIElementTypeOther>
            </XCUIElementTypeImage>
          </XCUIElementTypeToolbar>
        </XCUIElementTypeOther>
        <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="768" height="1024">
          <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="768" height="1024">
            <XCUIElementTypeNavigationBar type="XCUIElementTypeNavigationBar" name="RoundingView.OrganizationSearchView" enabled="true" x="0" y="20" width="768" height="44">
              <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="0" y="0" width="768" height="64">
                <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="0" y="64" width="768" height="1"/>
              </XCUIElementTypeImage>
              <XCUIElementTypeButton type="XCUIElementTypeButton" name="BackButton" label="ic chevron left white" enabled="true" x="9" y="23" width="58" height="36"/>
              <XCUIElementTypeButton type="XCUIElementTypeButton" name="Back" label="Back" enabled="true" x="12" y="32" width="21" height="21"/>
              <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="73" y="20" width="675" height="44">
                <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="73" y="0" width="675" height="64">
                  <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="73" y="0" width="675" height="64"/>
                </XCUIElementTypeImage>
                <XCUIElementTypeSearchField type="XCUIElementTypeSearchField" name="Search for organization..." label="Search for organization..." enabled="true" x="73" y="28" width="675" height="28"/>
              </XCUIElementTypeOther>
            </XCUIElementTypeNavigationBar>
            <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="768" height="1024">
              <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="768" height="1024">
                <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="-230" y="0" width="768" height="1024">
                  <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="-230" y="64" width="768" height="960">
                    <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="-230" y="64" width="0" height="0"/>
                    <XCUIElementTypeScrollView type="XCUIElementTypeScrollView" enabled="true" x="-76" y="64" width="460" height="960">
                      <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="-76" y="64" width="460" height="342">
                        <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="-76" y="164" width="460" height="242">
                          <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="-76" y="164" width="460" height="242">
                            <XCUIElementTypeOther type="XCUIElementTypeOther" name="CardTitleToolBar" enabled="true" x="-76" y="164" width="146" height="53">
                              <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="Start rounding" name="Start rounding" label="Start rounding" enabled="true" x="-66" y="174" width="126" height="33"/>
                            </XCUIElementTypeOther>
                            <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="-76" y="217" width="0" height="2"/>
                            <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="-76" y="219" width="460" height="129">
                              <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="-68" y="227" width="444" height="113">
                                <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="Where are you rounding today?" name="Where are you rounding today?" label="Where are you rounding today?" enabled="true" x="-58" y="237" width="424" height="17"/>
                                <XCUIElementTypeTextField type="XCUIElementTypeTextField" value="Choose an organization..." name="OrganizationSearchText" label="" enabled="true" x="-58" y="258" width="424" height="34"/>
                                <XCUIElementTypeTextField type="XCUIElementTypeTextField" value="Choose a location..." name="LocationSearchText" label="" enabled="false" x="-58" y="296" width="424" height="34"/>
                              </XCUIElementTypeOther>
                            </XCUIElementTypeOther>
                            <XCUIElementTypeOther type="XCUIElementTypeOther" name="CardBottomToolBar" enabled="true" x="-76" y="348" width="228" height="58">
                              <XCUIElementTypeButton type="XCUIElementTypeButton" name="StartRounding" label="Let's round!" enabled="false" x="-66" y="358" width="125" height="38"/>
                              <XCUIElementTypeButton type="XCUIElementTypeButton" name="CancelStartRound" label="Cancel" enabled="true" x="59" y="358" width="83" height="38"/>
                            </XCUIElementTypeOther>
                          </XCUIElementTypeOther>
                        </XCUIElementTypeOther>
                      </XCUIElementTypeOther>
                      <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="378" y="685" width="3" height="336"/>
                      <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="-73" y="1018" width="454" height="3"/>
                    </XCUIElementTypeScrollView>
                    <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="-230" y="1024" width="0" height="0"/>
                  </XCUIElementTypeOther>
                </XCUIElementTypeOther>
                <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="768" height="1024"/>
                <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="768" height="1024">
                  <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="64" width="768" height="960">
                    <XCUIElementTypeImage type="XCUIElementTypeImage" enabled="true" x="-9" y="64" width="9" height="960"/>
                    <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="64" width="768" height="960">
                      <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="64" width="0" height="0"/>
                      <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="64" width="768" height="960">
                        <XCUIElementTypeTable type="XCUIElementTypeTable" name="TypeAheadSearchResults" enabled="true" x="0" y="64" width="768" height="960">
                          <XCUIElementTypeCell type="XCUIElementTypeCell" enabled="true" x="0" y="64" width="768" height="50">
                            <XCUIElementTypeStaticText type="XCUIElementTypeStaticText" value="Mock Organization" name="Mock Organization" label="Mock Organization" enabled="true" x="16" y="80" width="736" height="17"/>
                          </XCUIElementTypeCell>
                        </XCUIElementTypeTable>
                      </XCUIElementTypeOther>
                      <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="1024" width="0" height="0"/>
                    </XCUIElementTypeOther>
                  </XCUIElementTypeOther>
                </XCUIElementTypeOther>
              </XCUIElementTypeOther>
            </XCUIElementTypeOther>
            <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="768" height="20"/>
          </XCUIElementTypeOther>
        </XCUIElementTypeOther>
      </XCUIElementTypeOther>
      <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="1024" width="0" height="0"/>
    </XCUIElementTypeOther>
  </XCUIElementTypeWindow>
  <XCUIElementTypeWindow type="XCUIElementTypeWindow" enabled="true" x="0" y="0" width="768" height="1024">
    <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="768" height="1024">
      <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="1024" width="768" height="0"/>
    </XCUIElementTypeOther>
  </XCUIElementTypeWindow>
  <XCUIElementTypeWindow type="XCUIElementTypeWindow" enabled="true" x="0" y="0" width="768" height="1024">
    <XCUIElementTypeStatusBar type="XCUIElementTypeStatusBar" enabled="true" x="0" y="0" width="768" height="20">
      <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="768" height="20"/>
      <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="0" y="0" width="768" height="20">
        <XCUIElementTypeOther type="XCUIElementTypeOther" enabled="true" x="6" y="0" width="42" height="20"/>
        <XCUIElementTypeOther type="XCUIElementTypeOther" value="SSID" name="3 of 3 Wi-Fi bars" label="3 of 3 Wi-Fi bars" enabled="true" x="53" y="0" width="13" height="20"/>
        <XCUIElementTypeOther type="XCUIElementTypeOther" name="10:15 AM" label="10:15 AM" enabled="true" x="359" y="0" width="55" height="20"/>
        <XCUIElementTypeOther type="XCUIElementTypeOther" name="-100% battery power" label="-100% battery power" enabled="true" x="703" y="0" width="60" height="20"/>
        <XCUIElementTypeOther type="XCUIElementTypeOther" name="100% battery power" label="100% battery power" enabled="true" x="703" y="0" width="32" height="20"/>
      </XCUIElementTypeOther>
    </XCUIElementTypeStatusBar>
  </XCUIElementTypeWindow>
</XCUIElementTypeApplication></AppiumAUT>

use native commands:

// java
el = driver.findElement(
                MobileBy.iOSNsPredicateString("type == 'XCUIElementTypeTable' AND name == 'TypeAheadSearchResults'")).
                findElement(MobileBy.iOSNsPredicateString("type == 'XCUIElementTypeStaticText'"))

I’ve been having the same problem with iOS and how it takes forever

@Aleksei, can you provide some more examples? Does “type” mean the ClassName? and does “name” mean the text? Also, what about AccessibilityID or selecting an element when there are multiple (specifying an index) ?

@kcinman11358 @Christi more to read - https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/ios_predicate.md

In ruby, find_element takes these finders:

    class: 'class name',
    class_name: 'class name',
    css: 'css selector',
    id: 'id',
    link: 'link text',
    link_text: 'link text',
    name: 'name',
    partial_link_text: 'partial link text',
    tag_name: 'tag name',
    xpath: 'xpath'

I was using the xpath finder. Which of these finders would I use to do what you are suggesting? None of them seem correct.

Also, I was able to find a workaround but it is not ideal. If I use the built in text selector, it is quick:

organization = text('My Organization')

The issue with this is that now I need to pass through the selector text since text only allows selection by the label attribute.

Sorry for the spam… I think that list of finders is incomplete! Which would be an issue in the ruby lib. I just found this code:

@driver.find_elements :predicate, predicate

Totally works!! Woo, thanks!

ruby:

organization = (find_element :predicate, 'type == "XCUIElementTypeTable" AND name == "TypeAheadSearchResults"')
                .find_element :predicate, 'type == "XCUIElementTypeStaticText"'

@Christi how fast it is now? (just to compare :slight_smile: )

Previous:

[HTTP] &lt;-- GET /wd/hub/session/6ec22214-b77a-4269-9de3-cc0fce8ee9f7/source 200 125 ms - 24046
[HTTP] --&gt; POST /wd/hub/session/6ec22214-b77a-4269-9de3-cc0fce8ee9f7/element/1092CE78-0E17-4A68-B494-F1C02AB68795/click {"{}":""}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[debug] [XCUITest] Executing command 'proxyReqRes'
[debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/6ec22214-b77a-4269-9de3-cc0fce8ee9f7/element/1092CE78-0E17-4A68-B494-F1C02AB68795/click] to [POST http://localhost:8100/session/810EFB7F-4E88-4179-93CE-AE8E1C23372A/element/1092CE78-0E17-4A68-B494-F1C02AB68795/click] with body: {"{}":""}
[debug] [JSONWP Proxy] Got response with status 200: {"status":0,"id":"1092CE78-0E17-4A68-B494-F1C02AB68795","sessionId":"810EFB7F-4E88-4179-93CE-AE8E1C23372A","value":""}
[JSONWP Proxy] Replacing sessionId 810EFB7F-4E88-4179-93CE-AE8E1C23372A with 6ec22214-b77a-4269-9de3-cc0fce8ee9f7
[HTTP] &lt;-- POST /wd/hub/session/6ec22214-b77a-4269-9de3-cc0fce8ee9f7/element/1092CE78-0E17-4A68-B494-F1C02AB68795/click 200 16081 ms - 118

Now:

[HTTP] --> POST /wd/hub/session/ae29a2ca-46de-49cf-8749-82c1388b1fe8/element {"using":"-ios predicate string","value":"type == \"XCUIElementTypeTable\" AND name == \"TypeAheadSearchResults\""}
[debug] [MJSONWP] Calling AppiumDriver.findElement() with args: ["-ios predicate string","type == \"XCUIElementTypeTable\" AND name == \"TypeAheadSearchResults\"","ae29a2ca-46de-49cf-8749-82c1388b1fe8"]
[debug] [XCUITest] Executing command 'findElement'
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id
[debug] [BaseDriver] Waiting up to 0 ms for condition
[debug] [JSONWP Proxy] Proxying [POST /element] to [POST http://localhost:8100/session/6C0EC812-A262-47F6-A3C6-9FFCC1CE65BD/element] with body: {"using":"predicate string","value":"type == \"XCUIElementTypeTable\" AND name == \"TypeAheadSearchResults\""}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"6C0EC812-A262-47F6-A3C6-9FFCC1CE65BD","value":{"label":null,"type":"XCUIElementTypeTable","ELEMENT":"C4DB9828-9074-4E39-A1FF-25AA5DA84E4A"},"status":0}
[debug] [MJSONWP] Responding to client with driver.findElement() result: {"label":null,"type":"XCUIElementTypeTable","ELEMENT":"C4DB9828-9074-4E39-A1FF-25AA5DA84E4A"}
[HTTP] <-- POST /wd/hub/session/ae29a2ca-46de-49cf-8749-82c1388b1fe8/element 200 269 ms - 165
[HTTP] --> POST /wd/hub/session/ae29a2ca-46de-49cf-8749-82c1388b1fe8/element/C4DB9828-9074-4E39-A1FF-25AA5DA84E4A/element {"using":"-ios predicate string","value":"type == \"XCUIElementTypeStaticText\""}
[debug] [MJSONWP] Calling AppiumDriver.findElementFromElement() with args: ["-ios predicate string","type == \"XCUIElementTypeStaticText\"","C4DB9828-9074-4E39-A1FF-25AA5DA84E4A","ae29a2ca-46de-49cf-8749-82c1388b1fe8"]
[debug] [XCUITest] Executing command 'findElementFromElement'
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, name, class name, -ios predicate string, -ios class chain, accessibility id
[debug] [BaseDriver] Waiting up to 0 ms for condition
[debug] [JSONWP Proxy] Proxying [POST /element/C4DB9828-9074-4E39-A1FF-25AA5DA84E4A/element] to [POST http://localhost:8100/session/6C0EC812-A262-47F6-A3C6-9FFCC1CE65BD/element/C4DB9828-9074-4E39-A1FF-25AA5DA84E4A/element] with body: {"using":"predicate string","value":"type == \"XCUIElementTypeStaticText\""}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"6C0EC812-A262-47F6-A3C6-9FFCC1CE65BD","value":{"label":"Mock Organization","type":"XCUIElementTypeStaticText","ELEMENT":"6C5A3811-D400-4C5B-9D28-CB30A7BDB09E"},"status":0}
[debug] [MJSONWP] Responding to client with driver.findElementFromElement() result: {"label":"Mock Organization","type":"XCUIElementTypeStaticText","ELEMENT":"6C5A3811-D400-4C5B-9D28-CB30A7BDB09E"}
[HTTP] <-- POST /wd/hub/session/ae29a2ca-46de-49cf-8749-82c1388b1fe8/element/C4DB9828-9074-4E39-A1FF-25AA5DA84E4A/element 200 371 ms - 185
[HTTP] --> POST /wd/hub/session/ae29a2ca-46de-49cf-8749-82c1388b1fe8/element/6C5A3811-D400-4C5B-9D28-CB30A7BDB09E/click {"{}":""}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[debug] [XCUITest] Executing command 'proxyReqRes'
[debug] [JSONWP Proxy] Proxying [POST /wd/hub/session/ae29a2ca-46de-49cf-8749-82c1388b1fe8/element/6C5A3811-D400-4C5B-9D28-CB30A7BDB09E/click] to [POST http://localhost:8100/session/6C0EC812-A262-47F6-A3C6-9FFCC1CE65BD/element/6C5A3811-D400-4C5B-9D28-CB30A7BDB09E/click] with body: {"{}":""}
[debug] [JSONWP Proxy] Got response with status 200: {"status":0,"id":"6C5A3811-D400-4C5B-9D28-CB30A7BDB09E","sessionId":"6C0EC812-A262-47F6-A3C6-9FFCC1CE65BD","value":""}
[JSONWP Proxy] Replacing sessionId 6C0EC812-A262-47F6-A3C6-9FFCC1CE65BD with ae29a2ca-46de-49cf-8749-82c1388b1fe8
[HTTP] <-- POST /wd/hub/session/ae29a2ca-46de-49cf-8749-82c1388b1fe8/element/6C5A3811-D400-4C5B-9D28-CB30A7BDB09E/click 200 685 ms - 118

So the click itself took 685 ms versus the previous 16081 ms. The initial find of the element is a little slower, 269 ms + 371 ms versus the previous 125 ms. Total time savings: 14881 ms!

I also ended up changing the rest of my xpath selectors to predicates where I could, so that might have sped up the full test suite some, though I didn’t collect numbers on how long it took before.