Forum Discussion

hskim's avatar
hskim
Contributor
8 years ago

Read a Text from app. by OCR

Dear,

I have Mobile module.

 

 

I must read a text of SMS so I installed SMS application in Android phone.

(Please refer the attached screen01.png)

 

TestComplete can recognize the object but the text info. doesn't be there.

(Please refer the attached screen02.png)

 

So I have to use OCR function.

 

I found the ocr script the following.(Please refer the URL, https://support.smartbear.com/viewarticle/86444/)

 

But I don't know what can I edit the script.

I tried to edit but always appear error.

 

Example,

p = Mobile.Device("SHV-E300K");

 

But I can't execute.

 

Please let me know how can I use it.

 

The other's information is,

Mobile.Device("SHV-E300K").Process("com.skt.prod.tmessage").RootLayout("").Layout("NO_ID").View("messages_fragment_pager").Layout("NO_ID").ListView("listview_messages").Layout("NO_ID").Layout("message_bubble_frame").Layout("message_bubble_container").Layout("NO_ID").Layout("message_bubble_send_bubble_container").TextView("message_bubble_send_text")

 

Aliases.Device.Process_prod_tmessage.RootLayout.Layout_NO_ID.View_messages_fragment_pager.Layout_NO_ID.ListView_listview_messages.Layout_NO_ID.Layout_message_bubble_frame.Layout_message_bubble_container.Layout_NO_ID.Layout.TextView_message_bubble_send_text

 

The following is script for OCR.

-------------------------------------

function Test()
{
  var p, w, OCRObj, OCROptions, Font, s;

  // Obtain the window containing the text to be recognized
  p = Sys.Process("MyApplication");
  w = p.Window("MyWndClass", "MyWndCaption", 1).Window("MyControlClass", "*", 1);

  // Create a new OCRObject object
  OCRObj = OCR.CreateObject(w);

  // Create a new OCROptions object to modify recognition settings
  OCROptions = OCRObj.CreateOptions();

  // The following code modifies the recognition settings

  // Add a new font to the Fonts collection
  Font = OCROptions.Fonts.Add();
  Font.Name = "Tahoma"; // Specify the font name
  Font.Styles.Add(1); // Add the Bold style
  Font.Styles.Add(2); // Add the Italic style
  Font.Sizes.Add(8); // Add the 8 pt size
  Font.Sizes.Add(12); // Add the 12 pt size

  // Add one more font to the Fonts collection
  Font = OCROptions.Fonts.Add();
  Font.Name = "Verdana"; // Specify the font name
  Font.Styles.Add(1); // Add the Bold style
  Font.Styles.Add(2); // Add the Italic style
  Font.Sizes.Add(8); // Add the 8 pt size
  Font.Sizes.Add(12); // Add the 12 pt size

  // Recognize text
  s = OCRObj.GetText(OCROptions);

  // Post results to the log
  Log.Message(s);
}

---------------------------------------------

 

Thank you.

Hwansung

2 Replies

  • The user contacted the TestComplete Support Team and was able to accomplish this task by installing third-party Android application.