Message Boards Message Boards

GROUPS:

Use a Korean query with WebExecute?

Posted 1 year ago
2576 Views
|
6 Replies
|
3 Total Likes
|

Dear sir/madam, I have a query regarding WebExecute of WL12. So far, i have well fetched lat/lon coordinates from GoogleMap using ExtenalEvaluate & WebUnit in WL11.3. As in the yellow highlight region of attachment01, an english query (e.g. KOEX) is well activated to get successful results. But, if i use any Korean query (e.g. "???") in the same place, only to fail in result (refer to the error message in attachment02). Is there any workaround to this input problem?

Thanks in advance, Ho-Woong

Attachment

Attachment

6 Replies

Thank you for reporting this! It is a known issue and our teams are working on a fix. We are not sure yet about possible workarounds. If we find out we will update this discussion.

Posted 1 year ago

Thanks for your swift feedback. Please let me know whether Chinese or Japanese query has the same issue. If not, there's a discrepancy in Asian deployment policy of Wolfram.

Ho-Woong

TextTranslation of the query can fix this problem. Relevant Code: WebExecute[session, "TypeElement" -> {input, TextTranslation["???"]}]

Thanks to Mr. Dev Budhathoki (@Wolfram Research) for the suggestion.

Any diacritics in WebExecute will cause the same bug, as you can check in this post: https://community.wolfram.com/groups/-/m/t/1897363

Maybe the same temporary workaround can solve your case.

I just confirmed your example. It's the same for latin characters encoding. Here is @Arnoud Buzing solution from this post. Just execute the code below to fix the WebUnit fetch function. Here is an example:

StartWebSession["Chrome"];
WebExecute["OpenPage"->"https://www.google.com/maps"];
input = First@WebExecute["LocateElements"->"XPath"->"//input[@id = 'searchboxinput']"];

Now execute:

ClearAll[WebUnit`Private`fetch];

WebUnit`Private`fetch[
 WebUnit`Private`sessioninfo_,
 WebUnit`Private`type_, 
 WebUnit`Private`path_, 
 WebUnit`Private`data_,
 WebUnit`Private`key_
] := Module[{
 WebUnit`Private`res, 
 WebUnit`Private`fetchResult
},
 WebUnit`Private`fetchResult = URLRead[
  HTTPRequest[
   WebUnit`Private`sessioninfo[[3]] <> WebUnit`Private`path, <|
    "Method" -> WebUnit`Private`type,
    "Body" -> WebUnit`Private`json[WebUnit`Private`data]
   |>
  ], "BodyByteArray"
 ]; 
 If[
  !ByteArrayQ[WebUnit`Private`fetchResult], 
  Return[$Failed]
 ]; 
 If[
  ImportByteArray[WebUnit`Private`fetchResult, "Text"] === "missing command parameters",
  Return[$Failed]
 ];
 WebUnit`Private`res = ImportByteArray[WebUnit`Private`fetchResult, "JSON"]; 
 WebUnit`Private`DebugPrint[ WebUnit`Private`format[WebUnit`Private`res] ]; 
 WebUnit`Private`key /. WebUnit`Private`res
]

And you can test with:

WebExecute["TypeElement"-> {input, "평양"}]

or as in my case

WebExecute["TypeElement"-> {input, "São Paulo"}]

Works fine! WebExecute is cool, but it's in It first version yet. I Hope to have better sendKey in the future version, with more options as I ask in this post.

Note

1- The bug is for any entry of WebExecute using non standard characters, not just for "TypeElement". For example WebExecute["LocateElements" -> "XPath" -> "//input[text() = 'São Paulo']"] will break either without redefine WebUnitPrivatefetch.

2- Redefine WebUnitPrivatefetch before StartWebSession will not work in a fresh kernel. It needs to be after StartWebSession.

Posted 6 months ago

@ Rodrigo Murta,

I appreciate your helpful advice for the problem. That's what I really want.

Ho-Woong

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract