Using 'accessibilityIdentifier' for webview


Right now we are iterating/switching over available webviews and recognizing the one we want to stay on by examining if page.title property has specific string value

This works well on Android for our application and it used to work on iOS. There was 3rd webview created after user logged in and it was selected properly. After some changes in the app and adding 4th webview that is being created only for a while but has same page.title property. This results in switching to a webview that will cease to exist in a few seconds which results in our test to hang.

We know that the application is setting webview name with this method

We think it should be visible as ‘name’ property:

A question is how to reference it from our code, we are using ruby, currently we have this function:

  def find_window_with_title(title, wait: FIND_WINDOW_TIMEOUT, ...)
    index = 0
    Timeout.timeout(wait) do
      loop do
        length = page.driver.window_handles.length
        windows = page.driver.window_handles
        # windows[index] can become null
          page.driver.switch_to_window windows[index] unless windows[index].nil?
          index = (index + 1) % length
          log_hybrid_helper "Iterating over window(webview) with title: #{page.title}"

          unless page.nil? || page.title.nil? || page.title.empty?
             break if page.title.include? title
        rescue NoMethodError => e
          #ignore this error as it is expected when page becomes nil after logout
    log_hybrid_helper "Switched to window(webview) with title: #{page.title}"

Any hints will be appreciated.