Skip to content

Commit

Permalink
PhantomJS driver will be removed in selenium 4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippSelenium authored and BeyondEvil committed Jun 23, 2020
1 parent 4e085ed commit 658c713
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
8 changes: 7 additions & 1 deletion pytest_selenium/pytest_selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import argparse
import copy
from datetime import datetime
from distutils.version import LooseVersion
import os
import io
import logging

import pytest
from requests.structures import CaseInsensitiveDict
from selenium import __version__ as SELENIUM_VERSION
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.support.event_firing_webdriver import EventFiringWebDriver
Expand All @@ -28,14 +30,18 @@
"Edge": webdriver.Edge,
"Firefox": webdriver.Firefox,
"IE": webdriver.Ie,
"PhantomJS": webdriver.PhantomJS,
"Remote": webdriver.Remote,
"Safari": webdriver.Safari,
"SauceLabs": webdriver.Remote,
"TestingBot": webdriver.Remote,
}
)


# Selenium 4.0.0 deprecated phantom js.
if LooseVersion(SELENIUM_VERSION) < LooseVersion("4.0.0"):
SUPPORTED_DRIVERS["PhantomJS"] = webdriver.PhantomJS

try:
from appium import webdriver as appiumdriver

Expand Down
15 changes: 12 additions & 3 deletions testing/test_phantomjs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import os
from distutils.version import LooseVersion

import pytest
from selenium import __version__ as SELENIUM_VERSION

pytestmark = pytest.mark.nondestructive

Expand All @@ -20,7 +22,11 @@ def test_pass(webtext):
assert webtext == u'Success!'
"""
)
testdir.quick_qa("--driver", "PhantomJS", file_test, passed=1)
if LooseVersion(SELENIUM_VERSION) < LooseVersion("4.0.0"):
testdir.quick_qa("--driver", "PhantomJS", file_test, passed=1)
else:
reprec = testdir.inline_run("--driver", "PhantomJS")
assert reprec.ret == pytest.ExitCode.USAGE_ERROR


@pytest.mark.phantomjs
Expand All @@ -36,5 +42,8 @@ def driver_args():
def test_pass(selenium): pass
"""
)
testdir.quick_qa("--driver", "PhantomJS", file_test, passed=1)
assert os.path.exists(str(testdir.tmpdir.join("foo.log")))
if LooseVersion(SELENIUM_VERSION) < LooseVersion("4.0.0"):
testdir.quick_qa("--driver", "PhantomJS", file_test, passed=1)
assert os.path.exists(str(testdir.tmpdir.join("foo.log")))
else:
pass

0 comments on commit 658c713

Please sign in to comment.