Mr_Bro
5 years agoFrequent Contributor
Exceuting Custom JS
Hi team,
I am trying to write a custom JS to find elements which are inside an iframe parent using xpath, but im facing some problem at the last line where I am trying to evaluate the xpath within "contentDocument.Script.eval" .
requesting you to please help me know how to fix the same.
Code Snippet:
function CustomJStoFindObj(){
identifier = eval('"//input[@id=\'f2b06437___form_menu_form_name\']"')
test = 'document.evaluate("' +identifier+'",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;'
Log.Message(test.toString());
temp = test.toString();
var pageObj = Sys.Browser("chrome").Page("URL")
var Obj = pageObj.contentDocument.Script.eval(temp)
}
waiting for your valuable reply.
Thanks in Advance
Hi Mr_Bro !
TestComplete has more convenient methods to find Objects using XPath. I recommend that you try this approach.
To my knowledge, to find an Object within an iframe you need to first obtain the iframe and then search for the needed object within this iframe.Also, to be able to test pages with iframes, I'd recommend launching Chrome with the parameters as specified in the article below: https://support.smartbear.com/testcomplete/docs/app-testing/web/general/preparing-browsers/chrome.html