Class: TestCentricity::AppElements::AppUIElement

Inherits:
Object
  • Object
show all
Includes:
Test::Unit::Assertions
Defined in:
lib/testcentricity_apps/app_elements/app_element.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, parent, locator, context) ⇒ AppUIElement

Returns a new instance of AppUIElement.



19
20
21
22
23
24
25
26
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 19

def initialize(name, parent, locator, context)
  @name = name
  @parent = parent
  @locator = locator
  @context = context
  @type = nil
  reset_mru_cache
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



16
17
18
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 16

def context
  @context
end

#locatorObject (readonly)

Returns the value of attribute locator.



16
17
18
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 16

def locator
  @locator
end

#mru_app_sessionObject

Returns the value of attribute mru_app_session.



17
18
19
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 17

def mru_app_session
  @mru_app_session
end

#mru_locatorObject

Returns the value of attribute mru_locator.



17
18
19
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 17

def mru_locator
  @mru_locator
end

#mru_objectObject

Returns the value of attribute mru_object.



17
18
19
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 17

def mru_object
  @mru_object
end

#mru_parentObject

Returns the value of attribute mru_parent.



17
18
19
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 17

def mru_parent
  @mru_parent
end

#nameObject (readonly)

Returns the value of attribute name.



16
17
18
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 16

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent.



16
17
18
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 16

def parent
  @parent
end

#typeObject (readonly)

Returns the value of attribute type.



16
17
18
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 16

def type
  @type
end

Instance Method Details

#clearObject



80
81
82
83
84
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 80

def clear
  obj = element
  object_not_found_exception(obj)
  obj.clear
end

#clickObject

Click on a UI element

Examples:

.click


455
456
457
458
459
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 455

def click
  obj = element
  object_not_found_exception(obj)
  obj.click
end

#countInteger

Return the number of occurrences of an object with an ambiguous locator that evaluates to multiple UI elements.

Examples:

num_items = store_item.count

Returns:

  • (Integer)


445
446
447
448
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 445

def count
  objs = find_elements(@locator.keys[0], @locator.values[0])
  objs.count
end

#disabled?Boolean

Is UI object disabled (not enabled)?

Examples:

refresh_button.disabled?

Returns:

  • (Boolean)


217
218
219
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 217

def disabled?
  !enabled?
end

#double_tapObject

Double-tap on a UI element

Examples:

refresh_chart_button.double_tap


480
481
482
483
484
485
486
487
488
489
490
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 480

def double_tap
  obj = element
  object_not_found_exception(obj)
  driver.action
        .click_and_hold(obj)
        .release
        .pause(duration: 0.2)
        .click_and_hold(obj)
        .release
        .perform
end

#drag_and_drop(target, duration = 0.3) ⇒ Object

Drag the UI object to the specified target object. If the optional duration parameter is not specified, the duration defaults to 0.3 seconds (300 milliseconds).

Examples:

puzzle_21_piece.drag_and_drop(puzzle_21_slot)

Parameters:

  • target (String)

    target object to drag to

  • duration (Float) (defaults to: 0.3)

    OPTIONAL duration of drag in seconds



550
551
552
553
554
555
556
557
558
559
560
561
562
563
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 550

def drag_and_drop(target, duration = 0.3)
  drag = element
  object_not_found_exception(drag)
  drop = target.element
  drag_x = drag.location.x
  drag_y = drag.location.y
  drop_x = drop.location.x
  drop_y = drop.location.y
  driver.action
        .click_and_hold(drag)
        .move_by(drop_x - drag_x, drop_y - drag_y, duration: duration)
        .release
        .perform
end

#drag_by(right_offset, down_offset, duration = 0.3) ⇒ Object

Drag the UI object by the specified offset. If the optional duration parameter is not specified, the duration defaults to 0.3 seconds (300 milliseconds).

Examples:

puzzle_21_piece.drag_by(-100, -300)

Parameters:

  • right_offset (Integer)

    x coordinate offset

  • down_offset (Integer)

    y coordinate offset

  • duration (Float) (defaults to: 0.3)

    OPTIONAL duration of drag in seconds



532
533
534
535
536
537
538
539
540
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 532

def drag_by(right_offset, down_offset, duration = 0.3)
  obj = element
  object_not_found_exception(obj)
  driver.action
        .click_and_hold(obj)
        .move_by(right_offset, down_offset, duration: duration)
        .release
        .perform
end

#elementObject



653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 653

def element
  reset_mru_cache if @mru_app_session != Environ.app_session_id
  obj = if @context == :section
          parent_obj = nil
          parent_locator = @parent.get_locator

          if @mru_locator == @locator && @mru_parent == parent_locator && !@mru_object.nil?
            return @mru_object
          end

          parent_locator.each do |locators|

            if locators.keys[0] == :object
              parent_obj = locators.values[0]
              break
            end

            parent_obj = if parent_obj.nil?
                           find_element(locators.keys[0], locators.values[0])
                         else
                           parent_obj.find_element(locators.keys[0], locators.values[0])
                         end
          end
          puts "Found parent object '#{@parent.get_name}' - #{@parent.get_locator}" if ENV['DEBUG']
          parent_obj.find_element(@locator.keys[0], @locator.values[0])
        else
          return @mru_object if @mru_locator == @locator && !@mru_object.nil?
          find_element(@locator.keys[0], @locator.values[0])
        end
  puts "Found object '#{@name}' - #{@locator}" if ENV['DEBUG']
  @mru_object = obj
  @mru_locator = @locator
  @mru_parent = parent_locator
  @mru_app_session = Environ.app_session_id
  obj
rescue
  puts "Did not find object '#{@name}' - #{@locator}" if ENV['DEBUG']
  nil
end

#enabled?Boolean

Is UI object enabled?

Examples:

.enabled?

Returns:

  • (Boolean)


205
206
207
208
209
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 205

def enabled?
  obj = element
  object_not_found_exception(obj)
  obj.enabled?
end

#exists?Boolean

Does UI object exists?

Examples:

empty_cart_image.exists?

Returns:

  • (Boolean)


165
166
167
168
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 165

def exists?
  obj = element
  !obj.nil?
end

#get_attribute(attrib) ⇒ Object



227
228
229
230
231
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 227

def get_attribute(attrib)
  obj = element
  object_not_found_exception(obj)
  obj.attribute(attrib)
end

#get_captionObject Also known as: caption



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 107

def get_caption
  obj = element
  object_not_found_exception(obj)
  if Environ.is_macos?
    return obj.title
  elsif AppiumConnect.is_webview?
    caption = case obj.tag_name.downcase
              when 'input', 'select', 'textarea'
                obj.value
              else
                obj.text
              end
  elsif Environ.is_ios?
    caption = case obj.tag_name
              when 'XCUIElementTypeNavigationBar'
                obj.attribute(:name)
              else
                obj.attribute(:label)
              end
    caption = '' if caption.nil?
  else
    caption = obj.text
    if caption.blank?
      case obj.attribute(:class)
      when 'android.view.ViewGroup'
        caption_obj = obj.find_element(:xpath, '//android.widget.TextView')
        caption = caption_obj.text
      when 'android.widget.Button'
        caption_obj = obj.find_element(:xpath, '//android.widget.TextView')
        caption = caption_obj.text
        if caption.blank?
          caption_obj = obj.find_element(:xpath, '//android.widget.ViewGroup/android.widget.TextView')
          caption = caption_obj.text
        end
      end
    end
  end
  caption
end

#get_locatorObject



39
40
41
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 39

def get_locator
  @locator
end

#get_nameObject



43
44
45
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 43

def get_name
  @name
end

#get_object_typeObject



35
36
37
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 35

def get_object_type
  @type
end

#get_valueObject Also known as: value



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 86

def get_value
  obj = element
  object_not_found_exception(obj)
  if Environ.is_macos?
    value = obj.value
    value = obj.title if value.nil?
    return value
  elsif AppiumConnect.is_webview?
    case obj.tag_name.downcase
    when 'input', 'select', 'textarea'
      obj.value
    else
      obj.text
    end
  else
    obj.text
  end
end

#heightInteger

Return height of object.

Examples:

button_height = my_button.height

Returns:

  • (Integer)


409
410
411
412
413
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 409

def height
  obj = element
  object_not_found_exception(obj)
  obj.size.height
end

#hidden?Boolean

Is UI object hidden (not visible)?

Examples:

remember_me_checkbox.hidden?

Returns:

  • (Boolean)


195
196
197
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 195

def hidden?
  !visible?
end

#hoverObject



517
518
519
520
521
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 517

def hover
  obj = element
  object_not_found_exception(obj)
  Environ.appium_driver.execute_script('macos: hover', { elementId: obj.id })
end

#idObject



47
48
49
50
51
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 47

def id
  obj = element
  object_not_found_exception(obj)
  obj.id
end

#identifierObject



149
150
151
152
153
154
155
156
157
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 149

def identifier
  if Environ.is_macos?
    obj = element
    object_not_found_exception(obj)
    obj.identifier
  else
    raise 'identifier is not a supported attribute'
  end
end

#long_press(duration = 1) ⇒ Object

Long press on a UI element

Examples:

header_image.long_press(1.5)

Parameters:

  • duration (Float) (defaults to: 1)

    duration of long press in seconds



498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 498

def long_press(duration = 1)
  obj = element
  object_not_found_exception(obj)
  if Environ.is_ios?
    begin
      Environ.appium_driver.execute_script('mobile: touchAndHold', { elementId: obj.id, duration: duration })
    rescue => err
      puts "Retrying longpress due to error: #{err}"
    else
      return
    end
  end
  driver.action
        .click_and_hold(obj)
        .pause(duration: duration)
        .release
        .perform
end

#reset_mru_cacheObject



28
29
30
31
32
33
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 28

def reset_mru_cache
  @mru_object = nil
  @mru_locator = nil
  @mru_parent = nil
  @mru_app_session = nil
end

#scroll_into_view(scroll_mode = :vertical) ⇒ Object

Scroll the UI object until it is visible. If scroll_mode is not specified, then vertical scrolling will be used.

Examples:

place_order_button.scroll_into_view(scroll_mode = :horizontal)

Parameters:

  • scroll_mode (Symbol) (defaults to: :vertical)

    :vertical (default) or :horizontal



571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 571

def scroll_into_view(scroll_mode = :vertical)
  return if visible?
  case scroll_mode
  when :vertical
    start_direction = :down
    end_direction = :up
  when :horizontal
    start_direction = :right
    end_direction = :left
  else
    raise "#{scroll_mode} is not a valid selector"
  end
  try_count = 8
  direction = start_direction
  while hidden?
    ScreenManager.current_screen.swipe_gesture(direction, distance = 0.1)
    try_count -= 1
    if try_count.zero?
      if direction == end_direction
        break
      else
        direction = end_direction
        try_count = 8
      end
    end
  end
end

#selected?Boolean

Returns:

  • (Boolean)


221
222
223
224
225
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 221

def selected?
  obj = element
  object_not_found_exception(obj)
  obj.selected?
end

#send_keys(value) ⇒ Object

Send keystrokes to this UI element.

Examples:

color_picker_wheel.send_keys('Lime green')

Parameters:



74
75
76
77
78
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 74

def send_keys(value)
  obj = element
  object_not_found_exception(obj)
  obj.send_keys(value)
end

#set(value) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 53

def set(value)
  obj = element
  object_not_found_exception(obj)
  if value.is_a?(Array)
    obj.send_keys(value[0])
    if value[1].is_a?(Integer)
      press_keycode(value[1])
    else
      obj.send_keys(value[1])
    end
  elsif value.is_a?(String)
    obj.send_keys(value)
  end
end

#swipe_gesture(direction, distance = 0.5) ⇒ Object

Perform a swipe gesture on the UI object in the specified direction. The swipe start point is the center of the UI object, and the swipe end point is the distance specified.

A distance of 1 specifies a swipe gesture with a distance that is the full screen height (vertical swipe), or full screen width (horizontal swipe). A distance of 0.5 specifies a swipe gesture with a distance that is half the screen width or height.

If distance is a value less than zero, then the distance of the swipe gesture will be half the height (vertical) or width (horizontal) of the UI element being swiped. This is useful for preforming swipes/scrolls in vertical or horizontal list objects.

Examples:

carousel_list.swipe_gesture(direction = :right, distance = 1)

Parameters:

  • direction (Symbol)

    :up, :down, :left, or :right

  • distance (Float) (defaults to: 0.5)

    scroll distance relative to the screen height or width



615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 615

def swipe_gesture(direction, distance = 0.5)
  raise 'Scroll distance must be less than 1' if distance > 1
  obj = element
  object_not_found_exception(obj)
  start_pt = [(obj.location.x + (obj.size.width * 0.5)).to_i, (obj.location.y + (obj.size.height * 0.5)).to_i]

  if distance < 0
    top = (start_pt[1] - obj.size.height).to_i
    bottom = (start_pt[1] + obj.size.height).to_i
    left = (start_pt[0] - obj.size.width).to_i
    right = (start_pt[0] + obj.size.width).to_i
  else
    screen_size = window_size
    top = (start_pt[1] - ((screen_size.height * distance) * 0.5)).to_i
    bottom = (start_pt[1] + ((screen_size.height * distance) * 0.5)).to_i
    left = (start_pt[0] - ((screen_size.width * distance) * 0.5)).to_i
    right = (start_pt[0] + ((screen_size.width * distance) * 0.5)).to_i
  end

  end_pt = case direction
           when :up
             [start_pt[0], bottom]
           when :down
             [start_pt[0], top]
           when :left
             [right, start_pt[1]]
           when :right
             [left, start_pt[1]]
           end

  puts "Swipe start_pt = #{start_pt} / end_pt = #{end_pt}" if ENV['DEBUG']
  driver.action
        .click_and_hold(obj)
        .move_to_location(end_pt[0], end_pt[1], duration: 0.25)
        .pointer_up
        .perform
end

#tapObject

Tap on a UI element

Examples:

bar_chart_close.tap


466
467
468
469
470
471
472
473
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 466

def tap
  obj = element
  object_not_found_exception(obj)
  driver.action
        .click_and_hold(obj)
        .release
        .perform
end

#visible?Boolean

Is UI object visible?

Examples:

remember_me_checkbox.visible?

Returns:

  • (Boolean)


176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 176

def visible?
  obj = element
  return false if obj.nil?
  begin
    obj.displayed?
  rescue
    reset_mru_cache
    obj = element
    return false if obj.nil?
    obj.displayed?
  end
end

#wait_until_enabled(seconds = nil, post_exception = true) ⇒ Object

Wait until the object is enabled, or until the specified wait time has expired. If the wait time is nil, then the wait time will be Environ.default_max_wait_time.

Examples:

run_button.wait_until_enabled(10)

Parameters:

  • seconds (Integer or Float) (defaults to: nil)

    wait time in seconds



328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 328

def wait_until_enabled(seconds = nil, post_exception = true)
  timeout = seconds.nil? ? Environ.default_max_wait_time : seconds
  wait = Selenium::WebDriver::Wait.new(timeout: timeout)
  wait.until do
    reset_mru_cache
    enabled?
  end
rescue
  if post_exception
    raise "UI #{object_ref_message} remained disabled after #{timeout} seconds" unless enabled?
  else
    enabled?
  end
end

#wait_until_exists(seconds = nil, post_exception = true) ⇒ Object

Wait until the object exists, or until the specified wait time has expired. If the wait time is nil, then the wait time will be Environ.default_max_wait_time.

Examples:

run_button.wait_until_exists(0.5)

Parameters:

  • seconds (Integer or Float) (defaults to: nil)

    wait time in seconds



240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 240

def wait_until_exists(seconds = nil, post_exception = true)
  timeout = seconds.nil? ? Environ.default_max_wait_time : seconds
  wait = Selenium::WebDriver::Wait.new(timeout: timeout)
  wait.until do
    reset_mru_cache
    exists?
  end
rescue
  if post_exception
    raise "Could not find UI #{object_ref_message} after #{timeout} seconds" unless exists?
  else
    exists?
  end
end

#wait_until_gone(seconds = nil, post_exception = true) ⇒ Object

Wait until the object no longer exists, or until the specified wait time has expired. If the wait time is nil, then the wait time will be Environ.default_max_wait_time.

Examples:

logout_button.wait_until_gone(5)

Parameters:

  • seconds (Integer or Float) (defaults to: nil)

    wait time in seconds



262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 262

def wait_until_gone(seconds = nil, post_exception = true)
  timeout = seconds.nil? ? Environ.default_max_wait_time : seconds
  wait = Selenium::WebDriver::Wait.new(timeout: timeout)
  wait.until do
    reset_mru_cache
    !exists?
  end
rescue
  if post_exception
    raise "UI #{object_ref_message} remained visible after #{timeout} seconds" if exists?
  else
    exists?
  end
end

#wait_until_hidden(seconds = nil, post_exception = true) ⇒ Object

Wait until the object is hidden, or until the specified wait time has expired. If the wait time is nil, then the wait time will be Environ.default_max_wait_time.

Examples:

run_button.wait_until_hidden(10)

Parameters:

  • seconds (Integer or Float) (defaults to: nil)

    wait time in seconds



306
307
308
309
310
311
312
313
314
315
316
317
318
319
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 306

def wait_until_hidden(seconds = nil, post_exception = true)
  timeout = seconds.nil? ? Environ.default_max_wait_time : seconds
  wait = Selenium::WebDriver::Wait.new(timeout: timeout)
  wait.until do
    reset_mru_cache
    hidden?
  end
rescue
  if post_exception
    raise "UI #{object_ref_message} remained visible after #{timeout} seconds" if visible?
  else
    hidden?
  end
end

#wait_until_value_changes(seconds = nil, post_exception = true) ⇒ Object

Wait until the object's value changes to a different value, or until the specified wait time has expired. If the wait time is nil, then the wait time will be Environ.default_max_wait_time.

Examples:

basket_grand_total_label.wait_until_value_changes(5)

Parameters:

  • seconds (Integer or Float) (defaults to: nil)

    wait time in seconds



375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 375

def wait_until_value_changes(seconds = nil, post_exception = true)
  value = get_value
  timeout = seconds.nil? ? Environ.default_max_wait_time : seconds
  wait = Selenium::WebDriver::Wait.new(timeout: timeout)
  wait.until do
    reset_mru_cache
    get_value != value
  end
rescue
  if post_exception
    raise "Value of UI #{object_ref_message} failed to change from '#{value}' after #{timeout} seconds" if get_value == value
  else
    get_value == value
  end
end

#wait_until_value_is(value, seconds = nil, post_exception = true) ⇒ Object

Wait until the object's value equals the specified value, or until the specified wait time has expired. If the wait time is nil, then the wait time will be Environ.default_max_wait_time.

Examples:

card_authorized_label.wait_until_value_is('Card authorized', 5)
  or
total_weight_field.wait_until_value_is({ :greater_than => '250' }, 5)

Parameters:

  • value (String or Hash)

    value expected or comparison hash

  • seconds (Integer or Float) (defaults to: nil)

    wait time in seconds



353
354
355
356
357
358
359
360
361
362
363
364
365
366
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 353

def wait_until_value_is(value, seconds = nil, post_exception = true)
  timeout = seconds.nil? ? Environ.default_max_wait_time : seconds
  wait = Selenium::WebDriver::Wait.new(timeout: timeout)
  wait.until do
    reset_mru_cache
    compare(value, get_value)
  end
rescue
  if post_exception
    raise "Value of UI #{object_ref_message} failed to equal '#{value}' after #{timeout} seconds" unless get_value == value
  else
    get_value == value
  end
end

#wait_until_visible(seconds = nil, post_exception = true) ⇒ Object

Wait until the object is visible, or until the specified wait time has expired. If the wait time is nil, then the wait time will be Environ.default_max_wait_time.

Examples:

run_button.wait_until_visible(0.5)

Parameters:

  • seconds (Integer or Float) (defaults to: nil)

    wait time in seconds



284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 284

def wait_until_visible(seconds = nil, post_exception = true)
  timeout = seconds.nil? ? Environ.default_max_wait_time : seconds
  wait = Selenium::WebDriver::Wait.new(timeout: timeout)
  wait.until do
    reset_mru_cache
    visible?
  end
rescue
  if post_exception
    raise "Could not find UI #{object_ref_message} after #{timeout} seconds" unless visible?
  else
    visible?
  end
end

#widthInteger

Return width of object.

Examples:

button_width = my_button.width

Returns:

  • (Integer)


397
398
399
400
401
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 397

def width
  obj = element
  object_not_found_exception(obj)
  obj.size.width
end

#x_locInteger

Return x coordinate of object's location.

Examples:

button_x = my_button.x_loc

Returns:

  • (Integer)


421
422
423
424
425
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 421

def x_loc
  obj = element
  object_not_found_exception(obj)
  obj.location.x
end

#y_locInteger

Return y coordinate of object's location.

Examples:

button_y = my_button.y_loc

Returns:

  • (Integer)


433
434
435
436
437
# File 'lib/testcentricity_apps/app_elements/app_element.rb', line 433

def y_loc
  obj = element
  object_not_found_exception(obj)
  obj.location.y
end