|
| 1 | +import warnings |
1 | 2 | from selenium import webdriver
|
2 | 3 | from selenium.common.exceptions import WebDriverException
|
3 | 4 | from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
@@ -112,10 +113,13 @@ def get_remote_driver(browser_name, headless, servername, port):
|
112 | 113 | desired_capabilities=(
|
113 | 114 | webdriver.DesiredCapabilities.SAFARI))
|
114 | 115 | 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)) |
119 | 123 |
|
120 | 124 |
|
121 | 125 | def get_local_driver(browser_name, headless):
|
@@ -158,7 +162,10 @@ def get_local_driver(browser_name, headless):
|
158 | 162 | if browser_name == constants.Browser.SAFARI:
|
159 | 163 | return webdriver.Safari()
|
160 | 164 | 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() |
162 | 169 | if browser_name == constants.Browser.GOOGLE_CHROME:
|
163 | 170 | try:
|
164 | 171 | chrome_options = webdriver.ChromeOptions()
|
|
0 commit comments