Closed kitsune0n closed 3 weeks ago
A SeleniumBase script must end naturally for the recording to be created from recorded actions when using Recorder Mode. Don't quit the driver before that. The recorded script is finalized during the tearDown()
phase.
See the Recorder Mode ReadMe for full instructions.
Thx @mdmintz tearDown() help's. But have troubles with sessionStorage url open by self.open() like in readme trying with and without uc mode Error:
`Traceback (most recent call last):
File "C:\Users\mrsta\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\seleniumbase\plugins\sb_manager.py", line 944, in SB
yield sb
File "C:\Users\mrsta\PycharmProjects\CryptoBot\main.py", line 100, in <module>
sb.tearDown()
File "C:\Users\mrsta\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\seleniumbase\fixtures\base_case.py", line 15857, in tearDown
self.__process_recorded_actions()
File "C:\Users\mrsta\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\seleniumbase\fixtures\base_case.py", line 4651, in __process_recorded_actions
tab_actions = self.__get_recorded_actions_on_active_tab()
File "C:\Users\mrsta\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\seleniumbase\fixtures\base_case.py", line 4632, in __get_recorded_actions_on_active_tab
actions = self.get_session_storage_item("recorded_actions")
File "C:\Users\mrsta\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\seleniumbase\fixtures\base_case.py", line 8519, in get_session_storage_item
raise WebDriverException("Session Storage is not available here!")
selenium.common.exceptions.WebDriverException: Message: Session Storage is not available here!
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\mrsta\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\seleniumbase\plugins\sb_manager.py", line 971, in SB
sb.tearDown()
File "C:\Users\mrsta\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\seleniumbase\fixtures\base_case.py", line 15857, in tearDown
self.__process_recorded_actions()
File "C:\Users\mrsta\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\seleniumbase\fixtures\base_case.py", line 4649, in __process_recorded_actions
for window in self.driver.window_handles:
File "C:\Users\mrsta\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\selenium\webdriver\remote\webdriver.py", line 494, in window_handles
return self.execute(Command.W3C_GET_WINDOW_HANDLES)["value"]
File "C:\Users\mrsta\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\selenium\webdriver\remote\webdriver.py", line 347, in execute
self.error_handler.check_response(response)
File "C:\Users\mrsta\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: disconnected: Unable to receive message from renderer
(failed to check if window was closed: disconnected: not connected to DevTools)
(Session info: chrome=125.0.6422.142)
Stacktrace:
GetHandleVerifier [0x00007FF695D91F52+60322]
(No symbol) [0x00007FF695D0CEC9]
(No symbol) [0x00007FF695BC7EBA]
(No symbol) [0x00007FF695BB070D]
(No symbol) [0x00007FF695BAE39D]
(No symbol) [0x00007FF695BAEBAF]
(No symbol) [0x00007FF695BC84E3]
(No symbol) [0x00007FF695B9D08C]
(No symbol) [0x00007FF695C4B697]
(No symbol) [0x00007FF695C3C1E0]
(No symbol) [0x00007FF695C09617]
(No symbol) [0x00007FF695C0A211]
GetHandleVerifier [0x00007FF6960A94AD+3301629]
GetHandleVerifier [0x00007FF6960F36D3+3605283]
GetHandleVerifier [0x00007FF6960E9450+3563680]
GetHandleVerifier [0x00007FF695E44326+790390]
(No symbol) [0x00007FF695D1750F]
(No symbol) [0x00007FF695D13404]
(No symbol) [0x00007FF695D13592]
(No symbol) [0x00007FF695D02F9F]
BaseThreadInitThunk [0x00007FFB1BC4257D+29]
RtlUserThreadStart [0x00007FFB1D08AA48+40]
Traceback (most recent call last):
File "C:\Users\mrsta\PycharmProjects\CryptoBot\main.py", line 100, in <module>
sb.tearDown()
File "C:\Users\mrsta\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\seleniumbase\fixtures\base_case.py", line 15857, in tearDown
self.__process_recorded_actions()
File "C:\Users\mrsta\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\seleniumbase\fixtures\base_case.py", line 4651, in __process_recorded_actions
tab_actions = self.__get_recorded_actions_on_active_tab()
File "C:\Users\mrsta\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\seleniumbase\fixtures\base_case.py", line 4632, in __get_recorded_actions_on_active_tab
actions = self.get_session_storage_item("recorded_actions")
File "C:\Users\mrsta\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\seleniumbase\fixtures\base_case.py", line 8519, in get_session_storage_item
raise WebDriverException("Session Storage is not available here!")
selenium.common.exceptions.WebDriverException: Message: Session Storage is not available here!`
Session Storage is only available on http
and https
URLs.
Session Storage is only available on
http
andhttps
URLs.
Yes. I open https url @mdmintz step by step:
Here's an example of using it from SB()
:
from seleniumbase import SB
with SB(recorder_ext=True) as sb:
sb.open("seleniumbase.io/simple/login")
sb.type("#username", "demo_user")
sb.type("#password", "secret_pass")
sb.click('a:contains("Sign in")')
sb.assert_exact_text("Welcome!", "h1")
sb.assert_element("img#image1")
sb.highlight("#image1")
sb.click_link("Sign out")
sb.assert_text("signed out", "#top_message")
Call a breakpoint()
on a line where you want to insert manual actions to record.
Type c
on the command-line and press Enter/Return
to continue from the breakpoint()
.
At the end of the script, the recording will be generated automatically.
Here's an example of using it from
SB()
:from seleniumbase import SB with SB(recorder_ext=True) as sb: sb.open("seleniumbase.io/simple/login") sb.type("#username", "demo_user") sb.type("#password", "secret_pass") sb.click('a:contains("Sign in")') sb.assert_exact_text("Welcome!", "h1") sb.assert_element("img#image1") sb.highlight("#image1") sb.click_link("Sign out") sb.assert_text("signed out", "#top_message")
Call a
breakpoint()
on a line where you want to insert manual actions to record. Typec
on the command-line and pressEnter/Return
to continue from thebreakpoint()
. At the end of the script, the recording will be generated automatically.
thx I find what is the problem I added by the plugin of Extense_Dir = Metamask_Extance_path open its web page that interferes with record. Is there anyway to ignore this with record extension ? or only use activate_recorder() for 1 page record ? can i make custom name of the records ?
When using seleniumbase in my python app as from seleniumbase import SB i understand have two options for using recording in my code recorder_ext=True with extension and activate_recorder() without extension
how i can stop recording and save?
trying to use import pdb; pdb.set_trace() after activate_recorder() but this only works with pytest ? or save_recorded_actions() after activate_recorder() and have only msg
Recorder Mode ACTIVE. [ESC]: Pause. [~
]: Resume.`Of course, in my case, extension would have approached more, it works when i add recorder_ext=True
SB(uc=True, disable_js=False, headless=False, recorder_ext=True, extension_dir=MY_EXTENSION_PATH, locale_code="en")
but with driver.quit () I do not see any saved records, do I need to execute additional commands to complete the recording and saving the file?