Forum Discussion

huabing's avatar
huabing
Occasional Contributor
2 years ago

Sometimes .Keys action doesn't work when input long text

When execute a lot of scripts one by one, the .Keys action not always valid. It works in log but actually not input any text. It never occurs when execution single script.

Text input about 300 characters.

 

I tried to click the box before input text, but this problem still there.

I also tried to delay 3s or use .Keys() action twice once check the first input not valid. but the second still not valid.

What should I do? Please help me, thanks!

 

  • huabing's avatar
    huabing
    2 years ago

    Problem solved but I really don't know failed reason.

     

    1. The failed action always occurs in specific script, although not reproduce when single run the script.

    2. So I think maybe the script executing right before the failed script get something wrong.

    3. And I find out the last sheet of former script used is next to last in Excel.

    4. I reordered the sheet and make it move forward. Problem solved!

     

    Anyway, thank you for your help!

     

8 Replies

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Is the UI control disabled, and then enabled after 3000 is entered? Also try SetText method.

    • koneth's avatar
      koneth
      Visitor

      Actually, I did nothing when ran these scripts. So I really don't know what happend. How to disable the UI control?

      The SetText() method not in Object Spy, and I tried, it didn't work and failed. The error message is "

      The object with the specified attributes does not exist." 

       

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Is the UI Control always enabled? Have you created a mapped name for your UI Control? Is TestComplete able to highlight that UI Control all the time? 

    Can you provide your code?

    • huabing's avatar
      huabing
      Occasional Contributor

      When I input text, I get data from excel:

       

      fullpath = aqFileSystem.ExpandUNCFileName(filepath)
      sheetname = Excel.Open(fullpath).SheetByTitle[sheet]
      for column in range(2,(sheetname.ColumnCount+1)):
          id = sheetname.Cell[column,2].Value
          value = sheetname.Cell[column,3].Value
          item = Aliases.browser.page("*").WaitElement(id,3000)

          item.Click()
          item.Keys(value)

       

      Does it any problem?

    • huabing's avatar
      huabing
      Occasional Contributor

      "#commentText1", the box id. And the value is 300 characters quoted by triple-quotes """""".

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Are you able to run this bit of code?

    function UIHighlight()
    {
        // Change 'chrome' to your browser
        var obj = Sys.Browser("chrome").Page("*").WaitElement("#commentText1", 10000);
        Sys.HighlightObject(obj);
        obj.Keys("Testing UI Control");   
    }

    If the object is returned, then the UI object should highlight and text will be entered

    • If large text does not work, then you could be reaching maximum text limit of Keys()
    • If this does not work, then WaitElement is not able to find "#commentText1"
    • Verify 'value' is correct
    • huabing's avatar
      huabing
      Occasional Contributor

      Problem solved but I really don't know failed reason.

       

      1. The failed action always occurs in specific script, although not reproduce when single run the script.

      2. So I think maybe the script executing right before the failed script get something wrong.

      3. And I find out the last sheet of former script used is next to last in Excel.

      4. I reordered the sheet and make it move forward. Problem solved!

       

      Anyway, thank you for your help!