Forum Discussion

ChandanD's avatar
ChandanD
Contributor
3 months ago

No output recieved when Jquery is executed

Hello,

I am using TestComplete 14, when I try to execute following script, no output is received. 

var url = "abc"
  Browsers.Item(btEdge).Run(url);
  browser = Sys.Browser();
  page = Sys.Browser().ToUrl(url);
  browser.BrowserWindow(0).Maximize();
//  Browsers.CurrentBrowser.Navigate(url);
//  var page = Sys.Browser().Page(url);
  
   page.contentDocument.Script.eval("jq('$attributeValue').val('TestPackage')")
  
  Delay(1000)
  var pritn = page.contentDocument.Script.eval("jq('$attributeValue').val()")
  Log.Message(pritn)

When I enter page.contentDocument.Script and check for eval, there is no eval available in the method.

 

I tried the same with TestComplete 15, the result is same.

 

Let me know what needs to be done so that the script can give the value and output.

 

I verified the same on developer mode ->console, it gives the desired result.

12 Replies

  • The expected output is current value of textbox and enter the value in text box as provided by me in script.

    • rraghvani's avatar
      rraghvani
      Champion Level 3

      This textbox, is it visible on your web application?

      • ChandanD's avatar
        ChandanD
        Contributor

        Below is screenshot of the application.

        Expected result is  and TestPackage to be entered.

        When I enter contentDocument.Script. and check for eval, the eval is not available in method.

        pageObj.contentDocument.Script.eval - why is eval in blue color in documentation. 

  • Hello,

    The application which I am automating is web based application. The application consists of textbox's, drop down menu, panel's. 

    The value of textbox, drop down, panel are generated runtime hence I am using XPath method to find the objects.  However, when new textbox or new label or button is added the as part of the developement, the object gets modified hence the XPath gets changed. 

    There is no unique properties for each textbox, textarea, drop down menu, label. 

    The application is designed using ZK framework. To overcome the issue faced due to XPATH update, the idea is to use JQuery to identify the objects with unique property. 

    Developer have provided JQuery information. 

    With TestComplete documentation provided, TestComplete supports JQuery.

    Hence, I am scripting using JQuery and testcomplete is unable to execute the query and provide the desired output.

    So, taking support from community to find the solution for the issue faced with using jquery. 

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Can you provide a screenshot of your UI control, and the Object Spy property values please?

  • Object Spy properties are -

     

    The idStr, ObjectIdentifier gets change everytime the web page is launched. Hence using jquery.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    So the idStr '#jThTx2' will change to something else, when the web page is relaunched. It is not possible to use Wildcard. Alternative approach is to get the Parent object (e.g. "Project Number*:" object), followed by the Child object.

    Is it possible for your developers to include a static idStr?

    Are you able to use Finding Web Objects Using XPath Expressions?

    FYI, if you are using the latest version of TC and Edge/Chrome, there's an issues with Run JavaScript on Web Pages

  • Hello,

    I have mentioned earlier the XPath as well changes if new textbox is added or removed. The XPath is heavy to maintain. There are issues facing due to XPath as well.