Contributions
Re: data-driven-loop on different db-connections
Hi Benjamin, Currently, there is no way to programmatically change the connection string used by a DB Table variable during the test execution. You can only visually configure such a variable at design time. However, I would like to suggest you the following workaround: 1. If you need to retrieve data from several database sources, create several DB Table variables in your keyword test at design time. Configure each variable so that it uses the appropriate connection string and retrieves data from the needed source. Let's suppose that you have two DB Table variables, DBVar1 and DBVar2. 2. Create a helper DB Table variable (say, it is named DBVar3) to be used as your data-driven loop's variable. Note that you must specify a valid connection string for this helper variable at design time to properly add the Data-Driven Loop operation to your test. It doesn't matter what connection string you specify for this variable at design time. The string just must be valid, because the Data-Driven Loop operation's wizard requires valid settings to be specified when you add a new operation. For example, for this helper variable, you can specify the same settings as you specified for one of the other variables. 3. Create a data-driven loop and specify the helper DB Table variable created in the previous step (DBVar3) as the data-driven loop's variable. 4. Then, before executing your data-driven loop, you need to set the needed DB Table variable's value (for instance, DBVar1 or DBVar2) to this helper variable (DBVar3) in the test. So, the data-driven loop will use the data previously stored in the appropriate variable and retrieved from one of the needed sources and copied to the helper variable. A few notes on copying one DB Table variable's value to another variable. The Set Variable Value operation doesn't allow setting values of DB Table variables. Therefore, you need to assign one DB Table variable to another using one of the following approaches: 1. Use the Call Object Method operation. When adding such an operation to the test, specify the following settings in the operation's wizard: a. In the edit box on the Specify Object page, type the following code snippet and click Next: KeywordTests.<test_name>.Variables b. On the Specify Method or Property page, select the appropriate method for setting a new value to the needed variable, that is, the method that is named like var_name [Set] (for instance, DBVar3 [Set]) and click Next. c. In the Value column of the table displayed on the Operation Parameters page, specify the variable whose value you want to be assigned to the helper variable and click Finish. 2. Use the Run Code Snippet operation. In the operation's parameters, specify a code snippet that just assigns one variable to another. There is one important note: since you are using VBScript, you need to specify the assignment in the following way: Without using the Execute statement, the Run Code Snippet operation will interpret the '=' operator as a comparison, not as an assignment. This is caused by the specifics of the VBScript syntax. Although the second approach seems to be easier, I would recommend that you use the first one (the Call Object Method operation). The assignment will be performed a bit faster in this case during the test execution. Please let me know whether the described workaround helps you.678Views0likes0CommentsRe: How to simulate custom user-agent query to web application?
Hi Vladimir, The following code is a DelphiScript version of the function. Note that I've modified a bit the original program logic of the code posted earlier by Igor. However, you can change the code of the function if you need and implement your own program logic in it. function HttpGet(url, userAgent): boolean; var httpObj: OleVariant; begin httpObj := Sys.OleObject['MSXML2.XMLHTTP']; httpObj.open('GET', url, true); httpObj.setRequestHeader('User-Agent', userAgent); // set user agent httpObj.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT'); /// do not cache the response httpObj.send(); while(httpObj.readyState <> 4) do Delay(300); case httpObj.status of 200, 302 : if Length(httpObj.responseText) <> 0 then begin Log.Message('The ' + url + ' link is valid', httpObj.responseText); Result := false; end else Result := true; else begin Log.Message('The ' + url + ' link was not found, the returned status: ' + aqConvert.VarToStr(httpObj.status), httpObj.responseText); Result := false; end end end; Does this help?1.9KViews0likes0CommentsRe: ADO reading parameters into SQL
Hi Chris, After some investigations, I've found a workaround for you. You can execute an SQL query to your database by using another object, IAQAADOConnection, which is returned by the ADO.CreateADOConnection method. Please try using this object instead of IAQAADOQuery returned by ADO.CreateADOQuery in your test where you need to use the colon character enclosed into quotes. You can use something like the following example (it seems to work fine in my sample test): // Create an IAQAADOConnection object var connection = ADO.CreateADOConnection(); // Specify the connection string connection.ConnectionString = getConnectionString(); connection.LoginPrompt = false; // Specify the SQL query var sql = "select '\" : \"' as text from dual"; connection.Open(); // Execute the query and get a recordset var rs = connection.Execute_(sql); // Move through the received records and use their fields while (!rs.EOF) { Log.Message(rs.Fields.Item("name"), rs.Fields.Item("address")); rs.MoveNext(); } connection.Close(); Does this workaround help in your case? Please let me know your results.1.2KViews0likes0CommentsRe: host add problem
Hi Ashish, Please try specifying the IP address of the slave machine, not its network name, in the Address field of the Hosts editor. Also, try pinging the specified IP address from the master machine to be sure that the machine with this IP address is available. I guess, you select the slave machine's name from the Select Host dialog, which is invoked after you click the ellipsis button in the Address field, therefore, the slave machine's network name is specified instead of the IP address in your case. Furthermore, please recheck that tcrea.exe is running on the slave machine and the firewall is disabled on that machine, as well as on the master one. Also, make sure again that all other requirements listed in the Message - Verification failed help topic are met in your case. If this does not help you, please submit your request to our Support Team via the Contact Support form on our web site and describe in greater detail all the steps you are performing to add and verify a slave host and the results you get. Please refer to this thread in your request.1.1KViews0likes0CommentsRe: host add problem
Hi Ashish, Please, see the following threads where issues similar to yours are discussed: http://smartbear.com/forums/forum/post/?mode=singleThread&thread=5b4dc97e-7cd9-4c23-b200-3b4d1e15dc72 http://smartbear.com/forums/forum/post/?mode=singleThread&thread=4c52dad4-15c6-47f3-9725-ea562f8fa5c3 Also, in addition to the recommendations from these threads, I would like to suggest you the following ones: 1. Make sure that both the master and slave machines reside in the same network. 2. Make sure that there are no other machines in your network with the same machine name as that you specified as the host name (if you still want to use the machine name instead of the IP address). 3. Make sure that the firewalls are disabled on both the master and slave machines. I hope that all the above-mentioned recommendations (including the threads I have referred you to) will help you solve the issue.1.1KViews0likes0CommentsRe: ADO reading parameters into SQL
Hi Chris, Have you tried to escape the colon character in your query by using the backslash character before the colon? Please try to use the following code: Qry.SQL = "select '\" \: \"' as text from dual"; I'm not sure about this, but I hope, this can help in your case if you need the colon character to be interpreted just as the colon character in the sought-for string.1.2KViews0likes0CommentsRe: Ignoring Date XML in Keyword tests?
Hi Corey, If you need to verify XML data in your keyword test, you can use the XML Checkpoint operation that compares the contents of an XML document (XML data which you obtain from the tested application during the test run) against the baseline copy stored as an XMLCheckpoint project element that belongs to the Stores | XML collection. If an XML document you need to verify contains variable date values only in attributes, I would like to suggest you the following two approaches: 1. Open the XMLCheckpoint project element containing the baseline copy of your XML document in the XMLCheckpoint Element editor, select the Ignore attributes check box and save the changes. In this case, XML Checkpoint will ignore all attribute values when comparing XML data from this XMLCheckpoint project element against the needed XML document obtained from the application at run time. It is the easiest way to ignore date values if they are stored only as attribute values. However, if you still need to compare some other XML attributes that do not contain variable date values in your document, this solution is not the best one in your case. 2. Remove attributes that contain variable date values from the baseline copy of your XML document and from the XML document that is obtained from the tested application and needs to be verified. If your document really contains thousands of such attributes, you can programmatically remove them from the baseline copy and from the actual XML document at run time and compare these modified documents. To modify the documents, you should programmatically iterate through their nodes and remove the needed attributes. For implementing the second approach, you can use the following scenario: a. Create an XML Checkpoint element in your project and save the baseline copy of your XML document in it (let's suppose the element is named XmlCheckpoint1). b. Create another XML Checkpoint element to which you will save the actual XML document that you need to verify (let's suppose the element is named XmlCheckpoint2). c. Add the following script routine to your project (note that it is written in JScript, so you can use it in a JScript TestComplete project): // XMLDoc - an object that implements the IXMLDOMDocument interface // and contains the initial XML document function RemoveXMLAttributes(XMLDoc) { var selectedNodes, node; // Create an array with the names of the attributes to be removed var attributeNames = Array("date_attr_1", "date_attr_2"); for(var i = 0; i < attributeNames.length; i++) { // Get the collection of nodes with the attributeNames attribute specified selectedNodes = XMLDoc.selectNodes("//*[@" + attributeNames + "]"); // Iterate through the selected nodes node = selectedNodes.nextNode(); while(node != null) { node.removeAttribute(attributeNames); node = selectedNodes.nextNode(); } } return XMLDoc; } This routine gets an XML document passed through its parameter as an object that implements the IXMLDOMDocument interface, removes all attributes whose names are specified in the attributeNames array and returns the resulting XML document. Note that you should edit a bit the routine's body and use the attributeNames array to specify all the attribute names which you need to be removed from the document's nodes (suppose you know exactly what attributes must be removed). d. Add a Run Script Routine operation to your keyword test and specify the above-mentioned RemoveXMLAttributes routine in the operation's parameters. Also, specify the XML.XmlCheckpoint1.Document value as the routine's parameter. When you execute this operation, the XmlCheckpoint1 element will contain the updated version of the baseline XML document (without the specified attributes). e. Let's suppose that you have stored the actual XML document in a separate file (for example, C:\mydata.xml). Before comparing it with the baseline copy, load its contents to the XmlCheckpoint2 helper element. For this purpose, you can use the Run Code Snippet operation in your test and specify the following code in its parameters: f. Add one more Run Script Routine operation to your keyword test, specify the RemoveXMLAttributes routine in its parameters and pass the following code to the routine: As a result of this operation, the XmlCheckpoint2 element will contain the actual version of your XML document after removing the specified attributes. g. Add one more Run Code Snippet operation to your test and specify the following code in its parameters: This code performs the comparison of the XmlCheckpoint1 element (the baseline document) against the XmlCheckpoint2 element (the actual XML data). The specified variable attributes (containing date values in your case) have been already removed from both the documents, so, you can compare them. I have attached a sample TestComplete project suite (see the XMLVerification.zip archive) that demonstrates how you can implement this approach. Note that the project suite was created with TestComplete ver. 8. The archive also contains a sample XML document named mydata.xml. Place it to the root of the C:\ disk to execute properly the test project. The RemoveXMLAttributes routine in the project removes all the version and name attributes from the sample document (note that its baseline copy stored in the XmlCheckpoint1 project element contains the attributes' values that differ from the values stored in the mydata.xml document). I hope this approach helps in your case.674Views0likes0CommentsRe: Automate a window already open and record from there
Hi Leanne, If you have a test recorded over a certain application, you can manually run your application, perform some preliminary user actions over it (if needed) and then execute the test that will work with the application's window(s). However, TestComplete makes the testing process easier by providing the Tested Applications collection. This project item allows your test to launch the application(s) to be tested automatically. If your test was recorded as script code, you can execute the needed routine by placing the cursor somewhere within the routine's code and clicking the Run Current Routine button on the Code Editor toolbar or by right-clicking the needed script unit in the Project Explorer panel and selecting the needed routine name from the Run submenu of the context menu. Note that TestComplete executes the whole routine. Unfortunately, there is no way to execute only certain script statements selected in a routine's body (not the whole script routine). If you use a keyword test, you can run the whole test (simply open it in the Keyword Test editor and click the Run Test button on the editor toolbar), as well as an individual keyword test operation in the test (right-click it in the editor and select Run Selected Operation from the context menu). Also, you can right-click a certain keyword test operation in the editor and select Run from Selected Operation from the context menu to execute a group of operations from the selected one to the end of the test. For more details, please see Running Keyword Tests. You can find more information on running TestComplete tests in the Running Tests help section.803Views0likes0CommentsRe: Unable to read updated value from XTPReport control
Hi Prakash, Could you please give us a snapshot created for your XTPReport object and all its child objects after you have modified some cell values? Such a snapshot will let us better investigate your issue. To create the snapshot of your grid, please follow the steps below: 1. Run your tested application and modify some cells in its XTPReport grid. 2. Select your XTPReport object in the Objects tree of TestComplete's Object Browser panel. To quickly find the needed object, you can: a. click the Display Object Spy button on the Tools toolbar to invoke the Object Spy window; b. drag the target glyph from this window to the grid in your application, wait until a red frame appears around your XTPReport control and then release the mouse button. Then, the Object Spy window displays the properties and methods of the selected grid; c. right-click somewhere in the list of properties and select Highlight in Object Tree from the context menu or click the appropriate button in the top right corner of the window. After that, TestComplete selects the appropriate object in the Objects tree of the Object Browser; d. close the Object Spy window. 3. Click the Save Object Snapshot button on the Save/Load Snapshots toolbar. If this toolbar is hidden, right-click somewhere within TestComplete’s toolbar area and select Save/Load Snapshots from the context menu to make the toolbar visible. 4. In the ensuing Save Object Snapshot dialog, specify the name of the snapshot file to be created. Select the Properties and Save recursively check boxes and the All properties option. Click OK. 5. Attach the generated *.tcSnapshot file to your post in this thread. If you do not want to upload the file to the forum, you can send it to our Support Team via the Contact Support form on our web site (http://smartbear.com/support/message/?prod=TestComplete). In this case, please refer to this forum thread in your message before sending it to the Support Team. Thanks in advance.1KViews0likes0CommentsRe: Automate a window already open and record from there
Hi Leanne, With TestComplete, you can start recording a script or keyword test and perform the actions you need to record. If you do not want to record some actions during the test recording, you can suspend the recording by clicking the Pause button on the Recording toolbar and then, after you have performed these actions, you can click the Resume Recording button to continue recording the script or keyword test. TestComplete can record a new script routine or keyword test or insert the recorded user actions into the existing script or keyword test. This behavior depends on the "Always start a new test" TestComplete option. By default, this option is enabled, and TestComplete starts recording a new script routine or keyword test when you initiate the recording process. If this option is disabled, TestComplete inserts the recorded script statements or keyword test operations into the current position in the script or keyword test. So, if you need to record some new actions with your application and append them to an existing scripting routine or keyword test, you can disable the "Always start a new test" option, put the cursor into the needed place in your script code or keyword test, run your application, perform the needed actions which you have already recorded, then start the recording, perform the actions you need to be recorded and appended to the test and stop the recording after all the needed actions are performed. TestComplete will insert the recorded actions into the script or keyword test recorded earlier. If you use keyword tests, you can also start the recording by clicking the Append to Test button on the Keyword Test editor's toolbar to insert newly recorded operations into the current position in the existing test or append them to the end of the test. For more information, please see the Starting, Pausing and Stopping Recording and Inserting Recorded Commands Into the Current Test sections of the Recording Tests - Overview help topic.803Views0likes0Comments