Developer tutorials
From QAliber
In the tutorials here we'll cover basic and advanced features and tools available for QAliber developer using our Visual Studio plug-in. These tutorials assume you already familiar with the QAliber developer plug-in and know how to create and deploy a Test Case (if not you should probably do the quick start tutorial first).
Web, using Find()
In this tutorial we will quickly go over simple web automation, and see how to use the UI control browser to create tests over IE explorer. You can download the visual studio solution for this tutorial from here
The test:
Select item in the sourceforge “What’s Hot for Windows”, click to rate item on list and verify the ratings number had changed. Lets drive the use cases and Test Cases blocks for this task:
- Open IE Navigate to sourceforge.net
- Select the the topic tab
- Click Topic item thumb up or down
- Insert text and submit task
- Verify number of ratings changed.
Codding Select Topic Test Case:
Make sure UI Control Browser is set to work with Web (selected in the combo) drag the cursor and mark any topic tab. Your control browser should look like this:
You can see this control has InnerText property which is unique as it describe the tab (Games,Security, Filesharing etc'). What we want to do in the test case is to receive the tab name as Parameters, and we'll look for it and click on it if found.
we have 2 options to do this:
1) Get the list item parent in the control browser, use for loop to go through each item and check the InnerText is what we looking for. Like this:
HTMLUl hotList = Desktop.Web.CurrentPage.FindByID("DIV", "hotB-carousel-body")["UL", 1] as HTMLUl foreach (HTMLLi item in hotList.Items) { if (item.InnerText == "Games") ... }
2) Or (Better) use Find:
- In control browser, select the parent element for the list items. HTMLDiv item as you see here:.
- From its properties get the element code path.
- Use the Find method to look in decedents for a control with InnerText property matched what you look for:
HTMLDiv whatsHotDiv = Desktop.Web.CurrentPage.FindByID("DIV", "yui-main")["DIV", 1]["DIV", 1]["DIV", 1]["DIV", 1] as HTMLDiv; UIControlBase tab = whatsHotDiv.Find(System.Windows.Automation.TreeScope.Descendants, "InnerText", "Games"); if (tab != null) tab.Click();
Now you can add a tab name Parameter and make our Test Case flexible, allow the test builder user to choose and tab on whats hot list.
private string tabName; public string TabName { get { return tabName; } set { tabName = value; } } public override void Body() { HTMLDiv whatsHotDiv = Desktop.Web.CurrentPage.FindByID("DIV", "yui-main")["DIV", 1]["DIV", 1]["DIV", 1]["DIV", 1] as HTMLDiv; UIControlBase tab = whatsHotDiv.Find(System.Windows.Automation.TreeScope.Descendants, "InnerText", tabName); if (tab != null) { Log.Default.Info("Tab found, click on it"); actualResult = TestCaseResult.Passed; tab.Click(); } }
Deploy it to your QAliber Builder and you're done. Once you added the Test Case to the repository you can the download & run the scenario
Thats it, were done, you can use our [| Help forums] with any question you might have regarding this scenario, or any other question you might have. Check out this wiki section for more tutorials.
