droefs / HLISA

A reimplementation of the Selenium API, emulating human interactions
https://pypi.org/project/HLISA/
GNU General Public License v3.0
73 stars 8 forks source link

`utils.get_cursor_coordinates()` fails to obtain cursor position in chromium-based webdrivers #42

Closed ajanderson1 closed 10 months ago

ajanderson1 commented 1 year ago

Encountered errors arising from HLISA.utils.get_cursor_coordinates() failing to retrieve cursor coords with Error NoCursorCoordinatesException.

The selenium error message: MoveTargetOutOfBoundsException does not appear to contain such information.

I will keep investigating and perhaps try a PR if I have any suggestions. In the meantime, would be interested to know if anyone concurs. + apols if I'm incorrect here!

Steps to reproduce: as per 'Usage Example' from README:

driver.get('https://stackoverflow.com/')
my_element = driver.find_element('xpath', '/html/body/header/div/a[1]')
actions = HLISA_ActionChains(driver)
actions.move_to_element(my_element)
actions.click()
actions.perform()

Have very much enjoyed working through HLISA - Thanks for all the work + the research paper HLISA: towards a more reliable measurement tool

camara1996 commented 1 year ago

I have exactly the same problem with the same code execution.

Apparently its failing to convert the coordinates of the cursor from string to int giving this exception:

Traceback (most recent call last): File "/home/me/.local/lib/python3.10/site-packages/HLISA/util.py", line 162, in get_cursor_coordinates x = int(x) ValueError: invalid literal for int() with base 10: 'ove t'

Any tips please ? Thanks for your work and contribution to the community.

droefs commented 1 year ago

Thank you ajanderson and camara1996 for reporting and investigating this issue! This issue is a duplicate of #31. I am sorry you spend time on this while the issue was already known. I will make it more clear in HLISA that this is a known issue.

The selenium error message: https://www.selenium.dev/selenium/docs/api/py/common/selenium.common.exceptions.html#selenium.common.exceptions.MoveTargetOutOfBoundsException does not (any longer at least) appear to contain such information.

You are correct that the error message does not provide the required information when using Selenium, but only in combination with a Chromium-based browser. The message in the error is not generated Selenium, but by the webdriver that is used in combination with Selenium, which is ChromeDriver in the case of chromium-based browsers (like Google Chrome). ChromeDriver does not provide the required information in it's error message. That is very unfortunate, as to my knowledge, there is no other way to get this information. The information is required for HLISA to function reliably.

ChromeDriver can provide the required information. I have opened an issue at the ChromeDriver repository with the request to review my code that lets ChromeDriver pass the required information. Unfortunately, this request was declined due to a lack of capacity at the ChromeDriver project. As my code has to be reviewed before it can be merged into ChromeDriver, this issue cannot be resolved at this moment. I will request the required code to be merged into ChromeDriver again in the near future, maybe the capacity problem is resolved by then.

For the time being, it is possible to use Firefox, which should work without any problem. Alternatively, it is possibly to use HLISA 1.4.1 (pip install HLISA==1.4.1) in combination with Chromium based browsers, but HLISA 1.4.1 contains a bug that can cause mouse movements to wrong locations. Therefore I would strongly advise to use Firefox if that is possible.

ajanderson1 commented 1 year ago

@droefs, thanks for the speedy response.

This issue is a duplicate of #31.

Apols, I missed that - have updated title to better reflect issue for those looking this up in future.

Works with firefox webdriver as you suggest. Thanks! Will come back if i have any further bright ideas.