Skip to content

Fix issue with printing file paths that contain spaces #1042

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

Merged
merged 4 commits into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion help_docs/recorder_mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<img src="https://seleniumbase.io/cdn/img/sb_recorder_notification.png" title="SeleniumBase" width="380">

(This tutorial assumes you are using SeleniumBase version ``2.0.8`` or newer.)
(This tutorial assumes you are using SeleniumBase version ``2.0.10`` or newer.)

🔴 To make a new recording with Recorder Mode, you can use ``sbase mkrec`` or ``sbase codegen``):

Expand Down
2 changes: 1 addition & 1 deletion seleniumbase/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "2.0.9"
__version__ = "2.0.10"
7 changes: 6 additions & 1 deletion seleniumbase/console_scripts/sb_mkchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,12 @@ def main():
file = codecs.open(file_path, "w+", "utf-8")
file.writelines("\r\n".join(data))
file.close()
os.system("sbase print %s -n" % file_name)
if " " not in file_name:
os.system("sbase print %s -n" % file_name)
elif '"' not in file_name:
os.system('sbase print "%s" -n' % file_name)
else:
os.system("sbase print '%s' -n" % file_name)
success = (
"\n" + c1 + '* Chart Presentation: "' + file_name + '" was created! *'
"" + cr + "\n"
Expand Down
7 changes: 6 additions & 1 deletion seleniumbase/console_scripts/sb_mkdir.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,12 @@ def main():
file = codecs.open(file_path, "w+", "utf-8")
file.writelines("\r\n".join(data))
file.close()
os.system("sbase print %s -n" % file_path)
if " " not in file_path:
os.system("sbase print %s -n" % file_path)
elif '"' not in file_path:
os.system('sbase print "%s" -n' % file_path)
else:
os.system("sbase print '%s' -n" % file_path)
os.remove(file_path)

success = (
Expand Down
7 changes: 6 additions & 1 deletion seleniumbase/console_scripts/sb_mkfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,12 @@ def main():
file = codecs.open(file_path, "w+", "utf-8")
file.writelines("\r\n".join(data))
file.close()
os.system("sbase print %s -n" % file_name)
if " " not in file_name:
os.system("sbase print %s -n" % file_name)
elif '"' not in file_name:
os.system('sbase print "%s" -n' % file_name)
else:
os.system("sbase print '%s' -n" % file_name)
success = (
"\n" + c1 + '* Test file: "' + file_name + '" was created! *'
"" + cr + "\n"
Expand Down
7 changes: 6 additions & 1 deletion seleniumbase/console_scripts/sb_mkpres.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,12 @@ def main():
file = codecs.open(file_path, "w+", "utf-8")
file.writelines("\r\n".join(data))
file.close()
os.system("sbase print %s -n" % file_name)
if " " not in file_name:
os.system("sbase print %s -n" % file_name)
elif '"' not in file_name:
os.system('sbase print "%s" -n' % file_name)
else:
os.system("sbase print '%s' -n" % file_name)
success = (
"\n" + c1 + '* Presentation: "' + file_name + '" was created! *'
"" + cr + "\n"
Expand Down
7 changes: 6 additions & 1 deletion seleniumbase/console_scripts/sb_mkrec.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,12 @@ def main():
recorded_filename = file_name[:-3] + "_rec.py"
recordings_dir = os.path.join(dir_name, "recordings")
recorded_file = os.path.join(recordings_dir, recorded_filename)
os.system("sbase print %s -n" % recorded_file)
if " " not in recorded_file:
os.system("sbase print %s -n" % recorded_file)
elif '"' not in recorded_file:
os.system('sbase print "%s" -n' % recorded_file)
else:
os.system("sbase print '%s' -n" % recorded_file)
shutil.copy(recorded_file, file_path)
success = (
"\n" + c2 + "***" + cr + " RECORDING COPIED to: "
Expand Down
18 changes: 9 additions & 9 deletions seleniumbase/core/browser_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import urllib3
import warnings
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as Chrome_Service
from selenium.webdriver.edge.service import Service as Edge_Service
from selenium.webdriver.firefox.service import Service as Firefox_Service
from selenium.webdriver.chrome.service import Service as ChromeService
from selenium.webdriver.edge.service import Service as EdgeService
from selenium.webdriver.firefox.service import Service as FirefoxService
from seleniumbase.config import settings
from seleniumbase.core import download_helper
from seleniumbase.core import proxy_helper
Expand Down Expand Up @@ -123,7 +123,7 @@ def _repair_chromedriver(chrome_options, headless_options):
)
try:
if selenium4:
service = Chrome_Service(
service = ChromeService(
executable_path=LOCAL_CHROMEDRIVER)
driver = webdriver.Chrome(
service=service,
Expand Down Expand Up @@ -1150,7 +1150,7 @@ def get_local_driver(
else:
if os.path.exists(LOCAL_GECKODRIVER):
if selenium4:
service = Firefox_Service(
service = FirefoxService(
executable_path=LOCAL_GECKODRIVER)
return webdriver.Firefox(
service=service,
Expand Down Expand Up @@ -1431,7 +1431,7 @@ def get_local_driver(
edge_options.add_argument(chromium_arg_item)
if selenium4:
try:
service = Edge_Service(executable_path=LOCAL_EDGEDRIVER)
service = EdgeService(executable_path=LOCAL_EDGEDRIVER)
driver = Edge(service=service, options=edge_options)
except Exception as e:
auto_upgrade_edgedriver = False
Expand Down Expand Up @@ -1459,7 +1459,7 @@ def get_local_driver(
if not _was_chromedriver_repaired(): # Works for Edge
_repair_edgedriver(edge_version)
_mark_chromedriver_repaired() # Works for Edge
service = Edge_Service(executable_path=LOCAL_EDGEDRIVER)
service = EdgeService(executable_path=LOCAL_EDGEDRIVER)
driver = Edge(service=service, options=edge_options)
return driver
else:
Expand Down Expand Up @@ -1636,7 +1636,7 @@ def get_local_driver(
try:
if os.path.exists(LOCAL_CHROMEDRIVER):
if selenium4:
service = Chrome_Service(
service = ChromeService(
executable_path=LOCAL_CHROMEDRIVER)
driver = webdriver.Chrome(
service=service,
Expand Down Expand Up @@ -1715,7 +1715,7 @@ def get_local_driver(
_mark_chromedriver_repaired()
if os.path.exists(LOCAL_CHROMEDRIVER):
if selenium4:
service = Chrome_Service(
service = ChromeService(
executable_path=LOCAL_CHROMEDRIVER)
driver = webdriver.Chrome(
service=service,
Expand Down