Contributions
- 1.9KViews0likes1Comment
Re: How to export a function from one unit to another unit in JavaScript.
tristaanogre, Found the issue,for (let l = 0;l < driver1.RowCount; l++) the loop is not working if i use RowCount, so i upated RowCount to Column Count, it started reading the file. My question is if i use only CoulmnCount (2) in the loop it's just using the first name(Kevin), last name(Gibson) in the first iteration and in the second iteration it's using Gibson as first name and the null as second name since there are only two columns. is there any keyword i can use to make it loop through all the rows?? The data file is attached. Thanks, Binnu.2.9KViews0likes2CommentsHow to export a function from one unit to another unit in JavaScript.
Hi Everyone, I'm trying to export a function from one unit to another unit, i used "module.exports.Test1 = Test1;" command in the unit1 to export Test1 function and used "var objin = require("Data1");" command to make it availble in unit2. i want to assign the Test1() funtion to a variable in the unit2. "let arrValues = objin.Test1();" i used this command to make it happen. but it's not working. can somebody help me export a funtion from external unit and how to use the function in another unit/funtion. Data1 (unit1): function Test1() { var driver = DDT.CSVDriver("C:\\Users\\75\\Desktop\\Data.csv"); var firstname_col = []; // var lastname_col = []; //let value1 = Project.Variables.Data.Value('FIRST NAME'); //let value2 = Project.Variables.Data.Value('LAST NAME'); for (i=0;i < driver.ColumnCount; i++) { firstname_col.push(driver.Value(i)); } DDT.CloseDriver(driver.Name); return firstname_col; } module.exports.Test1 = Test1; Data2(Unit2): var objin = require("Data1"); //USEUNIT Data1 function test() { var driver1 = DDT.CSVDriver("C:\\Users\\13175\\Desktop\\Data.csv"); let arrValues = objin.Test1(); //objin.Test1(); for (let l = 0;l < driver1.RowCount; l++) { let url = "http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_button_type"; Browsers.Item(btIExplorer).Run(url); let page = Sys.Browser("*").Page("*"); aqUtils.Delay(1000); let first_name = page.EvaluateXPath("//*[@id='fname']"); first_name[0].Click(); Sys.Keys(arrValues[l]); let last_name = page.EvaluateXPath("//*[@id='lname']"); last_name[0].Click(); Sys.Keys(arrValues[l+1]); // Call the function var arr = page.EvaluateXPath("//*[@type='submit']"); arr[0].Click(); aqObject.CheckProperty(Aliases.browser.pageTryitEditorV36.frameIframeresult.textnode, "contentText", cmpEqual, "The server has processed your input and returned this answer."); // DDT.CloseDriver(driver.Name); page.Close(); } } Thanks, BinnuSolved2.9KViews0likes6CommentsRe: How to export a function from one unit to another unit in JavaScript.
Hitristaanogre, Thanks for the reply, i don't get the error message or anything, testcomplete is passing the two tests and doing nothing. the log file doesn't show anything, it's just blank. Please see the screenshots for more details. Thanks, Binnu.2.9KViews0likes4CommentsSimple example for data driven testing
Hi everyone!! I'm new to testcomplete, and i've started creating my scripts manually (without using record option), the documentation availble in smartbear website is not detailed for data driven testing, and i can only see tutorials and video's on how to use data loop option in record test mode. can someone please create a simple javascript code for bignners (not exported script from a recorded tests) using an excel file or CSV file for a login page with different user ID's and password's. This will be a great help. Thanks in advance, Binnu.Solved2KViews0likes4Comments