Skip to content

Commit 4b52668

Browse files
committed
Handle PhantomJS deprecation warnings
1 parent d54651b commit 4b52668

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

seleniumbase/core/browser_launcher.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import warnings
12
from selenium import webdriver
23
from selenium.common.exceptions import WebDriverException
34
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
@@ -112,10 +113,13 @@ def get_remote_driver(browser_name, headless, servername, port):
112113
desired_capabilities=(
113114
webdriver.DesiredCapabilities.SAFARI))
114115
if browser_name == constants.Browser.PHANTOM_JS:
115-
return webdriver.Remote(
116-
command_executor=address,
117-
desired_capabilities=(
118-
webdriver.DesiredCapabilities.PHANTOMJS))
116+
with warnings.catch_warnings():
117+
# Ignore "PhantomJS has been deprecated" UserWarning
118+
warnings.simplefilter("ignore", category=UserWarning)
119+
return webdriver.Remote(
120+
command_executor=address,
121+
desired_capabilities=(
122+
webdriver.DesiredCapabilities.PHANTOMJS))
119123

120124

121125
def get_local_driver(browser_name, headless):
@@ -158,7 +162,10 @@ def get_local_driver(browser_name, headless):
158162
if browser_name == constants.Browser.SAFARI:
159163
return webdriver.Safari()
160164
if browser_name == constants.Browser.PHANTOM_JS:
161-
return webdriver.PhantomJS()
165+
with warnings.catch_warnings():
166+
# Ignore "PhantomJS has been deprecated" UserWarning
167+
warnings.simplefilter("ignore", category=UserWarning)
168+
return webdriver.PhantomJS()
162169
if browser_name == constants.Browser.GOOGLE_CHROME:
163170
try:
164171
chrome_options = webdriver.ChromeOptions()

0 commit comments

Comments
 (0)