VBscript fails when calling jquery in testcomplete -


this occurs in testcomplete version 9.20, , test against firefox 19.0.2.

first script file called test , contains following lines:

'useunit commonfunctions public function test()   call expandtree() end function 

the other script file named commonfunctions has function:

public function expandtree()   set foo = aliases.tree.contentdocument.script.jquery("li[data-nodeid='sites'] a.openclose").click() end function 

when run script automation files giving following error:

microsoft vbscript runtime error.  object doesn't support property or method:"contentdocument.script.jquery(...).click''  error location: unit:"contentsuite\content\script\commonfunctions" line:3972 coloumn2 

the same error not occur if place jquery in same file. if run work properly, , click work fine:

public function test()   set foo = aliases.tree.contentdocument.script.jquery("li[data-nodeid='sites'] a.openclose").click() end function 

first of all, current code uses dom click method, not have return value, need remove set foo =.

the error might jquery selector did not find matching objects. try checking length property of jquery function result:

set links = aliases.tree.contentdocument.script.jquery("li[data-nodeid='sites'] a.openclose") if links.length > 0   links.click else   log.error "object not found." end if 

but there's no need use jquery here, since testcomplete has built-in queryselector method:

set obj = aliases.tree.queryselector("li[data-nodeid='sites'] a.openclose") if not obj nothing   obj.click else   log.error "object not found." end if 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -