Group Abstract Group Abstract

Message Boards Message Boards

Use a Korean query with WebExecute?

Posted 7 years ago
6 Replies
Posted 5 years ago

@ Rodrigo Murta,

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

Ho-Woong

POSTED BY: Ho-Woong Choi

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 BY: Rodrigo Murta
POSTED BY: Rodrigo Murta

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.

POSTED BY: Suman Banerjee
Posted 7 years 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

POSTED BY: Ho-Woong Choi
POSTED BY: EDITORIAL BOARD
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard