Class: TestCentricity::ScreenSection

Inherits:
BaseScreenSectionObject show all
Includes:
Test::Unit::Assertions
Defined in:
lib/testcentricity_apps/app_core/screen_section.rb

Direct Known Subclasses

MenuBar

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseScreenSectionObject

#populate_data_fields, #swipe_gesture, trait, #verify_ui_states

Constructor Details

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

Returns a new instance of ScreenSection.



10
11
12
13
14
15
16
17
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 10

def initialize(name, parent, locator, context)
  @name        = name
  @parent      = parent
  @locator     = locator
  @context     = context
  @parent_list = nil
  @list_index  = nil
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



7
8
9
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 7

def context
  @context
end

#list_indexObject

Returns the value of attribute list_index.



8
9
10
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 8

def list_index
  @list_index
end

#locatorObject

Returns the value of attribute locator.



8
9
10
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 8

def locator
  @locator
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 7

def name
  @name
end

#parentObject

Returns the value of attribute parent.



8
9
10
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 8

def parent
  @parent
end

#parent_listObject

Returns the value of attribute parent_list.



8
9
10
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 8

def parent_list
  @parent_list
end

Class Method Details

.button(element_name, locator) ⇒ Object

Declare and instantiate a single button UI Element for this screen section object.

Examples:

button :video_play,  { accessibility_id: 'video icon play' }

Parameters:

  • element_name (Symbol)

    name of button object (as a symbol)

  • locator (Hash)

    { locator_strategy: locator_identifier }



123
124
125
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 123

def self.button(element_name, locator)
  define_section_element(element_name, TestCentricity::AppElements::AppButton, locator)
end

.buttons(element_hash) ⇒ Object

Declare and instantiate a collection of buttons for this screen section object.

Examples:

buttons video_back:    { accessibility_id: 'video icon backward' },
        video_play:    { accessibility_id: 'video icon play' },
        video_pause:   { accessibility_id: 'video icon stop' },
        video_forward: { accessibility_id: 'video icon forward' }

Parameters:

  • element_hash (Hash)

    names of buttons (as symbol) and locator Hash



136
137
138
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 136

def self.buttons(element_hash)
  element_hash.each_pair { |element_name, locator| button(element_name, locator) }
end

.checkbox(element_name, locator) ⇒ Object

Declare and instantiate a single checkbox UI Element for this screen section object.

Examples:

checkbox :bill_address_check, { xpath: '//XCUIElementTypeOther[contains(@name, "billing checkbox")]'}

Parameters:

  • element_name (Symbol)

    name of checkbox object (as a symbol)

  • locator (Hash)

    { locator_strategy: locator_identifier }



192
193
194
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 192

def self.checkbox(element_name, locator)
  define_section_element(element_name, TestCentricity::AppElements::AppCheckBox, locator)
end

.checkboxes(element_hash) ⇒ Object

Declare and instantiate a collection of checkboxes for this screen section object.

Examples:

checkboxes bill_address_check: { xpath: '//XCUIElementTypeOther[contains(@name, "billing checkbox")]'},
           is_gift_check: { accessibility_id: 'is a gift' }

Parameters:

  • element_hash (Hash)

    names of checkboxes (as symbol) and locator Hash



203
204
205
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 203

def self.checkboxes(element_hash)
  element_hash.each_pair { |element_name, locator| checkbox(element_name, locator) }
end

.define_section_element(element_name, obj, locator) ⇒ Object



702
703
704
705
706
707
708
709
710
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 702

def self.define_section_element(element_name, obj, locator)
  define_method(element_name) do
    ivar_name = "@#{element_name}"
    ivar = instance_variable_get(ivar_name)
    return ivar if ivar

    instance_variable_set(ivar_name, obj.new(element_name, self, locator, :section))
  end
end

.element(element_name, locator) ⇒ Object

Declare and instantiate a single generic UI Element for this screen section object.

  • The locator_identifier (a String) is the value or attribute that uniquely and unambiguously identifies the UI element.

Examples:

element :video_player, { accessibility_id: 'YouTube Video Player' }

Parameters:

  • element_name (Symbol)

    name of UI object (as a symbol)

  • locator (Hash)

    { locator_strategy: locator_identifier } The locator_strategy (a Symbol) specifies the selector strategy that Appium will use to find the UI element. Valid selectors are accessibility_id:, id:, name:, class:, xpath:, predicate: (iOS only), class_chain: (iOS only), and css: (WebViews in hybrid apps only).



100
101
102
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 100

def self.element(element_name, locator)
  define_section_element(element_name, TestCentricity::AppElements::AppUIElement, locator)
end

.elements(element_hash) ⇒ Object

Declare and instantiate a collection of generic UI Elements for this screen section object.

Examples:

elements drop_down_field: { accessibility_id: 'drop_trigger' },
         settings_item: { accessibility_id: 'settings' },
         log_out_item:  { accessibility_id: 'logout' }

Parameters:

  • element_hash (Hash)

    names of UI objects (as a Symbol) and locator Hash



112
113
114
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 112

def self.elements(element_hash)
  element_hash.each_pair { |element_name, locator| element(element_name, locator) }
end

.image(element_name, locator) ⇒ Object

Declare and instantiate a single image UI Element for this screen section object.

Examples:

image :product_image, { xpath: '//XCUIElementTypeImage' }

Parameters:

  • element_name (Symbol)

    name of image object (as a symbol)

  • locator (Hash)

    { locator_strategy: locator_identifier }



324
325
326
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 324

def self.image(element_name, locator)
  define_section_element(element_name, TestCentricity::AppElements::AppImage, locator)
end

.images(element_hash) ⇒ Object

Declare and instantiate a collection of images for this screen section object.

Examples:

images empty_cart_image: { accessibility_id: 'empty_cart' },
       logo_image: { accessibility_id: 'WebdriverIO logo' }

Parameters:

  • element_hash (Hash)

    names of images (as symbol) and locator Hash



335
336
337
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 335

def self.images(element_hash)
  element_hash.each_pair { |element_name, locator| image(element_name, locator) }
end

.label(element_name, locator) ⇒ Object

Declare and instantiate a single label UI Element for this screen section object.

Examples:

label :header_label, { accessibility_id: 'container header' }

Parameters:

  • element_name (Symbol)

    name of label object (as a symbol)

  • locator (Hash)

    { locator_strategy: locator_identifier }



236
237
238
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 236

def self.label(element_name, locator)
  define_section_element(element_name, TestCentricity::AppElements::AppLabel, locator)
end

.labels(element_hash) ⇒ Object

Declare and instantiate a collection of labels for this screen section object.

Examples:

labels total_qty_value:   { accessibility_id: 'total number' },
       total_price_value: { accessibility_id: 'total price' }

Parameters:

  • element_hash (Hash)

    names of labels (as symbol) and locator Hash



247
248
249
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 247

def self.labels(element_hash)
  element_hash.each_pair { |element_name, locator| label(element_name, locator) }
end

.list(element_name, locator) ⇒ Object

Declare and instantiate a single list UI Element for this screen section object.

Examples:

list :carousel_list, { accessibility_id: 'Carousel' }

Parameters:

  • element_name (Symbol)

    name of list object (as a symbol)

  • locator (Hash)

    { locator_strategy: locator_identifier }



258
259
260
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 258

def self.list(element_name, locator)
  define_section_element(element_name, TestCentricity::AppElements::AppList, locator)
end

.lists(element_hash) ⇒ Object

Declare and instantiate a collection of lists for this screen section object.

Examples:

lists product_grid: { xpath: '//android.widget.ScrollView/android.view.ViewGroup' },
      cart_list: { xpath: '//android.widget.ScrollView[@content-desc="cart screen"]' }

Parameters:

  • element_hash (Hash)

    names of lists (as symbol) and locator Hash



269
270
271
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 269

def self.lists(element_hash)
  element_hash.each_pair { |element_name, locator| list(element_name, locator) }
end

Declare and instantiate a single menu UI Element for this ScreenSection object.

Examples:

menu :convert_menu, { xpath: '//XCUIElementTypeMenuBarItem[6]' }

Parameters:

  • element_name (Symbol)

    name of menu object (as a symbol)

  • locator (Hash)

    { locator_strategy: locator_identifier }



346
347
348
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 346

def self.menu(element_name, locator)
  define_section_element(element_name, TestCentricity::AppElements::AppMenu, locator)
end

Declare and instantiate a collection of menus for this ScreenSection object.

Examples:

menus convert_menu: { xpath: '//XCUIElementTypeMenuBarItem[6]' },
      view_menu:    { xpath: '//XCUIElementTypeMenuBarItem[5]' }

Parameters:

  • element_hash (Hash)

    names of menus (as symbol) and locator Hash



357
358
359
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 357

def self.menus(element_hash)
  element_hash.each_pair { |element_name, locator| menu(element_name, locator) }
end

.radio(element_name, locator) ⇒ Object

Declare and instantiate a single radio button UI Element for this screen section object.

Examples:

radio :unicode_radio, { xpath: '//XCUIElementTypeRadioButton[@label="Unicode"]'}

Parameters:

  • element_name (Symbol)

    name of radio button object (as a symbol)

  • locator (Hash)

    { locator_strategy: locator_identifier }



214
215
216
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 214

def self.radio(element_name, locator)
  define_section_element(element_name, TestCentricity::AppElements::AppRadio, locator)
end

.radios(element_hash) ⇒ Object

Declare and instantiate a collection of radio buttons for this screen section object.

Examples:

radios unicode_radio: { xpath: '//XCUIElementTypeRadioButton[@label="Unicode"]'},
       ascii_radio:   { xpath: '//XCUIElementTypeRadioButton[@label="ASCII"] }

Parameters:

  • element_hash (Hash)

    names of radio buttons (as symbol) and locator Hash



225
226
227
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 225

def self.radios(element_hash)
  element_hash.each_pair { |element_name, locator| radio(element_name, locator) }
end

.section(section_name, obj, locator = 0) ⇒ Object

Instantiate a single ScreenSection object within this ScreenSection object.

Examples:

section :nav_menu, NavMenu

Parameters:

  • section_name (Symbol)

    name of ScreenSection object (as a symbol)

  • class_name (Class)

    Class name of ScreenSection object



368
369
370
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 368

def self.section(section_name, obj, locator = 0)
  define_section_element(section_name, obj, locator)
end

.sections(section_hash) ⇒ Object

Declare and instantiate a collection of ScreenSection objects for this ScreenSection object.

Examples:

sections product_grid_item: ProductGridItem,
         sort_by_menu:      SortByMenu

Parameters:

  • element_hash (Hash)

    names of ScreenSections (as symbol) and class name



379
380
381
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 379

def self.sections(section_hash)
  section_hash.each_pair { |section_name, class_name| section(section_name, class_name) }
end

.selectlist(element_name, locator) ⇒ Object

Declare and instantiate a single selectlist UI Element for this screen section object.

Examples:

selectlist :convert_list, { xpath: '//XCUIElementTypePopUpButton[@label="convert"]' }

Parameters:

  • element_name (Symbol)

    name of selectlist object (as a symbol)

  • locator (Hash)

    { locator_strategy: locator_identifier }



280
281
282
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 280

def self.selectlist(element_name, locator)
  define_section_element(element_name, TestCentricity::AppElements::AppSelectList, locator)
end

.selectlists(element_hash) ⇒ Object

Declare and instantiate a collection of selectlists for this screen section object.

Examples:

selectlists convert_list: { xpath: '//XCUIElementTypePopUpButton[@label="convert"]' },
            from_list:    { xpath: '//XCUIElementTypePopUpButton[@label="convert_from"]' }

Parameters:

  • element_hash (Hash)

    names of selectlists (as symbol) and locator Hash



291
292
293
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 291

def self.selectlists(element_hash)
  element_hash.each_pair { |element_name, locator| selectlist(element_name, locator) }
end

.switch(element_name, locator) ⇒ Object

Declare and instantiate a single switch UI Element for this screen section object.

Examples:

switch :debug_mode_switch, { accessibility_id: 'debug mode' }

Parameters:

  • element_name (Symbol)

    name of switch object (as a symbol)

  • locator (Hash)

    { locator_strategy: locator_identifier }



170
171
172
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 170

def self.switch(element_name, locator)
  define_section_element(element_name, TestCentricity::AppElements::AppSwitch, locator)
end

.switches(element_hash) ⇒ Object

Declare and instantiate a collection of switches for this screen section object.

Examples:

switches debug_mode_switch: { accessibility_id: 'debug mode' },
         metrics_switch: { accessibility_id: 'metrics' }

Parameters:

  • element_hash (Hash)

    names of switches (as symbol) and locator Hash



181
182
183
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 181

def self.switches(element_hash)
  element_hash.each_pair { |element_name, locator| switch(element_name, locator) }
end

.table(element_name, locator) ⇒ Object

Declare and instantiate a single table UI Element for this screen section object.

Examples:

table :sidebar_table, { predicate: 'identifier == "library.sidebar"' }

Parameters:

  • element_name (Symbol)

    name of table object (as a symbol)

  • locator (Hash)

    { locator_strategy: locator_identifier }



302
303
304
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 302

def self.table(element_name, locator)
  define_section_element(element_name, TestCentricity::AppElements::AppTable, locator)
end

.tables(element_hash) ⇒ Object

Declare and instantiate a collection of tables for this screen section object.

Examples:

tables sidebar_table: { predicate: 'identifier == "library.sidebar"' },
       view_table:    { predicate: 'identifier == "view.library.table"' }

Parameters:

  • element_hash (Hash)

    names of tables (as symbol) and locator Hash



313
314
315
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 313

def self.tables(element_hash)
  element_hash.each_pair { |element_name, locator| table(element_name, locator) }
end

.textfield(element_name, locator) ⇒ Object

Declare and instantiate a single textfield UI Element for this screen section object.

Examples:

textfield :payee_name_field, { xpath: '//android.widget.EditText[@content-desc="Full Name* input field"]' }
textfield :payee_name_field, { xpath: '//XCUIElementTypeTextField[@name="Full Name* input field"]' }

Parameters:

  • element_name (Symbol)

    name of textfield object (as a symbol)

  • locator (Hash)

    { locator_strategy: locator_identifier }



148
149
150
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 148

def self.textfield(element_name, locator)
  define_section_element(element_name, TestCentricity::AppElements::AppTextField, locator)
end

.textfields(element_hash) ⇒ Object

Declare and instantiate a collection of textfields for this screen section object.

Examples:

textfields username_field: { accessibility_id: 'Username input field' },
           password_field: { accessibility_id: 'Password input field' }

Parameters:

  • element_hash (Hash)

    names of textfields (as symbol) and locator Hash



159
160
161
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 159

def self.textfields(element_hash)
  element_hash.each_pair { |element_name, locator| textfield(element_name, locator) }
end

Instance Method Details

#clickObject

Click on a screen Section object

Examples:

bar_chart_section.click


388
389
390
391
392
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 388

def click
  section = find_section
  section_not_found_exception(section)
  section.click
end

#disabled?Boolean

Is screen Section object disabled (not enabled)?

Examples:

bar_chart_section.disabled?

Returns:

  • (Boolean)


509
510
511
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 509

def disabled?
  !enabled?
end

#double_tapObject

Double-tap on a screen Section object

Examples:

bar_chart_section.double_tap


413
414
415
416
417
418
419
420
421
422
423
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 413

def double_tap
  section = find_section
  section_not_found_exception(section)
  driver.action
        .click_and_hold(section)
        .release
        .pause(duration: 0.2)
        .click_and_hold(section)
        .release
        .perform
end

#enabled?Boolean

Is screen Section object enabled?

Examples:

bar_chart_section.enabled?

Returns:

  • (Boolean)


497
498
499
500
501
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 497

def enabled?
  section = find_section
  section_not_found_exception(section)
  section.enabled?
end

#exists?Boolean

Does screen Section object exists?

Examples:

navigation_toolbar.exists?

Returns:

  • (Boolean)


486
487
488
489
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 486

def exists?
  section = find_section
  section != nil
end

#get_item_countObject



56
57
58
59
60
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 56

def get_item_count
  raise 'No parent list defined' if @parent_list.nil?

  @parent_list.get_item_count
end

#get_list_itemsObject



62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 62

def get_list_items
  items = []
  (1..get_item_count).each do |item|
    set_list_index(nil, item)
    begin
      items.push(get_value)
    rescue
      scroll_into_view(@parent_list.scroll_mode)
      items.push(get_value)
    end
  end
  items
end

#get_locatorObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 19

def get_locator
  my_locator = if @locator.zero? && defined?(section_locator)
                 section_locator
               else
                 @locator
               end
  locators = []
  if @context == :section && !@parent.nil?
    locators = @parent.get_locator
  end

  if @parent_list.nil?
    locators.push(my_locator)
  else
    locators.push(@parent_list.get_locator)
    if @list_index.nil?
      locators.push(my_locator)
    else
      item_objects = @parent_list.item_refs
      if item_objects.nil?
        list_key = my_locator.keys[0]
        list_value = "#{my_locator.values[0]}[#{@list_index}]"
      else
        list_key = :object
        list_value = item_objects[@list_index - 1]
      end
      locators.push( { list_key => list_value } )
    end
  end
  locators
end

#get_nameObject



80
81
82
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 80

def get_name
  @name
end

#get_object_typeObject



76
77
78
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 76

def get_object_type
  :section
end

#heightInteger

Return height of screen Section object.

Examples:

button_height = my_button.height

Returns:

  • (Integer)


650
651
652
653
654
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 650

def height
  section = find_section
  section_not_found_exception(section)
  section.size.height
end

#hidden?Boolean

Is screen Section object hidden (not visible)?

Examples:

navigation_toolbar.hidden?

Returns:

  • (Boolean)


532
533
534
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 532

def hidden?
  !visible?
end

#identifierObject



536
537
538
539
540
541
542
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 536

def identifier
  raise 'identifier is not a supported attribute' unless Environ.is_macos?

  section = find_section
  section_not_found_exception(section)
  section.identifier
end

#long_press(duration = 1) ⇒ Object

Long press on a screen Section object

Examples:

header_image.long_press(1.5)

Parameters:

  • duration (Float) (defaults to: 1)

    duration of long press in seconds



431
432
433
434
435
436
437
438
439
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 431

def long_press(duration = 1)
  section = find_section
  section_not_found_exception(section)
  driver.action
        .click_and_hold(section)
        .pause(duration: duration)
        .release
        .perform
end

#scroll_into_view(scroll_mode = :vertical) ⇒ Object

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

Examples:

carousel_item.scroll_into_view(scroll_mode = :horizontal)

Parameters:

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

    :vertical (default) or :horizontal



448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 448

def scroll_into_view(scroll_mode = :vertical)
  return if visible?

  obj = element
  object_not_found_exception(obj)
  driver.action.move_to(obj).perform
  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?
    swipe_gesture(direction, distance = 0.2)
    try_count -= 1
    if try_count.zero?
      break if direction == end_direction
        
      
        direction = end_direction
        try_count = 8
      
    end
  end
end

#send_keys(value) ⇒ Object

Send keystrokes to this section object.

Examples:

basic_view.send_keys('Lime green')

Parameters:



550
551
552
553
554
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 550

def send_keys(value)
  section = find_section
  section_not_found_exception(section)
  section.send_keys(value)
end

#set_list_index(list, index = 1) ⇒ Object



51
52
53
54
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 51

def set_list_index(list, index = 1)
  @parent_list = list unless list.nil?
  @list_index  = index
end

#set_parent(parent) ⇒ Object



84
85
86
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 84

def set_parent(parent)
  @parent = parent
end

#tapObject

Tap on a screen Section object

Examples:

bar_chart_section.tap


399
400
401
402
403
404
405
406
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 399

def tap
  section = find_section
  section_not_found_exception(section)
  driver.action
        .click_and_hold(section)
        .release
        .perform
end

#visible?Boolean

Is screen Section object visible?

Examples:

navigation_toolbar.visible?

Returns:

  • (Boolean)


519
520
521
522
523
524
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 519

def visible?
  section = find_section
  return false if section.nil?

  section.displayed?
end

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

Wait until the screen Section 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:

navigation_toolbar.wait_until_exists(1.5)

Parameters:

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

    wait time in seconds



563
564
565
566
567
568
569
570
571
572
573
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 563

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 { exists? }
rescue
  if post_exception
    raise "Could not find Section object '#{get_name}' (#{get_locator}) after #{timeout} seconds" unless exists?
  else
    exists?
  end
end

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

Wait until the screen Section 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:

navigation_toolbar.wait_until_gone(5)

Parameters:

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

    wait time in seconds



582
583
584
585
586
587
588
589
590
591
592
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 582

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 { !exists? }
rescue
  if post_exception
    raise "Section object '#{get_name}' (#{get_locator}) remained visible after #{timeout} seconds" if exists?
  else
    exists?
  end
end

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

Wait until the screen Section 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:

navigation_toolbar.wait_until_hidden(2)

Parameters:

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

    wait time in seconds



620
621
622
623
624
625
626
627
628
629
630
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 620

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 { hidden? }
rescue
  if post_exception
    raise "Section object '#{get_name}' (#{get_locator}) remained visible after #{timeout} seconds" if visible?
  else
    visible?
  end
end

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

Wait until the screen Section 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:

navigation_toolbar.wait_until_visible(1.5)

Parameters:

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

    wait time in seconds



601
602
603
604
605
606
607
608
609
610
611
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 601

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 { visible? }
rescue
  if post_exception
    raise "Could not find Section object '#{get_name}' (#{get_locator}) after #{timeout} seconds" unless visible?
  else
    visible?
  end
end

#widthInteger

Return width of screen Section object.

Examples:

button_width = my_button.width

Returns:

  • (Integer)


638
639
640
641
642
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 638

def width
  section = find_section
  section_not_found_exception(section)
  section.size.width
end

#x_locInteger

Return x coordinate of screen Section object's location.

Examples:

button_x = my_button.x_loc

Returns:

  • (Integer)


662
663
664
665
666
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 662

def x_loc
  section = find_section
  section_not_found_exception(section)
  section.location.x
end

#y_locInteger

Return y coordinate of screen Section object's location.

Examples:

button_x = my_button.x_loc

Returns:

  • (Integer)


674
675
676
677
678
# File 'lib/testcentricity_apps/app_core/screen_section.rb', line 674

def y_loc
  section = find_section
  section_not_found_exception(section)
  section.location.y
end