aisingapore / TagUI

Free RPA tool by AI Singapore
Apache License 2.0
5.68k stars 585 forks source link

Reliability issue - use XPath for web elements, bring textarea to focus for keyboard commands #1278

Closed rjkothari closed 3 months ago

rjkothari commented 2 years ago

I tried to use tagui on email client and found that 'click' command works sometimes and other times it clicks slightly away, giving unreliable results.

https://abcd.managewoc.org:2096/ wait 2 // Look in tagui_local.csv in the flow's folder for a value for 'email' and find that element // if tagui_local.csv doesn't exist, then look in tagui_global.csv in tagui/src folder // and tries the same thing, so when the flow is run, it will become // type Email Address as xxxx@abcdefg.xyz type email as user_email type password as user_password Click log-in.png wait 5 Click abcd dkdkfd dfjkdjfd dafkdjkfjdf dfdkdj fd wait 2 Click Plain-text.png wait 3 read (//*[@id="message-htmlpart1"]/div) to message-txt echo 'message-txt' keyboard [ctrl]a keyboard [ctrl]c message_text = clipboard() wait 3 Echo 'message_text' wait 5

Also, noticed following problems:

  1. Getting SyntaxError : Unexpected token "=" (seems to be in this line - read (\*@id=)
  2. copy and paste commands don't work in above code
  3. i wish to use it to copy certain text from 'Notepad' and paste it in Excel. I don't see any way of doing this..
ruthtxh commented 2 years ago

Hi @rjkothari

Visual automation will click on the middle of the picture (log-in.png). Visual automation also depends on several parameters like machine/browser zoom setting, image resolution. For web elements, I would suggest you to use XPath instead of visual automation, for instance:

click //*[@id="login_submit"]

If for some reason you have to stick to visual automation, you can try setting the machine/browser zoom setting to 100% and if you are using macOS, check that the snapshot of the image is 72ppi.

Regarding your other queries:

  1. You can try read //*[@id="message-htmlpart1"]/div to message-txt
  2. & 3. For keyboard commands, you have to bring the text area you want to copy into focus first by doing a visual automation click on the text area (click notepad.png).
rjkothari commented 2 years ago

I tried using XPath, as you can see,. But, it gives syntax error:

Unexpected token "=" (seems to be in this line - read (*@id=)

ruthtxh commented 2 years ago

Hi @rjkothari as mentioned in the comment above, you can try the XPath without the brackets.

rjkothari commented 2 years ago

Getting same error without brackets also. ===== first.tag ===== https://abcd.managewoc.org:2096/ wait 2 // Look in tagui_local.csv in the flow's folder for a value for 'email' and find that element // if tagui_local.csv doesn't exist, then look in tagui_global.csv in tagui/src folder // and tries the same thing, so when the flow is run, it will become // type Email Address as type email as user_email type password as user_password Click log-in.png wait 5 Click abcd dkdkfd dfjkdjfd dafkdjkfjdf dfdkdj fd wait 2 Click Plain-text.png wait 3 read //*[@id="message-htmlpart1"]/div to message-txt echo 'message-txt' keyboard [ctrl]a keyboard [ctrl]c message_text = clipboard() wait 3 Echo 'message_text' wait 5

See error during execution below:

C:\tagui\flows\first>tagui first.tag SyntaxError: Unexpected token '='

phantomjs://code/first.tag.js:2017 in injectJs phantomjs://code/bootstrap.js:456

ruthtxh commented 2 years ago

Hi @rjkothari

I think the error is due to the variable, not XPath.

Try removing the hyphen in the variable like this:

read //*[@id="message-htmlpart1"]/div to messageTxt

Also, FYI to echo the variable you have to wrap them in between backticks and not quotation mark. Backticks are at the top left hand corner of your keyboard `

echo `messageTxt`
rjkothari commented 2 years ago

Ok. It worked a bit. But, I'm unable to make X-Path click work. Only visual click is working properly. Either tagui is not able to 'click' or not able to find X-Path. See recent output below.

START - automation started - Wed Sep 07 2022 16:43:43 GMT https://abcd.managewoc.org:2096/ - Webmail Login

wait 2 type Email Address as xxxx@abcdefg.xyz type Password as xxxxxxx click //*[@id="login-wrapper"] wait 5 Click abcd dkdkfd dfjkdjfd dafkdjkfjdf dfdkdj fd ERROR - cannot find abcd dkdkfd dfjkdjfd dafkdjkfjdf dfdkdj fd

C:\tagui\flows\first>tagui first.tag

START - automation started - Wed Sep 07 2022 16:45:04 GMT https:///abcd.managewoc.org:2096/ - Webmail Login

wait 2 type Email Address as xxxx@abcdefg.xyz type Password as xxxxxxx Click C:/tagui/flows/first/log-in.png wait 5 Click abcd dkdkfd dfjkdjfd dafkdjkfjdf dfdkdj fd wait 2 Click C:/tagui/flows/first/Plain-text.png wait 3 read //*[@id="message-htmlpart1"]/div to MessageTxt *ERROR - cannot find //[@id="message-htmlpart1"]/div**

ruthtxh commented 2 years ago

Hi @rjkothari first I hope this account you're sharing is a dummy or test account. Otherwise please remove the credentials asap.

I am not sure which "Request for the Free SecureNT Intranet SSL Certificate" do you intend to click because there are many similar text that appear on the screen such as the ones on the left like this. image

For the Plain text button, it is nested within an iframe but due to some reasons does not get picked up by the frame step as well. In this case you would have to fall back on visual automation.

Let us know if you face any issues using visual automation.

rjkothari commented 2 years ago

Thanks for your help.

Regarding which request you wish to click, yes, you are right. I thought I will figure it out later.

Visual animation is not reliable. Sometimes it clicks in the centre of the image but most of the time it clicks slightly above on right side or outside the image. I made image bigger also but still same result. i would say it's not reliably working.

rjkothari commented 2 years ago

Also, for last 2 days I'm facing issue with my ISP because TagUI seems to make several unsuccessful login attempts before it manages to login correctly. They have blacklisted my IP several times due to these unsuccessful login attempts.

kensoh commented 3 months ago

Closing but please ping back if this is still relevant or an issue.