This is a migrated thread and some comments may be shown as answers.

How to deal with global navigation bar?

3 Answers 121 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Shane
Top achievements
Rank 1
Shane asked on 02 Oct 2012, 11:45 AM
Hi,

I was wondering if somebody could help me with my test design in relation to a navigation bar which is on every page.  Basically on our website which I am going to be running through automation, I'd like to creat some generic functionality to navigate around the site by passing through the link text to click on.  So far I have tried using record and play ( please bear in mind that I have come from a fully coded automation system prior to test studio ) but found that the element repository will become very bloated if I have to add an element per navigation link under every single page, especially as the users of the site are able to dynamically create there own pages with navigation links. If you see the attached image "NavigationBar.jpg", this is the navigation bar which displays on every page in it's most basic default form.

The best way I have come up with so far is to create a coded step as follows:

[CodedStep(@"Clicks one of the Search tabs")]
public void Click_Product_Search_Tab( string productNavLinkToClick )
{
    HtmlFindExpression expression = new HtmlFindExpression("tagname=a", "id=?searchLink", "textcontent=" + productNavLinkToClick );
    Element eLink = new Element( expression, Find, ActiveBrowser );
    eLink.Wait.ForExists( 30000 );
    HtmlAnchor hotelNavLink = new HtmlAnchor( eLink );
      
    if ( hotelNavLink != null )
        hotelNavLink.Click();
      
    Assert.IsNull( hotelNavLink );
      
      
}

I feel this would keep the functionality re-usable.  To test it I removes the productNavLinkToClick  argument and created a local data table with one cell/column which contained "hotel" replacing the HtmlFindExpression with Data[0].ToString() so I know the code itself works, but I am struggling to make it re-usable by the QA Manual testers who are not code literate.  I was hoping either for them to be able to just drag and drop my coded step and add the value of productNavLinkToClick themselves, or for me to intelligentally work out what page I am on and need to get to and call into this coded step accordingly.

I would be grateful if you could let me know if I am on the right track for a maintenance free navigation test or whether there is some better design?  I would be happy to tweak what I have done if required.

Please let me know if you require any further information

Many Thanks
Shane

3 Answers, 1 is accepted

Sort by
0
Byron
Telerik team
answered on 05 Oct 2012, 03:32 PM
Hello Shane,

If you would like to pass find logic to a test step, you can do so without resorting to code by using our data-driven find expressions feature. Since our 2012 R2 release (2012.2.920), you can bind columns from a data source to the filters of a step's find logic. This allows you to use an element in the element repository to find numerous target elements based on the contents of a data source, while allowing your QA testers to make changes to the data binding without editing code. Please let us know if this addresses your goal.

All the best,
Byron
the Telerik team
Are you enjoying Test Studio? We’d appreciate your vote in the ATI automation awards.
Vote now
0
Shane
Top achievements
Rank 1
answered on 08 Oct 2012, 09:24 AM
Hi Byron,

Thank you for your response.  It does half resolve my problem, however what I am struggling with is having the element as global i.e not being a child element of a page, rather I want it to be an element of any page.  You see I don't want to manage all the navigation links on every possible page.  Supposing our client configures 50 pages I would like to have one element which takes in the link  text as an argument which then gets used to find the element on any page along with two other element properties ( in this case being "tagname=a", "id=?searchLink"  ). 

I have managed to do what I need now by constructing a "Utility" class which contains the following method:
       
public void Click_Product_Search_Tab( string productNavLinkToClick, Find find, ArtOfTest.WebAii.Core.Browser browser  )
        {           
            HtmlFindExpression expression = new HtmlFindExpression("tagname=a", "id=?searchLink", "textcontent=" + productNavLinkToClick);
            Element eLink = new Element(expression, find, browser);
            eLink.Wait.ForExists(30000);
            HtmlAnchor productNavLink = new HtmlAnchor(eLink);
 
            if (productNavLink != null)
            {
                productNavLink.Click();
                Assert.IsNotNull(productNavLink);
            }
            else
            {
                Assert.IsNull(productNavLink);
            }
        }

I then make a call to this like so:
Utility.Click_Product_Search_Tab( "Hotel", this.Find, this.ActiveBrowser );

If I use your method of datadriving the find expression ( which is a very good enhancement to your product and I am using it elsewhere ), then the way I have implemented it may be incorrect as I have ended up with a base element under every possible page ( e.g. see attached "Navigation.jpg" image ) which uses the datadriven find expression to ID each of the possible navigation elements on the current page.  I would like to remove the parent "Page" so that I have just one element to maintain on all pages.  Is this possible?
0
Byron
Telerik team
answered on 09 Oct 2012, 11:18 PM
Hi Shane,

If you would like to reduce the number of pages and child nodes, I recommend merging your page nodes where appropriate. This is especially helpful in situations where page differences result from dynamic portions of a page URL, but reflect a similar or identical DOM. This way you can data drive the find expressions of fewer elements in order to achieve your goal. 

Greetings,
Byron
the Telerik team
Are you enjoying Test Studio? We’d appreciate your vote in the ATI automation awards.
Vote now
Tags
General Discussions
Asked by
Shane
Top achievements
Rank 1
Answers by
Byron
Telerik team
Shane
Top achievements
Rank 1
Share this question
or