testcentricity_web 1.0.23 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11cac258d557b6572fa4fa209eca4ba13048c7c2
4
- data.tar.gz: c07a7ba2498271b0dedf45354a0fe041349a659c
3
+ metadata.gz: 70b7ed7b77f264766c15a9215ffafd3e62b4a00c
4
+ data.tar.gz: 94ffe57156d1e9e181aaeffaa671cd3a6ac091d7
5
5
  SHA512:
6
- metadata.gz: 4c2df2216b789eafd819b880f2ad66a4e6163e6f0d8aa5e463f6f1fe6f58c75292a1bca44dbc5cbbf83de625d04ce0e05ab04e9273527f8a207f425dc9735306
7
- data.tar.gz: 647c80a4737bf00b0be2d8a855c37d8823acee4152e198da9b40413a306dd73893b5736823662d0504f4db24fef66a70c41b650b246e6a06515431b74d2641cd
6
+ metadata.gz: d230d08d0df3a009df25251f056ed0746cfd68a4775a879e12c4ea0176bf667857a2ac685122bd9202a78a338e95ce5b67e0e5802e904e72bb96c96dc4b9891d
7
+ data.tar.gz: fbd2c61354b850f76523b7ae5371e3b9ff182aaa6249267925b04094c66d4709aac363c95e8c847fda6329f09af44bd5a9b650bf068f3c6e5c425555427007ce
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- TestCentricity (tm) Framework is Copyright (c) 2014-2016, Tony Mrozinski
1
+ TestCentricity Web (tm) Framework is Copyright (c) 2014-2017, Tony Mrozinski
2
2
  All rights reserved.
3
3
 
4
4
 
data/README.md CHANGED
@@ -158,6 +158,7 @@ You define your page's **Traits** as shown below:
158
158
 
159
159
  ### Adding UI Elements to your Page Object
160
160
 
161
+ Web pages are made up of UI elements like text fields, check boxes, combo boxes, radio buttons, tables, lists, buttons, etc.
161
162
  **UI Elements** are added to your **Page Object** class definition as shown below:
162
163
 
163
164
  class LoginPage < TestCentricity::PageObject
@@ -334,6 +335,7 @@ You define your page section's **Traits** as shown below:
334
335
 
335
336
  ### Adding UI Elements to your PageSection Object
336
337
 
338
+ Page sections are typically made up of UI elements like text fields, check boxes, combo boxes, radio buttons, tables, lists, buttons, etc.
337
339
  **UI Elements** are added to your **PageSection** class definition as shown below:
338
340
 
339
341
  class SearchForm < TestCentricity::PageSection
@@ -384,6 +386,121 @@ Once your **Page Object** has been instantiated, you can call its **PageSection*
384
386
 
385
387
 
386
388
 
389
+ ## UI Elements
390
+
391
+ **Page Objects** and **PageSection Objects** are typically made up of **UI Element** like text fields, check boxes, combo boxes, radio buttons,
392
+ tables, lists, buttons, etc. **UI Elements** are declared and instantiated within the class definition of the **Page Object** or **PageSection
393
+ Object** in which they are contained. With TestCentricity Web, all UI elements are based on the **UIElement** class.
394
+
395
+
396
+ ### Declaring and instantiating UI Element
397
+
398
+ Single **UIElement** declarations have the following format:
399
+
400
+ elementType :element Name, locator
401
+
402
+ * The `element name` is the unique name that you will use to refer to the UI element and is specified as a symbol.
403
+ * The `locator` is the CSS or XPath attribute that uniquely and unambiguously identifies the UI element.
404
+
405
+ Multiple **UIElement** declarations for a collection of elements of the same type can be performed by passing a hash table containing the
406
+ names and locators of each individual element.
407
+
408
+ Supported **UI Element** elementTypes and their declarations have the following format:
409
+
410
+ *Single element declarations:*
411
+
412
+ button :button_name, locator
413
+ textfield :field_name, locator
414
+ checkbox :checkbox_name, locator
415
+ radio :radio_button_name, locator
416
+ label :label_name, locator
417
+ link :link_name, locator
418
+ selectlist :select_name, locator
419
+ list :list_name, locator
420
+ table :table_name, locator
421
+ image :image_name, locator
422
+ filefield :filefield_name, locator
423
+
424
+ *Multiple element declarations:*
425
+
426
+ buttons button_1_name: locator,
427
+ button_2_name: locator,
428
+ ...
429
+ button_X_name: locator
430
+ textfields field_1_name: locator,
431
+ field_2_name: locator,
432
+ ...
433
+ field_X_name: locator
434
+ checkboxes check_1_name: locator,
435
+ check_2_name: locator,
436
+ ...
437
+ check_X_name: locator
438
+ radios radio_1_name: locator,
439
+ ...
440
+ radio_X_name: locator
441
+ labels label_1_name: locator,
442
+ ...
443
+ label_X_name: locator
444
+ links link_1_name: locator,
445
+ ...
446
+ link_X_name: locator
447
+ selectlists selectlist_1_name: locator,
448
+ ...
449
+ selectlist_X_name: locator
450
+ lists list_1_name: locator,
451
+ ...
452
+ list_X_name: locator
453
+ tables table_1_name: locator,
454
+ ...
455
+ table_X_name: locator
456
+ images image_1_name: locator,
457
+ ...
458
+ image_X_name: locator
459
+ filefields filefield_1_name: locator,
460
+ ...
461
+ filefield_X_name: locator
462
+
463
+
464
+ Refer to the Class List documentation for the **PageObject** and **PageSection** classes for details on the class methods used for declaring
465
+ and instantiating **UI Elements**. Examples of UI element declarations can be found in the ***Adding UI Elements to your Page Object*** and
466
+ ***Adding UI Elements to your PageSection Object*** sections above.
467
+
468
+
469
+ ### UIElement inherited methods
470
+
471
+ With TestCentricity, all UI elements are based on the **UIElement** class, and inherit the following methods:
472
+
473
+ **Action methods:**
474
+
475
+ element.click
476
+
477
+ element.double_click
478
+ element.right_click
479
+ element.click_at(x, y)
480
+ element.hover
481
+ element.drag_by(right_offset, down_offset)
482
+ element.drag_and_drop(target, right_offset, down_offset)
483
+
484
+ **Object state methods:**
485
+
486
+ element.exists?
487
+ element.visible?
488
+ element.hidden?
489
+ element.enabled?
490
+ element.disabled?
491
+ element.get_value
492
+ element.get_attribute(attrib)
493
+
494
+ **Waiting methods:**
495
+
496
+ element.wait_until_exists(seconds)
497
+ element.wait_until_gone(seconds)
498
+ element.wait_until_visible(seconds)
499
+ element.wait_until_hidden(seconds)
500
+ element.wait_until_value_is(value, seconds)
501
+ element.wait_until_value_changes(seconds)
502
+
503
+
387
504
  ## Instantiating your Page Objects
388
505
 
389
506
  Before you can call the methods in your **Page Objects** and **PageSection Objects**, you must instantiate the **Page Objects** of your
@@ -437,7 +554,11 @@ to be instantiated by **PageManager**:
437
554
  :confirm_purchase_page => PurchaseConfirmationPage,
438
555
  :my_account_page => MyAccountPage,
439
556
  :my_order_history_page => MyOrderHistoryPage,
440
- :my_ship_to_addresses_page => MyShipToAddressesPage
557
+ :my_ship_to_addresses_page => MyShipToAddressesPage,
558
+ :terms_conditions_page => TermsConditionsPage,
559
+ :privacy_policy_page => PrivacyPolicyPage,
560
+ :faqs_page => FAQsPage,
561
+ :contact_us_page => ContactUsPage
441
562
  }
442
563
  end
443
564
  end
@@ -455,9 +576,10 @@ executed:
455
576
  **NOTE:** If you intend to use the **PageManager**, you must define a `page_name` trait for each of the **Page Objects** to be registered.
456
577
 
457
578
 
458
- ### Leveraging the PageManager from Cucumber
459
-
579
+ ### Leveraging the PageManager in your Cucumber tests
460
580
 
581
+ Many Cucumber based automated tests suites include scenarios that verify that web pages are correctly loaded, displayed, or can be
582
+ navigated to by clicking associated links. One such Cucumber navigation scenario is displayed below:
461
583
 
462
584
  Scenario Outline: Verify Home page navigation links
463
585
  Given I am on the Home page
@@ -471,17 +593,63 @@ executed:
471
593
  |Terms & Conditions |
472
594
  |Privacy Policy |
473
595
  |FAQs |
474
- |Refunds & Cancellations |
475
596
  |Contact Us |
476
597
 
598
+ In the above example, the step definitions associated with the 3 steps might be implemented using a page_dispatcher method using a
599
+ `case` statement to parse the `page` parameter as in the example below:
477
600
 
478
- Include the step definitions and code below in a `page_steps.rb` or `generic_steps.rb` file in the `features/step_definitions` folder:
601
+ Given(/^I am on the ([^\"]*) page$/) do |page_name|
602
+ target_page = page_dispatcher(page_name)
603
+ target_page.load_page
604
+ end
605
+
606
+ When(/^I click the ([^\"]*) navigation link$/) do |link_name|
607
+ target_page = page_dispatcher(link_name)
608
+ target_page.navigate_to
609
+ end
610
+
611
+ Then(/^I expect the ([^\"]*) page to be correctly displayed$/) do |page_name|
612
+ target_page = page_dispatcher(page_name)
613
+ target_page.verify_page_exists
614
+ target_page.verify_page_ui
615
+ end
616
+
617
+ # this method takes a page name as a parameter and returns an instance of the associated Page Object
618
+ def page_dispatcher(page_name)
619
+ case page_name
620
+ when 'Registration'
621
+ page = registration_page
622
+ when 'My Account'
623
+ page = my_account_page
624
+ when 'Terms & Conditions'
625
+ page = terms_conditions_page
626
+ when 'Privacy Policy'
627
+ page = privacy_policy_page
628
+ when 'Contact Us'
629
+ page = contact_us_page
630
+ when 'FAQs'
631
+ page = faqs_page
632
+ end
633
+ raise "No page object defined for page named '#{page_name}'" unless page
634
+ page
635
+ end
636
+
637
+
638
+ While this approach may be effective for small web applications with only a few pages (and hence few **Page Objects**), it quickly becomes
639
+ cumbersome to manage if your web application has dozens of **Page Objects** that need to be managed.
640
+
641
+ The **PageManager** class provides a `find_page` method that replaces the cumbersome and difficult to maintain `case` statement used in the
642
+ above example. The **PageManager** `current_page` method allows you to set or get an instance of the currently active Page Object.
643
+
644
+ To use these **PageManager** methods, include the step definitions and code below in a `page_steps.rb` or `generic_steps.rb` file in the
645
+ `features/step_definitions` folder:
479
646
 
480
647
  include TestCentricity
481
648
 
482
649
  Given(/^I am on the ([^\"]*) page$/) do |page_name|
483
650
  target_page = page_dispatcher(page_name)
484
651
  target_page.load_page if target_page
652
+ # let PageManager store instance of current page object
485
653
  PageManager.current_page = target_page
486
654
  end
487
655
 
@@ -493,6 +661,7 @@ Include the step definitions and code below in a `page_steps.rb` or `generic_ste
493
661
  Then(/^I expect to see the ([^\"]*) page$/) do |page_name|
494
662
  target_page = page_dispatcher(page_name)
495
663
  target_page.verify_page_exists if target_page
664
+ # let PageManager store instance of current page object
496
665
  PageManager.current_page = target_page
497
666
  end
498
667
 
@@ -500,10 +669,10 @@ Include the step definitions and code below in a `page_steps.rb` or `generic_ste
500
669
  target_page = page_dispatcher(page_name)
501
670
  target_page.verify_page_exists
502
671
  target_page.verify_page_ui
672
+ # let PageManager store instance of current page object
503
673
  PageManager.current_page = target_page
504
674
  end
505
675
 
506
-
507
676
  # this method takes a page name as a parameter and returns an instance of the associated Page Object
508
677
  def page_dispatcher(page_name)
509
678
  page = PageManager.find_page(page_name)
@@ -512,7 +681,6 @@ Include the step definitions and code below in a `page_steps.rb` or `generic_ste
512
681
  end
513
682
 
514
683
 
515
-
516
684
  ## Connecting to a Web Browser
517
685
 
518
686
  The `TestCentricity::WebDriverConnect.initialize_web_driver` method configures the appropriate selenium-webdriver capabilities required to establish a
@@ -1140,7 +1308,7 @@ landscape orientation running on the BrowserStack service:
1140
1308
 
1141
1309
  ## Copyright and License
1142
1310
 
1143
- TestCentricity™ Framework is Copyright (c) 2014-2016, Tony Mrozinski.
1311
+ TestCentricity™ Framework is Copyright (c) 2014-2017, Tony Mrozinski.
1144
1312
  All rights reserved.
1145
1313
 
1146
1314
 
@@ -272,6 +272,12 @@ module TestCentricity
272
272
  class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::FileField.new("#{element_name}", self, "#{locator}", :page);end))
273
273
  end
274
274
 
275
+ def self.filefields(element_hash)
276
+ element_hash.each do |element_name, locator|
277
+ filefield(element_name, locator)
278
+ end
279
+ end
280
+
275
281
  # Declare and instantiate a cell button in a table column on this page object.
276
282
  #
277
283
  # @param element_name [Symbol] name of cell button object (as a symbol)
@@ -281,6 +281,12 @@ module TestCentricity
281
281
  class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::FileField.new("#{element_name}", self, "#{locator}", :section);end))
282
282
  end
283
283
 
284
+ def self.filefields(element_hash)
285
+ element_hash.each do |element_name, locator|
286
+ filefield(element_name, locator)
287
+ end
288
+ end
289
+
284
290
  # Declare and instantiate a cell button in a table column on this page section.
285
291
  #
286
292
  # @param element_name [Symbol] name of cell button object (as a symbol)
@@ -1,3 +1,3 @@
1
1
  module TestCentricityWeb
2
- VERSION = '1.0.23'
2
+ VERSION = '2.0.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testcentricity_web
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.23
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - A.J. Mrozinski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-09 00:00:00.000000000 Z
11
+ date: 2017-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler