Submitted by slabhani on February 3, 2010 - 10:11am.Here is an instance of a unique problem we encountered for a project and how a little out of the box thinking helped us find a solution. Based on specific requirements of a customer, we were asked to evaluate the testing tool QTP for specific capabilities corresponding to their requirements. The problem and the solution are described here.
Client uses asynchronous AJAX WebTable for their list of users using the application, we landed up in a scenario where we have to select multiple rows based on the data provided as the input to the scenario. This option of selecting multiple rows manually is selecting the first row and the next set of rows by selecting/clicking the required row using the CTRL key pressed down.
We tried all the options that were provided by the tool like DeviceReplay, SendKeys, FireEvent … However, there was not a single solution which could solve the issue. Then we went on to the big guru the google.com, and tried searching on the web to select multiple rows in an AJAX WebTable using QTP and no luck there as well.
That’s when we put our automation experience to test and donned the hat of an automation tester. We tried the “drag and drop” option of the tool to use and we were successful in finding the solution. One more challenge associated with the AJAX WebTable was its controls, they were dynamic in nature.
The user name’s unique identifying factor “htmlid” was constructed as a combination of the following <<TableName>>-id-<<ID value from the Table>>-name.
For example: let us say the user name was “AutTest” which is 102nd entry in the table with the name “UserTable”, and then the htmlid would be UserTable-id-102-name.
Here is the code snippet of the solution implemented.
‘Declaring the Variables being used Dim BaseObj, RowCount, WEDesc, UserName, sqlQuery, id, eleHtmlid
‘Setting up the base object Set BaseObj = Browser("Browser").Page("Page")
‘Getting the row count in the data table RowCount = Datatable.GetSheetName(<SheetID>).GetRowCount
‘Creating the Web element object required for selection/clicking Set WEDesc = Description.Create() WEDesc("micclass").Value = "WebElement"
‘Creating the record set object Set DBRes = CreateObject("ADODB.RecordSet")
‘Logic for creating the required object, performing the multiple row selection For row=1 to RowCount DataTable.SetCurrentRow(row) UsrName = DataTable.Rawvalue(<<ColumnName>>, <<SheetName>>) sqlQuery = "Select id, name from <<Table Name>> where name = '" & UsrName &"'" DBRes.Open sqlQuery,DBConn If DBRes.RecordCount > 0 Then id = DBRes("id") eleHtmlid = "<<TableName-id->>-id-" & id & "_name" WEDesc("html id").value = eleHtmlid ‘Checking if the Web Element exists and getting the corresponding x and y positions If BaseObj.WebTable("UserList").WebElement(WEDesc).Exist(1) then xpos =BaseObj.WebTable("UserTable").WebElement(WEDesc).GetROProperty("x") ypos =BaseObj.WebTable("UserTable").WebElement(WEDesc).GetROProperty("y") wait(1)
‘Drag and Drop the web element in the same location by keeping the control key pressed BaseObj.WebTable("UserTable").WebElement(WEDesc).Drag xpos,ypos,micLeftBtn,micCtrl wait(1) BaseObj.WebTable("UserTable").WebElement(WEDesc).Drop xpos,ypos
‘Printing to ensure that the right value has been selected Print "User " & UsrName & " selected " End If Else
‘In case if the user name does not exist in the database Print "User " & UsrName & " doesnot exist in the database " End If DBRes.Close Next
|
Recent comments
9 weeks 5 hours ago
12 weeks 4 days ago