Hello,
 
I’m running into a problem I think is a probably a programming error in my part.
 
Here is what I’m trying to accomplish: I have script with 2800 lines of code. My test cases in the script have many repeatable steps. For each test case, I’m basically coding the same steps over an over again and thus I get hundreds of lines of code.
 
My first inclination was to break out the test and make them into separate files so that the script is not so big and less error prone. But I would be doing the same thing as I was doing earlier except now I would have to maintain many files rather one.
 
So what I want to do is create a method that contains the repeatable steps that are used in every test case and call the method when I need to execute the steps. The method would live in separate file. Sounds easy, right?  Well, when I try to a get this error:
 
1) Error:
test_steps(AccountManagementSteps):
NoMethodError: undefined method `link' for nil:NilClass
    ./negative_tierI_steps.rb:37:in `test_steps'
 
  2) Error:
test_01_account_management(TC_Negative):
ArgumentError: wrong number of arguments (0 for 1)
    C:/automation/src/thdf/projects/core/testharness/fixtures/admin_administration/tc_tierI_negative_tests.rb:67:in `initialize'
    C:/automation/src/thdf/projects/core/testharness/fixtures/admin_administration/tc_tierI_negative_tests.rb:67:in `new'
    C:/automation/src/thdf/projects/core/testharness/fixtures/admin_administration/tc_tierI_negative_tests.rb:67:in `test_01_account_management'

Here is the code. The method I’m calling is called AccountManagementSteps. Require 'setup' halls my require statements including so I know the script has the proper require statements. require 'negative_tierI_steps.rb' contains the steps that are given me the problem.
 
 
require 'setup'
require 'negative_tierI_steps.rb'
 
TOPDIR = File.join(File.dirname(__FILE__), '..')
$LOAD_PATH.unshift TOPDIR
 
 
class TC_Negative < Test::Unit::TestCase
 
    def test_01_account_management
    puts ''; puts '';
    puts "############ Starting Test Class: TC_tierI_negative_tests   ############";
    puts ''
    puts 'Executing test 01 - Account Management Access'
    puts ''
              @login = Login.new($user, $password, $url, $submit_key);
               # create a random Admin user name
               @random_name = UserRandomName.new();
               $username = @random_name.User();
               # Create a new Admin User
               @admin_user = CreateUser.new($username);
               # Verify that user was created
               assert($ie.contains_text($save_msg));
    @login.logout("admin");
             assert($ie.contains_text($logoff_msg));
            @login.shutdown();                       
# Login as superuser
                        @login = Login.new($user, $password, $url, $submit_key);
                        @group_details = 0
    set_group = SetPermission.new()
    set_group.fSteps(@group_details);
                          assert($ie.contains_text($save_msg));
                        @login.logout("admin");
                          assert($ie.contains_text($logoff_msg));
                        @login.shutdown();
                        @login = Login.new($username, $password, $url, $submit_key);
    @steps = AccountManagementSteps.new()
    @steps.test_steps()
   end
 
This is the code in the method I’m calling.
 
require 'setup'
require 'watir'
require 'test/unit'
require 'test/unit/ui/console/testrunner'
require 'watir/testUnitAddons'
 
class AccountManagementSteps < Test::Unit::TestCase
 
  def initialize()
  end
 
&nbs! p; def test_steps()
    $ie.link(:text, "Account management").click();
                          assert($ie.contains_text("Manage Accounts"));
    $ie.link(:text, "Manage settings").click();
                          assert($ie.contains_text($no_autho_msg));
    $ie.link(:text, "Manage affiliates").click();
                          assert($ie.contains_text($no_autho_msg));
    $ie.link(:text, "Admin authentication").click();
    $ie.link(:text, "AAUT").click();
      assert($ie.contains_text($no_autho_msg));         
    $ie.link(:text, "Payment processing").click();
                          assert($ie.contains_text($no_autho_msg));
    $ie.link(:text, "Promotions").click();
    $ie.link(:text, "Create New Promotion").click();
                          assert($ie.contains_text($no_autho_msg));
    $ie.link(:text, "Content keys").click();
                          assert($ie.contains_text($no_autho_msg));
    $ie.link(:text, "Pay Model").click();
    table = $ie.table(:index, 9)
    #table.flash
    sleep 1
    table[1][5].image(:name, "updatetop").click
      assert($ie.contains_text($no_permission_msg))
    $ie.link(:text, "Game Library").click();
    table = $ie.table(:index, 9)
    sleep 1
    table[1][3].image(:name, "updatetop").click
      assert($ie.contains_text($no_permission_msg))
    $ie.link(:text, "Game Settings").click();
      assert($ie.contains_text($no_autho_msg));
    $ie.link(:text, "Game Menu Tabs").click();
    table = $ie.table(:index, 9)
    sleep 1
    table[1][3].image(:name, "updatetop").click
      assert($ie.contains_text($no_permission_msg))
    $ie.link(:text, "Community Games").click();
    #table = $ie.table(:index, 9)
    #sleep 1
    #table[1][3].image(:name, "updatetop").click
      #assert($ie.contains_text($no_permission_msg))
    $ie.link(:text, "Community User Migration").click();
    # No update button available. Need to figure out how to assert false for no buttons
    $ie.link(:text, "Community User Upload").click();
    # Need address attaching files
    #$ie.link(:text, "Community Management").click();
    #$ie.text_field(:name, "newCommunity").set("Test")
    #table = $ie.table(:index, 10)
    #sleep 1
    #table[1][3].image(:name, "form_top_singl_create").click
      #assert($ie.contains_text($no_permission_msg))
    $ie.link(:text, "Jackpot List").click();
    # Jackpot lists allowed - research test case
    $ie.link(:text, "Jackpot Details").click();
    table = $ie.table(:index, 9)
    sleep 1
    table[1][3].image(:name, "updatetop").click
      assert($ie.contains_text($no_permission_msg))
    $ie.link(:text, "Jackpot Adjustments").click();
    $ie.text_field(:name, "AdjustAmt").set("1000")
    $ie.text_field(:name, "ReasonText").set("This is a test")
    table = $ie.table(:index, 19)
    sleep 1
    table[1][3].image(:name, "createbottom").click
      assert($ie.contains_text($no_permission_msg))
    $ie.link(:text, "Settings").click();
    table = $ie.table(:index, 9)
  &n! bsp; sleep 1
    table[1][3].image(:name, "updatetop").click
      assert($ie.contains_text($no_permission_msg))
    $ie.link(:text, "Game Points").click();
    table = $ie.table(:index, 9)
    sleep 1
    table[1][3].image(:name, "updatetop").click
      assert($ie.contains_text($no_permission_msg))
    $ie.link(:text, "Customer Search").click();
    # User allowed ! to make Customer Search
    $ie.link(:text, "Tournament List").click();
    table = $ie.table(:index, 9)
    sleep 1
    table[1][3].image(:name, "updatetop").click
!       assert($ie.contains_text($no_permission_msg))
    $ie.link(:text, "Real Time List").click();
    # Page is not displayed - Research test case
    $ie.link(:text, "Post Hoc Online").click();
    # Page is not displayed - Research test case
    $ie.link(:text, "Post Hoc Offline").click();
    # Page is not displayed - Research test case
    $ie.link(:text, "User Transaction Search").click();
    $ie.text_field(:name, "username").set("Joe Tester")
    table = $ie.table(:index, 9)
    sleep 1
    table[1][3].image(:name, "updatetop").click
      assert($ie.contains_text($no_permission_msg))
    $ie.link(:text, "Action Score").click();
    table = $ie.table(:index, 9)
    sleep 1
    table[1][3].image(:name, "updatetop").click
      assert($ie.contains_text($no_permission_msg))
    $ie.link(:text, "Group Weights").click();
    table = $ie.table(:index, 9)
    sleep 1
    table[1][3].image(:name, "updatetop").click
      assert($ie.contains_text($no_permission_msg))
    $ie.link(:text, "Results Score").click();
    table = $ie.table(:index, 9)
    sleep 1
    table[1][3].image(:name, "updatetop").click
      assert($ie.contains_text($no_permission_msg))
    $ie.link(:text, "Countries in Juris.").click();
    $ie.link(:url, "_javascript_:submit_form('ADMINJurCountriesUpdate','1','select')").click();
       assert($ie.contains_text($no_permission_msg))
    $ie.link(:text, "Groups in Juris.").click();
    table = $ie.table(:index, 9)
    sleep 1
    table[1][3].image(:name, "updatetop").click
      assert($ie.contains_text($no_permission_msg))
    $ie.link(:text, "DSPs in Group").click();
    table = $ie.table(:index, 9)
    sleep 1
    table[1][3].image(:name, "updatetop").click
      assert($ie.contains_text($no_permission_msg))
    $ie.link(:text, "DSPs in Country/group").click();
    $ie.text_field(:name, "VendorPriority0").set("88")
    $ie.checkbox(:name, "CurrentMember0").set
    table = $ie.table(:index, 9)
    sleep 1
    table[1][3].image(:name, "updatetop").click
      assert($ie.contains_text($no_permission_msg))
    $ie.link(:text, "Search MVF Users").click();
    $ie.select_list( :name , "country").select("United Kingdom");
    table = $ie.table(:index, 9)
    sleep 1
    table[1][3].image(:name, "searchtop").click
      assert($ie.contains_text($no_permission_msg))
 end
end
 
Any ideas?
 
Thanks
David
 
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to