What is a Module on Ruby ?

Hello guys, I will summarise this post because there are many examples and methods that you can learn. So, today I will talk about more technical questions. What is and when you can use module on Ruby.

WHAT IS ?

Module is a collection of methods and constants. The methods in a module may be instance methods or module methods. Instance methods appear as methods in a class when the module is included, module methods do not. Conversely, module methods may be called without creating an encapsulating object, while instance methods may not. (See below, module_function)

USING PARAMETERS

Once a module is written, its global entities (i.e., global PARAMETERs, global variables and internal functions) can be made available to other modules and programs. The program or module that wants to use a particular module must have a USE statement at its very beginning. The USE statement has one of the following forms:

SYNTAX

The following form is the syntax of a module:

USE  module-name

USE  module-name, ONLY: name-1, name-2, ..., name-n

Here is the meaning of these USEs:

  • The first indicates that the current program or module wants to use the module whose name is module-name. For example, the following main program indicates that it wants to use the content of module SomeConstants:
    PROGRAM  MainProgram
       USE   SomeConstants
       IMPLICIT  NONE
       ..........
    END PROGRAM  MainProgram
    

    Once a USE is specified in a program or in a module, every global entities of that used module (i.e.PARAMETERs, variables, and internal functions) becomes available to this program or this module. For example, if module SomeConstants is:

    MODULE  SomeConstants
       IMPLICIT  NONE
       REAL, PARAMETER :: PI = 3.1415926
       REAL, PARAMETER :: g = 980
       INTEGER         :: Counter
    END MODULE  SomeConstants
    

    Then, program MainProgram can access to PARAMETERPI and g and variable Counter.

  • However, under many circumstances, a program or a module does not want to use everything of the used module. For example, if program MainProgram only wants to use PARAMETER PIand variable Counter and does not want to use g, then the second form becomes very useful. In this case, one should add the keyword ONLY followed by a colon :, followed by a list of names that the current program or module wants to use.
    PROGRAM  MainProgram
       USE   SomeConstants, ONLY: PI, Counter
       IMPLICIT  NONE
       ..........
    END PROGRAM  MainProgram
    

    Thus, MainProgram can use PI and Counter of module SomeConstants; but, MainProgram cannot use g!USE with ONLY: is very handy, because it could only “import” those important and vital information and “ignore” those un-wanted ones.

  • There is a third, not recommended form, that can help to rename the names of a module locally. If a module has a name abc, in a program with a USE, one can use a new name for abc. The way of writing this renaming is the following:
    new-name => name-in-module
    

    For example, if one wants to give a new name to Counter of module SomeConstants, one should write:

    NewCounter => Counter
    

    Thus, in a program, whenever it uses MyCounter, this program is actually using Counter of module SomeConstants.This kind of renaming can be used with ONLY: or without ONLY:.

    PROGRAM  MainProgram
       USE   SomeConstants, ONLY: PI, MyCounter => Counter
       IMPLICIT  NONE
       ..........
    END PROGRAM  MainProgram
    

    The above example wants to use PI of module SomeConstants. In this case, when program MainProgram uses PI, it actually uses the PI of module SomeConstants. Program MainProgramalso uses Counter of module SomeConstants; but, in this case, since there is a renaming, when MainProgram uses MyCounter it actually uses Counter of module SomeConstants.Renaming does not require ONLY:. In the following, MainProgram can use all contents of module SomeConstants. When MainProgram uses PI and g, it uses the PI and g of module SomeConstants; however, when MainProgram uses MyCounter, it actually uses Counter of module SomeConstants.

    PROGRAM  MainProgram
       USE   SomeConstants, MyCounter => Counter
       IMPLICIT  NONE
       ..........
    END PROGRAM  MainProgram
    

    Why do we need renaming? It is simple. In your program, you may have a variable whose name is identical to an entity of a module that is being USEed. In this case, renaming the variable name would clear the ambiguity.

    PROGRAM  MainProgram
       USE   SomeConstants, GravityConstant => g
       IMPLICIT  NONE
       INTEGER :: e, f, g
       ..........
    END PROGRAM  MainProgram
    

    In the above example, since MainProgram has a variable called g, which is the same as PARAMETER g in module SomeConstants. By renaming g of SomeConstantsMainProgram can use variable g for the variable and GravityConstant for the PARAMETER g in module SomeConstants.

However, renaming is not a recommended feature. You should avoid using it whenever possible.

EXAMPLES

module Mod

  include Math
  CONST = 1
  def meth
    #  ...
  end
end
Mod.class              #=> Module
Mod.constants          #=> [:CONST, :PI, :E]
Mod.instance_methods   #=> [:meth]

 

Public Class Methods

I will write two examples, but if you click in the link below (Fonts), you can see a lot of other examples of modules used on Ruby.

new → mod
new {|mod| block } → mod

Creates a new anonymous module. If a block is given, it is passed the module object, and the block is evaluated in the context of this module using module_eval.

fred = Module.new do
  def meth1
    "hello"
  end
  def meth2
    "bye"
  end
end
a = "my string"
a.extend(fred)   #=> "my string"
a.meth1          #=> "hello"
a.meth2          #=> "bye"

 

Assign the module to a constant (name starting uppercase) if you want to treat it like a regular module.

static VALUE
rb_mod_initialize(VALUE module)
{
    if (rb_block_given_p()) {
        rb_mod_module_exec(1, &module, module);
    }
    return Qnil;
}
module_function(string, …) → self

Creates module functions for the named methods. These functions may be called with the module as a receiver, and also become available as instance methods to classes that mix in the module. Module functions are copies of the original, and so may be changed independently. The instance-method versions are made private. If used with no arguments, subsequently defined methods become module functions. String arguments are converted to symbols.

module Mod
  def one
    "This is one"
  end
  module_function :one
end
class Cls
  include Mod
  def call_one
    one
  end
end
Mod.one     #=> "This is one"
c = Cls.new
c.call_one  #=> "This is one"
module Mod
  def one
    "This is the new one"
  end
end
Mod.one     #=> "This is one"
c.call_one  #=> "This is the new one"

               static VALUE
rb_mod_modfunc(int argc, VALUE *argv, VALUE module)
{
    int i;
    ID id;
    const rb_method_entry_t *me;

    if (!RB_TYPE_P(module, T_MODULE)) {
        rb_raise(rb_eTypeError, "module_function must be called for modules");
    }

    if (argc == 0) {
        SCOPE_SET(NOEX_MODFUNC);
        return module;
    }

    set_method_visibility(module, argc, argv, NOEX_PRIVATE);

    for (i = 0; i < argc; i++) {
        VALUE m = module;

        id = rb_to_id(argv[i]);
        for (;;) {
            me = search_method(m, id, 0);
            if (me == 0) {
                me = search_method(rb_cObject, id, 0);
            }
            if (UNDEFINED_METHOD_ENTRY_P(me)) {
                rb_print_undef(module, id, 0);
            }
            if (me->def->type != VM_METHOD_TYPE_ZSUPER) {
                break; /* normal case: need not to follow 'super' link */
            }
            m = RCLASS_SUPER(m);
            if (!m)
                break;
        }
        rb_method_entry_set(rb_singleton_class(module), id, me, NOEX_PUBLIC);
    }
    return module;
}
            


Guys, if you have any question, suggestion or complaint (I hope this last you don’t have) just write in the comments. Bye 🙂


 

Fonts: http://www.ruby-doc.org/core-2.1.2/Module.html

http://www.cs.mtu.edu/~shene/COURSES/cs201/NOTES/chap06/mod-use.html

How To Optimize Regression Test Suite Effectively

Hi guys, I read a article about Optimize Regression Tests and for this reason I will summarize with my words what you can do more effectively with Regression Tests. According to different surveys, more than 70% of software work relates to application maintenance and improvement. This means that you will have a lot of work updating your regression test code and also keeping focus on the newer application functionality on the same time.

regression testing, optimize regression test suitesThere are a few factors that affect the effectiveness of the regression test suites. So, how to maintain the effectiveness of the regression test suite, or optimize regression test suite effectively?

  • RTS – Regression Test Selection is one of the most popular methods for test case suite optimization. Divide the test suite into reusable test cases, retestable test cases and obsolete test cases. Apart from all these, it also creates new test cases that test the program for areas not covered in current test cases.
  • TRACK MECHANISM – The effectiveness of the regression test suite can be easily maintained by monitoring the changes to the test suite. A clearly outlined process will ensure that only tests that are useful to the entire testing strategy get added to the test suite, which ensures the efficiency and usability of the test harness at a high level.
  • PERIODIC CLEANUP – Considering periodic cleanup of old tests, all the existing tests in the test suite need to be analyzed for their effectiveness in a specific scenario. In such cases, the relevant regression test suites should also be eased out. It will ensure robustness of the regression test suite for a long period of time. You can also measure the effectiveness of regression test suites on a release-to-release basis. It will allow you to know the root cause for reduction in the effectiveness of the test harness if any, and enable you to take appropriate action on the same.
  • METRICS ANALYSIS – Collection of some metrics and their analysis could also be useful when it comes to the effectiveness of the regression test suite. You can consider different metrics such as percentage of defects found by the regression tests suite, their importance, etc.

You can consider optimization of tests when the tests get lengthy or huge, evaluate different regression test selection strategies and plan and explore changes in the regression test suite framework in order to maintain the effectiveness of the regression test suite.

If you have another method, tell to us commenting below.

Thank you again 🙂

Referenceshttp://intersog.com/blog/How-To-Optimize-Regression-Test-Suite-Effectively

How to run Selenium Headless Browser in Ubuntu ?

Hello again !!!

Today I will post a tutorial about how configure and run selenium headless in Ubuntu using Mozilla Firefox as your primary browser.

Install Firefox headless in Ubuntu

Download the latest version of Firefox on your PC. In case you don’t have firefox or using older version of firefox, follow the steps to upgrade firefox.

  • In /etc/apt/sources.list add the following line.
	ppa:mozillateam/firefox-stable
  • Run the following commands to upgrade or install latest version of Firefox to work with Selenium.
	sudo apt-get update
	sudo apt-get install firefox

Install Xvfb – the X Virtual FrameBuffer

This piece of software emulates the framebuffer using virtual memory which lets you run X-Server in machines with no display devices. This service is required to make browsers run normally by making them believe there is a display available. To install xvfb in ubuntu or Debian, run the following command:

sudo apt-get install xvfb

Now run the xvfb service in a display number which is less likely to clash even if you add a display at later stage. For this example, you can assume a display, 10.

sudo Xvfb :10 -ac

The parameter -ac makes xvfb run with access control off. The server should be running now.

Start browser headlessly in Ubuntu

Before you can run a browser, you need to set the environment variable DISPLAY with the display number at which xvfb is running. Before we add the environmental variable as a persistent one, let us check whether everything works as expected.

export DISPLAY=:10
firefox

If there was no error on the terminal, then you have successfully running firefox headlessly in Ubuntu. The command should keep running until you kill the process by pressing ctrl+ C or similar. There wont be any output.

Now that you have a browser running headless in Ubuntu server, you can run selenium server as you will run in your local machine.

Easy, don’t you think ? If you have any questions, just write below !

Thank you ! Have a good weekend !

 

Fonts: http://www.installationpage.com/selenium/how-to-run-selenium-headless-firefox-in-ubuntu/

Using DOM on Selenium

Hello guys, today I will post about DOM, what is and where you will use on Automation.

What is the Document Object Model?

The Document Object Model is a platform- and language-neutral interface that will allow programs and scripts to dynamically access and update the content, structure and style of documents. The document can be further processed and the results of that processing can be incorporated back into the presented page. 

Why the Document Object Model?

“Dynamic HTML” is a term used by some vendors to describe the combination of HTML, style sheets and scripts that allows documents to be animated.
DOM lookups in a view
Let’s look at some example code. The first thing you can do is to create a container class called LoginContainer. This class is used to find the DOM elements of the Login View. For the DOM lookup, you can use the @FindBy annotation, which takes parameters specifying what to find. In Listing 10, we use the How parameter for the lookup and using as the lookup variable. How options include CSS, ID, and XPATH.

Listing 10. LoginContainer with DOM lookups on Ruby, Cucumber and Selenium

	@FindBy(how = How.ID, using = "LoginPage")
	public WebElement loginPageDiv;
	
	@FindBy(how = How.CSS, using = "#LoginPage input[name=username]")
	public WebElement usernameInput;
	
	@FindBy(how = How.CSS, using = "#LoginPage input[name=password]")
	public WebElement passwordInput;
	
	@FindBy(how = How.CSS, using = "#LoginPage span[role='button']")
	public WebElement submitButton;

A more generically class on Java and Selenium to Find a Element

public void FindElement(Parameters_Config configParam, String idName, 
String findBy) throws IOException, Exception {
        switch (findBy) {

            case "linkText":
                try {
                    configParam.driver.findElement(By.linkText(idName));
                } catch (Exception e) {
                    System.out.println(e.getMessage());
                }
                break;

            case "className":
                try {
                    configParam.driver.findElement(By.className(idName));
                } catch (Exception e) {
                    System.out.println(e.getMessage());
                }
                break;

            case "id":
                try {
                    configParam.driver.findElement(By.id(idName));
                } catch (Exception e) {
                    System.out.println(e.getMessage());
                }
                break;

            case "cssSelector":
                try {
                    configParam.driver.findElement(By.cssSelector(idName));
                } catch (Exception e) {
                    System.out.println(e.getMessage());
                }
                break;

            case "tagName":
                try {
                    configParam.driver.findElement(By.tagName(idName));
                } catch (Exception e) {
                    System.out.println(e.getMessage());
                }
                break;

            case "xpath":
                try {
                    configParam.driver.findElement(By.xpath(idName));
                } catch (Exception e) {
                    System.out.println(e.getMessage());
                }
                break;

            default:
                Exception e = new Exception();
                System.out.println(e.getMessage());
                break;
        }
    } 

Thank you 🙂

Font: http://www.w3.org/DOM/

Commands to use running Cucumber

Hi guys, I am writing here the commands to use when you run cucumber on Automation. It is very usefully 🙂

Launching and Customizing launch

Calabash has two ways of launching apps: SimLauncher and Apple’s instruments tool. Each has its own advantages and problems (see below).

For iOS7+ only the instruments launch method is supported. If instruments is not used to automatically launch the app touch events wont work.

Since version 0.9.154, Calabash is using instruments and UIAutomation to launch apps by default. The primary reason for this is two-fold: (a) in iOS7, Apple removed access to APIs previously used to synthesize touch events and we needed a different approach, (b) there are things possible with UIA that are not possible from “inside the app”, i.e., in the Calabash server (like accepting the Access to current location dialog or sending the app to the background).

The launch method can be controlled using environment variables. With Calabash 0.9.157+, the use of environment variables was greatly simplified. If you’re updating from a previous version, it is recommended to try removing all the environment variables, and then adding only the ones you’re sure you need.

  • DEVICE_TARGET controls which device to launch on. When set Calabash uses instruments to launch. The default is ‘simulator’ (see also Testing on Physical iDevices). You can also setDEVICE_TARGET=device or DEVICE_TARGET=UDID_OF_CONNECTED_DEVICE to pick a specific connected device, or DEVICE_TARGET=simulator to force use of instruments and simulator. (You can see the UDID of your device in the Devices tab in Xcode’s Organizer window).
  • SDK_VERSION is only used when running on the simulator. It controls which iOS version of the simulator is launched. Note, SDK_VERSION forces the launch method to be SimLauncher (not instruments). The reason for this is that the instruments tool does not support launching a simulator that is not the latest version.
  • DEVICE=ipad if you want to ensure we launch the iPad simulator. Defaults to ‘iphone’.
  • OS is deprecated and now automatically detected (it was previously used to decide which “recordings” to use for playback).
  • NO_LAUNCH is not supported when running with instruments. It tells Calabash to not automatically launch the app (it is mostly used when you want to start the app yourself – should rarely be used).
  • NO_STOP means don’t stop the app after the test completes. (It is mostly used to leave the app open in case of a test failure and should be used for debugging purposes only).
  • RESET_BETWEEN_SCENARIOS (example: RESET_BETWEEN_SCENARIOS=1) – Reset iOS Simulator between each scenario.

EG.

$ SDK_VERSION=6.1 DEVICE=ipad cucumber 

Explore interactively!

To start-up a console, you can run the command: calabash-ios console and then start a simulator withstart_test_server_in_background for iOS7 to get touch events to work.

Try starting your app using the -cal scheme from Xcode and then run calabash-ios console. This will give you a Calabash console (it is just a Ruby irb with calabash loaded).

From this console you can explore your application interactively.

You can query, touch, scroll, etc from the irb session. This information below also serves as an introduction for the APIs that are available in other place.

Query

If your app have two buttons. Try this from the console:

irb > query("button") 

You should see something like this:

=> [{"class"=>"UIRoundedRectButton", frame"=>
{"y"=>287, "width"=>72, "x"=>100, 
"height"=>37}, "UIType"=>"UIControl", 
"description"=>"<UIRoundedRectButton: 0x7d463d0; 
frame = (100 287; 72 37); opaque = NO; autoresize = RM+BM;
 layer = <CALayer: 0x7d46ae0>>"}, 
{"class"=>"UIRoundedRectButton", "frame"=>
{"y"=>215, "width"=>73, "x"=>109, 
"height"=>37}, "UIType"=>"UIControl", 
"description"=>"<UIRoundedRectButton: 0x7d3a760; 
frame = (109 215; 73 37); opaque = NO; autoresize = RM+BM;
 layer = <CALayer: 0x7d3a8a0>>"}] 

This is actually an array with two objects that are descriptions of the two buttons. For example, the class of the first button is “UIRoundedRectButton”. We can dive into this information using Ruby programming:

irb > result = query("button") ... irb > btn1 = 
result[0] ... irb > class1 = btn1["class"] => 
"UIRoundedRectButton" 

The query function takes a string query as an argument. The query argument is similar to a css selector, for example we can do:

irb > query("button index:0 label") => 
[{"class"=>"UIButtonLabel", "frame"=>{"y"=>9, 
"width"=>38, "x"=>17, "height"=>19}, "UIType"=>"UIView", 
"description"=>"<UIButtonLabel: 0x7d41120; frame = 
(17 9; 38 19); text = 'other'; clipsToBounds = YES; opaque 
= NO; userInteractionEnabled = NO; layer = <CALayer: 
0x7d40510>>"}] 

This means “find the first button, and then inside of that find all labels”.

Query may also take parameters that are mapped to Objective-C selectors on the found object.

irb > query("button index:0 label", :text) => 
["other"] 

Query is very powerful, but the full syntax and power of query is beyond the scope of the Getting started guide on GitHub.

Touch

Anything that can be found using query can also be touched. Try this while you watch the iOS Simulator:

irb > touch("button index:0") 

Notice that the button is touched (turns blue), although this button doesn’t do anything.

You can also touch the tab bars:

irb > touch("tabBarButton index:1") 

The filter: index:1 means that it is the second tab-bar button that should be touched.

Setting accessibility

Identifiers and accessibility

Labels

In general UI views are found using accessibility ids or labels. Go to the “First” tab in simulator, and then in your console session try this:

# query for the switch on the "First" tab irb > 
query("view marked:'switch'") [ [0] { "class" => 
"UISwitch", "frame" => { "y" => 148, "width" => 
79, "x" => 106, "height" => 27 }, "UIType" => 
"UIControl", "description" => "<UISwitch: 0x7d3ffb0; 
frame = (106 148; 79 27); <snip> >>" } ] 

You can set the accessibility attributes of UIView from the Interface Builder or programmatically.

In some cases the UIKit framework will set the accessibilityLabel for you if you don’t explicitly set the value.

For example, UITabBarButton will have an accessibility label that is the same as title of the tab bar button.

irb > query("tabBarButton marked:'Second'") [ [0] {
 "class" => "UITabBarButton", "id" => nil, "rect" 
=> { "center_x" => 120, "y" => 520, "width" =>
 76, "x" => 82, "center_y" => 544, "height" => 48 
}, "frame" => { "y" => 1, "width" => 76, "x" =>
 82, "height" => 48 }, "label" => "Second", 
"description" => "<UITabBarButton: 0x857e010; frame = 
(82 1; 76 48); <snip> >" } ] 

Whenever possible, you should use the accessibilityIdentifier of UIView and reserve the accessibilityLabel for providing localized Accessibility traits.

- (void) viewDidLoad { [super viewDidLoad]; UISwitch 
*switch = self.wantsCoffeeSwitch; # ex. queries # query 
"view marked:'wants coffee'" # query "switch 
{accessibilityIdentifier LIKE 'wants coffee'}" # query 
"switch marked:'wants coffee'" 
switch.accessibilityIdentifier = @"wants coffee"; # 
accessibilityLabels should be localized and follow the 
conventions # described by Apple's Accessibility 
documentation if (switch.isOn == YES) { 
switch.accessibilityLabel = NSLocalizedString(@"Wants 
coffee"); } else { switch.accessibilityLabel = 
NSLocalizedString(@"Does not want coffee"); } } 

 

Thank you guys ! If you have any question, just write below. Bye !!
Fonts: https://github.com/calabash/calabash-ios/wiki/01-Getting-started-guide

TestComplete 10.1 Released with Real-Device Support for iOS

Hello guys, I will put today a post about automation tests with TestComplete on mobile apps. I used to work with Cucumber and Calabash, but if you want to try another tool, this is very used too.

The new TestComplete 10.1 release now supports real-device test automation for iOS applications so you can rest assured that your mobile apps are of the highest quality. In the recent SmartBear study, State of Mobile Testing 2014, 21% of those surveyed told us that app quality was the greatest challenge for success in mobile.

Image

Efficient mobile application testing results in higher quality applications. With a good test automation tool in your toolbox, you can automate tasks like data-driven testing, authentication testing, and functional checks, so your team can focus on more time-intensive application testing that require human interaction.

So what does the new release of TestComplete bring to iOS mobile testing?

  • Real-Device Testing for iOS versions 6 and 7
  • Object Recognition for iOS Applications
  • Multi-Device Testing
  • Device Pools

Native Application Testing

The new release supports testing of native iOS applications without the need to root your devices, including keyword and scripted tests. By using the new Mobile Screen, which replicates your application on your desktop computer as you test, with our Object Browser, you can easily make the connection between screen elements and their associated objects in the code.

Image

Object Recognition

TestComplete 10.1 has full object recognition of tested iOS applications, including object parameters for low-level testing. Use the Name Mapping feature to label objects like grids, buttons, and layers within your mobile app so you can easily identify them in both tests and test results.

By relying on object recognition, your tests are immune to GUI-level changes during the development cycle that can occur when an automation tool relies solely on screen elements.

Image

Multi-Device Testing

By leveraging our object recognition and common controls technology, TestComplete 10.1 ensures that your automated tests are compatible with any Apple device running iOS 6 or 7. This means you can create a test once and run that same test on all of your devices, regardless of screen resolution or aspect ratio.

TestComplete 10.1 also includes a device pool feature that allows you to manage all of the devices in your testing pool. You can start and stop tests on any device from this central pool, allowing you the ultimate flexibility in how, where and when your automated tests run.

This isn’t a free software, but you can try for 30 days.

Bye guys ! This is the other tool very known in the automation market.

Fonts: http://blog.smartbear.com/test-automation/testcomplete-10-1-released-with-real-device-support-for-ios/

Data Driven with Selenium IDE

Ok, I really don’t like of Selenium IDE for many reasons, but today I will show one way to use Data Driven with its. This can help the guys who are beginning on automation.

Here are the steps to follow:

  1. Download the flowcontrol extension for IDE. (“Download” is a bit of a misnomer here, as the download link takes one to an HTML page. Simply copy/paste only the JavaScript contents of that page into a file named goto_sel_ide.js.)
  2. Download the 1.1 version of the includeCommand4IDE extension. (The just-released 1.2 version appears to have a serious bug.)
  3. Download the most recent version (0.2) of the datadriven.js extension.
  4. Install these 3 extensions in IDE via the Selenium Core extensionsfield (accessible via Options=>Options=>General). They must be specified in the order above!!!
  5. Re-start IDE so that all 3 extensions will get read in.
  6. Create an .xml file
    <testdata>
    <test linkText="How It Works" title="Sauce OnDemand: Cross browser testing 
    with hosted Selenium testing in the cloud - Sauce Labs"/>
    <test linkText="Downloads" title="Sauce Labs Downloads"/>
    <test linkText="Pricing" title="Sauce Labs Pricing For Hosted 
    Selenium in the Cloud"/>
    <test linkText="Support" title="Support: Sauce RC (Selenium RC) - 
    Sauce Labs"/>
    <test linkText="Forums" title="Sauce Labs Forums"/>
    <test linkText="Blog" title="Selenium Testing? Do Cross Browser 
    Testing with Sauce Labs"/>
    <test linkText="Flash/Flex Solution" title="Automate testing of your 
    Flex and Flash Web Apps - Sauce Labs"/>
    <test linkText="Documentation" title="Documentation - Sauce Labs"/>
    <test linkText="About" title="About - Sauce Labs"/>
    <test linkText="Team" title="The Sauce Labs Team"/>
    <test linkText="News" title="Selenium News &amp; Events - Sauce Labs"/>
    <test linkText="Webinars" title="Webinars - Sauce Labs"/>
    <test linkText="Contact us" title="Support Contact - Sauce Labs"/>
    <test linkText="Service Status" title="Status - Sauce Labs"/>
    </testdata>
    
  7. linkText and title are variable names of my choosing. You can use any names you want, and also any number of variables you want. The critical thing is that each container must contain all the data–input and output–for a single test case.
  8. View your .xml file in the browser to ensure that it does not contain any errors (only necessary if you did not use an XML editor to create the file).
  9. Utilize your .xml file via creating an HTML test case:
    loadTestData file:///Users/mamp/Desktop/BLOG/saucelabs-footer.xml open 
    http://www.saucelabs.com while !testdata.EOF() nextTestData
    
    clickAndWait link=${linkText} verifyTitle ${title} goBackAndWait endWhile

Be sure to replace the URL for the .xml file provided to loadTestData above with the appropriate URL on your computer.

Run the test.

Thank you guys. Have a good weekend !

 

Fonts: http://saucelabs.com/blog/index.php/2011/01/selenium-resources-for-newbs-data-driven-testing-with-ide-xml/

 

%d bloggers like this: