Contributions
Re: How to change scripting language of an existing project
While I hit an issue with excel and had to take the risk to switch the language. The current code sample only supports VBScript and JScript (https://support.smartbear.com/viewarticle/24734/), while using the JScript snippet in JavaScript (TestComplete 12), it reports "book.Sheets() is not a function". Have to close my project, open and update my project mds file, then reload the project again. Changed from <config language="{90F89436-9452-4F95-9882-6B5210079F13}" /> to <config language="{E42909F2-4390-4F5D-94B8-FABF59BABFCE}" /> Now it seems to be fine, I can read/write excel now. I would not suggest you to do this unless you want to take the unknown risk, JavaScript to JScript is probably has the lowest risk, I guess?4.1KViews0likes1CommentRe: Failed to recognize the new childcount
I figured out by using object.refresh(), I can get the new ChildCount. I will need to define a new variable though. It looks like below now: var x = new definitions.Category_List_Page(); // x is a customized object Log.Message(x.numOfCategories); // output 9 var cat = definitions.get_CLP_subCatItem(2); // click on the second item cat.Touch(); // second item get expanded with sub items Delay(6000); x.self.refresh(); // x.self is the actual navigation element on screen var y = new definitions.Category_List_Page(); // has to define a new object, can't use x anymore Log.Message(y.numOfCategories); // output 17 Thanks all!1.9KViews0likes0CommentsFailed to recognize the new childcount
I tried to retrieve an element's ChildCount, it originally is 9. Then I called Touch(), it will expands and show up a sub menu. By using ObjectSpy, its ChildCount becomes 17. However I can't get the number 17 using neither script nor keyword test. Is there a way to force TC to read the new object? Original: a b c After touch: a b >b1 >b2 >b3 c Script: var x = new definitions.Category_List_Page(); Log.Message(x.numOfCategories); var cat = definitions.get_CLP_subCatItem(2); cat.Touch(); Delay(6000); var y = new definitions.Category_List_Page(); Log.Message(y.numOfCategories); The only workaround I can use, is probably recognize each status of the list (by expanding each sub item) to be different objects: 1) default page with no sub items expanded/touched 2) page1 with item 1 touched 3) page2 with item 2 touched ...... But this sounds silly.1.9KViews0likes4Commentsfailed to set value then read value from excel
read several threads about read/set excel, however when I try to do it together, it doesn't work: function _read_data(row,col) { var excel = Sys.WaitProcess('EXCEL'); if (excel.Exists) excel.Terminate(); var app = Sys.OleObject("Excel.Application"); ...... app.Quit(); } function _write_data(row,col,value) { var excel = Sys.WaitProcess('EXCEL'); if (excel.Exists) excel.Terminate(); var app = Sys.OleObject("Excel.Application"); var book = app.Workbooks.Open(...); var sheet = book.Sheets("Sheet1"); sheet.Cells(row,col) = value; book.save(); ...... app.Quit(); } function read_data() { _read_data(1,1); } function write_data() { _write_data(1,1,"hello"); } function test() { _write_data(1,1,"hi"); _read_data(1,1); } Run read_data() or write_data() separately, it works fine. However when I run test(), it doesn't do anything and no log printed. Please anyone could help?676Views0likes0Comments