Skip to content

Commit aba17f0

Browse files
authored
fix: tune quit in start_driver to not raise an exception there (#985)
* fix: set nil to avoid duplicated delete request * tune the quit a bit * fix lint * leave todo
1 parent 9461d7a commit aba17f0

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/appium_lib/driver.rb

+10-1
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,9 @@ def element_screenshot(element, png_save_path)
459459
# @return [void]
460460
def driver_quit
461461
@driver&.quit
462+
@driver = nil
463+
rescue Selenium::WebDriver::Error::WebDriverError
464+
nil
462465
end
463466
alias quit_driver driver_quit
464467

@@ -521,7 +524,13 @@ def window_rect
521524
# @return [Selenium::WebDriver] the new global driver
522525
def start_driver(http_client_ops =
523526
{ http_client: ::Appium::Http::Default.new, open_timeout: 999_999, read_timeout: 999_999 })
524-
@core.driver&.quit
527+
528+
# TODO: do not kill the previous session in the future version.
529+
if $driver.nil?
530+
driver_quit
531+
else
532+
$driver.driver_quit
533+
end
525534

526535
# If automationName is set only in server side, then the following automation_name should be nil before
527536
# starting driver.

0 commit comments

Comments
 (0)