Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#513] FIX: Fix error message thrown by selenium exceptions upon wait #512

Merged
merged 1 commit into from
Feb 12, 2024

Conversation

jacekziembla
Copy link
Contributor

Currently we were casting entire exception to the string (including not readable stacktrace) from selenium to error message. Instead, we should pass just the error message.

Before:

.venv/lib/python3.8/site-packages/selene/core/wait.py:143: in for_
     return self._decorator(self)(logic)(fn)
 .venv/lib/python3.8/site-packages/selene/core/wait.py:141: in logic
     raise self._hook_failure(failure)
 E   selene.core.exceptions.TimeoutException: Message: 
 E   
 E   Timed out after 1s, while waiting for:
 E   browser.element(('id', 'UserName')).is present in DOM
 E   
 E   Reason: NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="UserName"]"}
 E     (Session info: chrome=121.0.6167.160); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
 E   Stacktrace:
 E   0   chromedriver                        0x00000001009c0168 chromedriver + 4673896
 E   1   chromedriver                        0x00000001009b79c3 chromedriver + 4639171
 E   2   chromedriver                        0x00000001005abfdd chromedriver + 397277
 E   3   chromedriver                        0x00000001005f7bfc chromedriver + 707580
 E   4   chromedriver                        0x00000001005f7dd1 chromedriver + 708049
 E   5   chromedriver                        0x000000010063c284 chromedriver + 987780
 E   6   chromedriver                        0x000000010061a8ed chromedriver + 850157
 E   7   chromedriver                        0x0000000100639796 chromedriver + 976790
 E   8   chromedriver                        0x000000010061a663 chromedriver + 849507
 E   9   chromedriver                        0x00000001005ea1cf chromedriver + 651727
 E   10  chromedriver                        0x00000001005eb1ae chromedriver + 655790
 E   11  chromedriver                        0x0000000100980380 chromedriver + 4412288
 E   12  chromedriver                        0x0000000100985798 chromedriver + 4433816
 E   13  chromedriver                        0x0000000100964d71 chromedriver + 4300145
 E   14  chromedriver                        0x00000001009864e6 chromedriver + 4437222
 E   15  chromedriver                        0x0000000100956d3c chromedriver + 4242748
 E   16  chromedriver                        0x00000001009a6208 chromedriver + 4567560
 E   17  chromedriver                        0x00000001009a63be chromedriver + 4567998
 E   18  chromedriver                        0x00000001009b7603 chromedriver + 4638211
 E   19  libsystem_pthread.dylib             0x00007ff805e53202 _pthread_start + 99
 E   20  libsystem_pthread.dylib             0x00007ff805e4ebab thread_start + 15

After:

.venv/lib/python3.8/site-packages/selene/core/wait.py:141: in for_
     return self._decorator(self)(logic)(fn)
 .venv/lib/python3.8/site-packages/selene/core/wait.py:139: in logic
     raise self._hook_failure(failure)
 E selene.core.exceptions.TimeoutException: Message: 
 E   
 E Timed out after 1s, while waiting for:
 E browser.element(('id', 'UserName')).is present in DOM
 E   
 E Reason: NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"[id="UserName"]"}
 E (Session info: chrome=121.0.6167.160); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception

@jacekziembla
Copy link
Contributor Author

jacekziembla commented Feb 9, 2024

@yashaka apologizes that I did not create issue first, should be linked now. I edited it via GitHub UI without cloning and did not run mypy check as well - although the change is really tiny (I've checked if it's working by editing directly source files in my venv)

@jacekziembla jacekziembla changed the title FIX: Fix error message thrown by selenium exceptions upon wait [#513] FIX: Fix error message thrown by selenium exceptions upon wait Feb 9, 2024
@jacekziembla
Copy link
Contributor Author

based on the linters and tests, I guess it should be smth like

message=getattr(reason, "msg", None)

@jacekziembla
Copy link
Contributor Author

jacekziembla commented Feb 10, 2024

I have run black locally, this check should be passing now. There are ~5 tests that needs to be fixed, as the reason string changed and we do not have 'Stacktrace: *', now, but I was unable to kick these tests locally without browserstack key

@jacekziembla
Copy link
Contributor Author

I have run black locally, this check should be passing now. There are ~5 tests that needs to be fixed, as the reason string changed and we do not have 'Stacktrace: *', now, but I was unable to kick these tests locally without browserstack key

Modified error_messages tests, also in case there is no original error message we fallback to previous behavior of casting the error to string

Currently we were casting entire exception to the string (including not readable stacktrace) from selenium to error message. Instead, we should pass just the error message
@yashaka
Copy link
Owner

yashaka commented Feb 12, 2024

Modified error_messages tests, also in case there is no original error message we fallback to previous behavior of casting the error to string

yes, this was something that I felt was absent... great that you found it!

@yashaka yashaka merged commit e3bfdbb into yashaka:master Feb 12, 2024
4 of 7 checks passed
github-actions bot added a commit that referenced this pull request Feb 12, 2024
[#513] FIX: Fix error message thrown by selenium exceptions upon wait
@jacekziembla
Copy link
Contributor Author

Great, thanks! Waiting for next release 🤞

@yashaka
Copy link
Owner

yashaka commented Feb 13, 2024

https://github.com/yashaka/selene/releases/tag/2.0.0rc8 ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants