Comments (8)
@kensoh I did some tests, using the coordinates returned in the tagui log, I used the following code to screenshot and it works fine on both Windows and Centos.
import rpa as r
import json
from websocket import create_connection
import base64
import requests
r.init()
r.url('https://baidu.com')
r.wait(2)
res = requests.get('http://localhost:9222/json').content
# print(json.loads(res.decode('utf-8'))[0]['webSocketDebuggerUrl'])
wsconn = json.loads(res.decode('utf-8'))[0]['webSocketDebuggerUrl']
ws = create_connection(wsconn,suppress_origin=True)
# r.snap('//img[ @id=\"s_lg_img\" ]','1111.png')
# centos
# [12] {"id":12,"result":{"result":{"type":"object","value":{"top":44,"left":526,"width":270,"height":129}}}}
# windows
# [8] {"id":8,"result":{"result":{"type":"object","value":{"top":44,"left":540,"width":270,"height":129}}}}
# do snap
# [9] {"id":9,"method":"Page.captureScreenshot","params":{"format":"png","quality":80,"clip":{"x":548,"y":44,"width":270,"height":129,"scale":1},"fromSurface":true}}
request = {}
request['id'] = 1
request['method'] = 'Page.captureScreenshot'
request['params'] = {"format":"png","quality":80,"clip":{"x":526,"y":44,"width":270,"height":129,"scale":1},"fromSurface":True}
ws.send(json.dumps(request))
result = ws.recv()
png = json.loads(result)['result']['data']
rpng = base64.b64decode(png)
# print(base64.b64decode(rpng))
open('testbaidu.png','wb').write(rpng)
ws.close()
r.wait(10)
How to continue troubleshooting this problem?
from rpa-python.
I tested the site "baidu.com" and reproduced the problem.
Linux system:
r.snap('//img[ @id="s_lg_img" ]','222.png')
the result is the entire web page
Windows system:
r.snap('//img[ @id="s_lg_img" ]','222.png')
it is the correct element
from rpa-python.
Hi @yucongshub thanks for raising this! The backend API only returns what Chrome returns. So my initial hunch is there might be some change or bug in Chrome in Linux that could be the root cause. And this is the first report of such issue.
I've tried replicating on Mac and it is also working fine -
RPA:Desktop kensoh$ python3
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 16:52:21)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpa as r
>>> r.init()
True
>>> r.url('www.baidu.com')
True
>>> r.snap('//img[ @id="s_lg_img" ]','222.png')
True
I have a Linux VPS but it is an old CentOS so I can't run Chrome there. Can you share with me the log file after running the snap() step from your Linux machine? I think you can directly attach the file here. It can be found by print(r.tagui_location())
and then go to .tagui/src/tagui_chrome.log
That is the transaction log between the TagUI engine and Chrome browser through websocket connection. So it contains the exact and entire low-level information returned from Chrome.
from rpa-python.
Adding on @yucongshub - I've tried using the Google Colab notebook example (which runs on Ubuntu) and it appears to be working correctly. The notebook example link is the following and found on README.md page of this repo -
https://colab.research.google.com/drive/1or8DtXZP8ZxJYK52me0dA6O9A1dXKKOE?usp=sharing
Using the following lines, I have downloaded the log file and attaching it below for comparison later.
log_file = r.tagui_location() + '/.tagui/src/tagui_chrome.log'
from google.colab import files; files.download(log_file)
from rpa-python.
Hi @kensoh , I tested again and provided the previous and this time log files. I saw that the difference between the log files you provided is that there are no pixel coordinates in Page.captureScreenshot
?
tagui_chrome.log.2024.1.15.log
tagui_chrome.log.2024.1.11.log
from rpa-python.
Hi @yucongshub can you tell me more what do you mean? Can you share more on what is the difference between on your Linux and the example using Google Colab Ubuntu? Is it your Linux doesn't return coordinates and the Google Colab Ubuntu returns?
If on your Linux there is no coordinates returned, then you can't use workaround to capture the screenshot. Unless you use another system to first collect the coordinates and hard code the solution on your Linux system. Otherwise directly on Linux you don't have those coordinates to use the workaround.
What is your Linux and version? I suspect it might be some Linux/Chrome edge case issue that is hard to replicate on other Linux/Chrome. The solution might be to use the one you shared above, collect the coordinates on another machine and use them to do the screen shot on your Linux/Chrome.
from rpa-python.
Hi @kensoh , The Linux operating environment I use is centos7.9. I tested it in Windows, google colab, and centos7.9. Windows and google colab returned the correct element screenshots, but centos7.9 was wrong. Its coordinates and screenshot codes The execution order seems different from windows and google colab. How can I debug the order of obtaining element coordinates and taking screenshots? I want to compare and see how windows and centos7.9 run. I have provided the log files of the three, you can check from the logs.
tagui_chrome.log.google-colab.log
tagui_chrome.log.windows.log
tagui_chrome.log.centos7.log
from rpa-python.
Related Issues (20)
- How do I use rpa.init() in PyScript or Pyodide? - try this local hacks to see if they work HOT 2
- After python is packaged as an exe, an error occurs - try using .bat .cmd or shell script HOT 1
- Using reCAPTCHA keys to bypass - those are for the actual website owner for testing HOT 5
- Text not found - r.click() with OCR text by using "Text I want to click on.png" syntax HOT 7
- Out of memory problem - Chrome browser is memory hog, can explore that angle HOT 6
- Linux环境下运行 - pending replication details (maybe can't connect to Chrome) HOT 11
- Will there be support for automation of desktop apps - already, visual automation HOT 2
- Correct estimation of the operation execution time HOT 2
- The problem with Cyrillic in r.keyboard()
- "Speeding up" the search for objects on the screen. HOT 2
- During visual automation, when Chrome pops up, it blocks the program on the desktop
- frame() does not work properly when crossing domain
- use document for context
- dom() returns empty string
- Run rpa in centos error. Setting headless_mode=True, i have no response; When i setting headless_mode=False return error
- r.init() hang on cloned virtual machine
- How to use edge web browser
- r.url("https://www.baidu.com") HOT 1
- 运行可以打开浏览器,但是浏览器显示崩溃
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rpa-python.