Skip to content

Commit

Permalink
[py]: #11093 - The SessionId shouldn't be added to params themself bu… (
Browse files Browse the repository at this point in the history
#11121)

* [py]: #11093 - The SessionId shouldn't be added to params themself but to a copy of them.

* [py] Add an unit test to check the session id is not preserved in print options after a page is printed.

* [py] Update the test_session_id_is_not_preserved_after_page_is_printed test to comply with coding conventions.
  • Loading branch information
tvataire committed Oct 29, 2022
1 parent aa23847 commit e2542bb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion py/selenium/webdriver/remote/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,13 +431,14 @@ def execute(self, driver_command: str, params: dict = None) -> dict:
:Returns:
The command's JSON response loaded into a dictionary object.
"""
params = self._wrap_value(params)

if self.session_id:
if not params:
params = {"sessionId": self.session_id}
elif "sessionId" not in params:
params["sessionId"] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
self.error_handler.check_response(response)
Expand Down
9 changes: 9 additions & 0 deletions py/test/selenium/webdriver/common/print_pdf_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,12 @@ def test_valid_params(driver, pages):
base64code = driver.print_page(print_options)

assert base64code[START_INDEX:END_INDEX] == PDF_MAGIC_NUMBER


def test_session_id_is_not_preserved_after_page_is_printed(driver, pages):
print_options = PrintOptions()
print_options.margin_bottom = print_options.margin_top = print_options.margin_left = print_options.margin_right = 0
assert "sessionId" not in print_options.to_dict()
pages.load("printPage.html")
driver.print_page(print_options=print_options)
assert "sessionId" not in print_options.to_dict()

0 comments on commit e2542bb

Please sign in to comment.