aisingapore / TagUI

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

Some questions about iframe need to ask you - use this syntax for subframe #1386

Closed XiaoluoMax closed 2 months ago

XiaoluoMax commented 2 months ago

80B47FC8-3DA6-4E83-8695-CABFFF31310A

71F405F4-050A-4045-96F7-7EA7544A852B Hello developers, some questions about iframe need to ask you 2AB90700-CEB4-4F8F-A725-9D0407ECA8D3 Figure 3 is my run window command, stuck in the last sentence 26073E17-F4F5-4541-AB10-2A2EA7DD6DD6 Figure 4 is my code statement

XiaoluoMax commented 2 months ago

Figure 4 is my code statement and Figure 3 is my run window command, which is stuck in the last sentence. As you can see, I tried to operate RPA to click a button, but it was in the second iframe, so I could not select this element. Is there any good way?

kensoh commented 2 months ago

Hi @XiaoluoMax the syntax for subframe is this

frame [frame name] | [subframe name]
    steps
frame forwardFrame | mainiframe
    steps

More info at the docs - https://tagui.readthedocs.io/en/latest/reference.html#frame

XiaoluoMax commented 2 months ago

Hi developer, I have tried many times and still can't get me to successfully click on the button element in the iframe, is there any way to print which frame I am currently in ![Uploading 5EF1EA6F-8A3F-4752-87B3-14DA8688E492.png…]()

XiaoluoMax commented 2 months ago

37F76703-432D-4E83-94C2-1729D1F8EDC4

XiaoluoMax commented 2 months ago

These are some additional errors, although I don't know what he means

[tagui] INPUT - [62] {"id":62,"method":"Runtime.evaluate","params":{"expression":"var result_bounds = document.evaluate('(//frame|//iframe)[@name=\"mainiframe\" or @id=\"mainiframe\"]',mainframe_context,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null).snapshotItem(0).getBoundingClientRect(); var result_rect = {top: Math.round(result_bounds.top), left: Math.round(result_bounds.left), width: Math.round(result_bounds.width), height: Math.round(result_bounds.height)}; result_rect","returnByValue":true}} [tagui] OUTPUT - [62] {"id":62,"result":{"result":{"type":"object","subtype":"error","className":"TypeError","description":"TypeError: Cannot read properties of null (reading 'getBoundingClientRect')\n at :1:183","objectId":"7072152145493749342.7.4"},"exceptionDetails":{"exceptionId":1,"text":"Uncaught","lineNumber":0,"columnNumber":182,"scriptId":"136","exception":{"type":"object","subtype":"error","className":"TypeError","description":"TypeError: Cannot read properties of null (reading 'getBoundingClientRect')\n at :1:183","objectId":"7072152145493749342.7.5"}}}}

[tagui] INPUT - [63] {"id":63,"method":"Runtime.evaluate","params":{"expression":"subframe_context = document.evaluate('(//frame|//iframe)[@name=\"mainiframe\" or @id=\"mainiframe\"]',mainframe_context,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null).snapshotItem(0).contentDocument"}} [tagui] OUTPUT - [63] {"id":63,"result":{"result":{"type":"object","subtype":"error","className":"TypeError","description":"TypeError: Cannot read properties of null (reading 'contentDocument')\n at :1:182","objectId":"7072152145493749342.7.6"},"exceptionDetails":{"exceptionId":2,"text":"Uncaught","lineNumber":0,"columnNumber":181,"scriptId":"137","exception":{"type":"object","subtype":"error","className":"TypeError","description":"TypeError: Cannot read properties of null (reading 'contentDocument')\n at :1:182","objectId":"7072152145493749342.7.7"}}}}

kensoh commented 2 months ago

Hi @XiaoluoMax from above it looks like the subframe cannot be found for some reason. Are you able to access and visit the URL directly for the subframe? If you can you can automate that directly. The URL is the one just below the mainframe line in your first screenshot.

Otherwise, is your website accessible to public so I can have a look? If accessible can you share your code that can show this error?

XiaoluoMax commented 2 months ago

Hello developer, due to some security issues, the website cannot be opened to the public, but I think it may be the problem of the new TAB page. Which one is right below the first screen shot you mentioned? Please help me point out. As you can see, I first searched the page I need to enter in the search bar (1) of the home page. Then click to enter the search results page (2), and the elements in operation (2) are needed, and the code screenshots are also the elements in leaf page (2). Do I need to use "popup "when switching? 8BD5809B-A255-45E5-A3A8-D5444EF10D61 3E5628FF-835B-4287-9CCF-6EF9DAF3EA5B

marcelocecin commented 2 months ago

Hi, if your automation is web only, try using the https://www.automa.site

XiaoluoMax commented 2 months ago

Hello developers, my problem about iframe has been solved, now when I encounter to switch a new TAB page, the URL will change and there is no way to use "popup" to switch 8C9C0518-7441-4FF9-BF91-13D152481D45 B9A0E0DF-4861-4CD6-972B-827F2D19D9AC

kensoh commented 2 months ago

Hi @XiaoluoMax wow, this is tricky. There are 2 ways you can explore.

First way is you just need a small part of URL. Will using below work? It might work if parent page does not have this below in its URL.

popup ifr?page

Second way is are you able to see or read the URL from parent page then visit that page directly instead of using frame?

XiaoluoMax commented 2 months ago

Developer hello, the first way does not work, the parent page into the child page ulr changes only the "page" behind the variable, is there any way can be opened in the page, get the time variable number, because the number variable of this website is year, month, day, hour and minute seconds, can only wait until the page opens to get the correct variable, Is there anything you can do about the second option 1D8C8C23-266C-45BC-8112-C4CDC81F4145 CCC73A3E-F693-4084-AF25-D89036F6274F The ones that are all numbers are the subpages

kensoh commented 2 months ago

It sounds like it can't be automated. If you use visual automation and keyboard() on the popup new tab would it work for your use case? Otherwise I suspect that this scenario is not doable with the tool.

One last thing you can try is after new tab opens up, you do something like below. This forces popup() to point at the new tab because the parent tab is now pointing to google.com and does not have the 'page=' string in the URL.

https://google.com popup page=

XiaoluoMax commented 2 months ago

I'm sorry I don't understand what you mean, but I think I can restore the situation I encountered. The "page" content of the second subpage is a variable. How should I switch from the first subpage to the second subpage 84799C6B-9485-4F92-8EE2-8D7054B4A05E F600BD31-357F-445E-882D-0BBCCC5F8951 BE2680CD-5030-4C9A-8692-C47848384F41

kensoh commented 2 months ago

Hi @XiaoluoMax what I mean is after new tab appears, try the following to see if you can you get access to the new tab -

https://google.com popup page= other steps

kensoh commented 2 months ago

But if there is a new tab and another new tab with very similar URLs other than the page ID which is random, I don't think this tool can easily or possibly automate this scenario.

kensoh commented 2 months ago

(Closing issue for now but will look out for reply)