Hey guys,
UiPath beginner here. I have been trying to automate the responses for whatsapp web messages. I am planning on using an excel spreadsheet with responses to key words. I can’t seem to use selectors to detect both my last message and the incoming last message into separate variables. I am not very familiar with css or html to properly use uiexplorer. I plan to use these variables for comparison and bouncing off the input excel table to generate responses. Any help would be appreciated.Thanks in advance.
Although there are several ways of doing this - one way would be to use Javascript. We could then use the querySelector() method to select the object and get the contents of it. Here is what I got to work:
Use the Inject Js Script activity to execute Javascript on the page with the following properties:
InputParameter: To get the last message you sent, use “message-out”. To get the last message you received use “message-in”
ScriptCode:
function(WebElement, className) {
return document.getElementsByClassName(className)[(document.getElementsByClassName(className).length - 1)].querySelector(".copyable-text span span").innerHTML;
};
ScriptOutput: The script’s output will be the message. Store the message in a variable.
I have never used javascript before. Can you send me the xml code with it so i can take a closer look at it please?
Thanks in advance
Here’s an example.
WhatsappExample.zip (18.3 KB)
Note: It takes the message from the currently opened chat. Therefore it requires a chat to be openend. Without it it will throw an exception as the querySelector() in the javascript file returned nothing. Handle this properly in your project.
If you take a close look at the Inject Js Script activity, the InputParameter is set to “message-in”. Use “message-out” to get the out message.
Hope this clarifies things.
Thank you!
I get an error detecting project version when i try to open it. I know it is something probably stupid and basic, but how do i resolve this? If i open it without unzipping, it opens,but it just says missing or invalid activity. Sorry for the stupid questions.I’m just getting started with this software and trying to figure stuff out.