Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Commit

Permalink
Remove GhostDriver, thereby also built-in WebDriver support (#15399)
Browse files Browse the repository at this point in the history
We don't carry an embedded copy of GhostDriver anymore.
  • Loading branch information
ariya committed Dec 26, 2019
1 parent bdaa9c8 commit 5da1448
Show file tree
Hide file tree
Showing 336 changed files with 3 additions and 69,860 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ include_directories(src/qcommandline)

set(EXTRA_LIBS dl)

add_executable(${PROJECT_NAME} src/phantomjs.qrc src/ghostdriver/ghostdriver.qrc ${PHANTOMJS_SOURCES} ${THIRDPARTY_SOURCES})
add_executable(${PROJECT_NAME} src/phantomjs.qrc ${PHANTOMJS_SOURCES} ${THIRDPARTY_SOURCES})
target_link_libraries(${PROJECT_NAME} ${EXTRA_LIBS} Qt5::Core Qt5::Network Qt5::WebKitWidgets Threads::Threads)
install(TARGETS ${PROJECT_NAME} DESTINATION bin)

Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ phantom.callback = function(callback) {
var _paths = [], dir;

if (request[0] === '.') {
_paths.push(fs.absolute(joinPath(phantom.webdriverMode ? ":/ghostdriver" : this.dirname, request)));
_paths.push(fs.absolute(joinPath(this.dirname, request)));
} else if (fs.isAbsolute(request)) {
_paths.push(fs.absolute(request));
} else {
Expand Down
103 changes: 0 additions & 103 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,8 @@ static const struct QCommandLineConfigEntry flags[] = {
{ QCommandLine::Option, '\0', "ssl-client-certificate-file", "Sets the location of a client certificate", QCommandLine::Optional },
{ QCommandLine::Option, '\0', "ssl-client-key-file", "Sets the location of a clients' private key", QCommandLine::Optional },
{ QCommandLine::Option, '\0', "ssl-client-key-passphrase", "Sets the passphrase for the clients' private key", QCommandLine::Optional },
{ QCommandLine::Option, '\0', "webdriver", "Starts in 'Remote WebDriver mode' (embedded GhostDriver): '[[<IP>:]<PORT>]' (default '127.0.0.1:8910') ", QCommandLine::Optional },
{ QCommandLine::Option, '\0', "webdriver-logfile", "File where to write the WebDriver's Log (default 'none') (NOTE: needs '--webdriver') ", QCommandLine::Optional },
{ QCommandLine::Option, '\0', "webdriver-loglevel", "WebDriver Logging Level: (supported: 'ERROR', 'WARN', 'INFO', 'DEBUG') (default 'INFO') (NOTE: needs '--webdriver') ", QCommandLine::Optional },
{ QCommandLine::Option, '\0', "webdriver-selenium-grid-hub", "URL to the Selenium Grid HUB: 'URL_TO_HUB' (default 'none') (NOTE: needs '--webdriver') ", QCommandLine::Optional },
{ QCommandLine::Param, '\0', "script", "Script", QCommandLine::Flags(QCommandLine::Optional | QCommandLine::ParameterFence)},
{ QCommandLine::Param, '\0', "argument", "Script argument", QCommandLine::OptionalMultiple },
{ QCommandLine::Switch, 'w', "wd", "Equivalent to '--webdriver' option above", QCommandLine::Optional },
{ QCommandLine::Switch, 'h', "help", "Shows this message and quits", QCommandLine::Optional },
{ QCommandLine::Switch, 'v', "version", "Prints out PhantomJS version", QCommandLine::Optional },
QCOMMANDLINE_CONFIG_ENTRY_END
Expand Down Expand Up @@ -123,29 +118,6 @@ void Config::processArgs(const QStringList& args)
m_cmdLine->setConfig(flags);
m_cmdLine->parse();

// Inject command line parameters to be picked up by GhostDriver
if (isWebdriverMode()) {
QStringList argsForGhostDriver;

m_scriptFile = "main.js"; //< launch script

argsForGhostDriver << QString("--ip=%1").arg(m_webdriverIp); //< "--ip=IP"
argsForGhostDriver << QString("--port=%1").arg(m_webdriverPort); //< "--port=PORT"

if (!m_webdriverSeleniumGridHub.isEmpty()) {
argsForGhostDriver << QString("--hub=%1").arg(m_webdriverSeleniumGridHub); //< "--hub=SELENIUM_GRID_HUB_URL"
}

if (!m_webdriverLogFile.isEmpty()) {
argsForGhostDriver << QString("--logFile=%1").arg(m_webdriverLogFile); //< "--logFile=LOG_FILE"
argsForGhostDriver << "--logColor=false"; //< Force no-color-output in Log File
}

argsForGhostDriver << QString("--logLevel=%1").arg(m_webdriverLogLevel); //< "--logLevel=LOG_LEVEL"

// Clear current args and override with those
setScriptArgs(argsForGhostDriver);
}
}

void Config::loadJsonFile(const QString& filePath)
Expand Down Expand Up @@ -520,60 +492,6 @@ bool Config::javascriptCanCloseWindows() const
return m_javascriptCanCloseWindows;
}

void Config::setWebdriver(const QString& webdriverConfig)
{
// Parse and validate the configuration
bool isValidPort;
QStringList wdCfg = webdriverConfig.split(':');
if (wdCfg.length() == 1 && wdCfg[0].toInt(&isValidPort) && isValidPort) {
// Only a PORT was provided
m_webdriverPort = wdCfg[0];
} else if (wdCfg.length() == 2 && !wdCfg[0].isEmpty() && wdCfg[1].toInt(&isValidPort) && isValidPort) {
// Both IP and PORT provided
m_webdriverIp = wdCfg[0];
m_webdriverPort = wdCfg[1];
}
}

QString Config::webdriver() const
{
return QString("%1:%2").arg(m_webdriverIp).arg(m_webdriverPort);
}

bool Config::isWebdriverMode() const
{
return !m_webdriverPort.isEmpty();
}

void Config::setWebdriverLogFile(const QString& webdriverLogFile)
{
m_webdriverLogFile = webdriverLogFile;
}

QString Config::webdriverLogFile() const
{
return m_webdriverLogFile;
}

void Config::setWebdriverLogLevel(const QString& webdriverLogLevel)
{
m_webdriverLogLevel = webdriverLogLevel;
}

QString Config::webdriverLogLevel() const
{
return m_webdriverLogLevel;
}

void Config::setWebdriverSeleniumGridHub(const QString& hubUrl)
{
m_webdriverSeleniumGridHub = hubUrl;
}

QString Config::webdriverSeleniumGridHub() const
{
return m_webdriverSeleniumGridHub;
}

// private:
void Config::resetToDefaults()
Expand Down Expand Up @@ -634,11 +552,6 @@ void Config::resetToDefaults()
m_sslClientCertificateFile.clear();
m_sslClientKeyFile.clear();
m_sslClientKeyPassphrase.clear();
m_webdriverIp = QString();
m_webdriverPort = QString();
m_webdriverLogFile = QString();
m_webdriverLogLevel = "INFO";
m_webdriverSeleniumGridHub = QString();
}

void Config::setProxyAuthPass(const QString& value)
Expand Down Expand Up @@ -685,10 +598,6 @@ void Config::handleSwitch(const QString& sw)
{
setHelpFlag(sw == "help");
setVersionFlag(sw == "version");

if (sw == "wd") {
setWebdriver(DEFAULT_WEBDRIVER_CONFIG);
}
}

void Config::handleOption(const QString& option, const QVariant& value)
Expand Down Expand Up @@ -822,18 +731,6 @@ void Config::handleOption(const QString& option, const QVariant& value)
if (option == "ssl-client-key-passphrase") {
setSslClientKeyPassphrase(value.toByteArray());
}
if (option == "webdriver") {
setWebdriver(value.toString().length() > 0 ? value.toString() : DEFAULT_WEBDRIVER_CONFIG);
}
if (option == "webdriver-logfile") {
setWebdriverLogFile(value.toString());
}
if (option == "webdriver-loglevel") {
setWebdriverLogLevel(value.toString());
}
if (option == "webdriver-selenium-grid-hub") {
setWebdriverSeleniumGridHub(value.toString());
}
}

void Config::handleParam(const QString& param, const QVariant& value)
Expand Down
22 changes: 0 additions & 22 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ class Config: public QObject
Q_PROPERTY(QString sslClientCertificateFile READ sslClientCertificateFile WRITE setSslClientCertificateFile)
Q_PROPERTY(QString sslClientKeyFile READ sslClientKeyFile WRITE setSslClientKeyFile)
Q_PROPERTY(QByteArray sslClientKeyPassphrase READ sslClientKeyPassphrase WRITE setSslClientKeyPassphrase)
Q_PROPERTY(QString webdriver READ webdriver WRITE setWebdriver)
Q_PROPERTY(QString webdriverLogFile READ webdriverLogFile WRITE setWebdriverLogFile)
Q_PROPERTY(QString webdriverLogLevel READ webdriverLogLevel WRITE setWebdriverLogLevel)
Q_PROPERTY(QString webdriverSeleniumGridHub READ webdriverSeleniumGridHub WRITE setWebdriverSeleniumGridHub)

public:
Config(QObject* parent = 0);
Expand Down Expand Up @@ -195,19 +191,6 @@ class Config: public QObject
void setSslClientKeyPassphrase(const QByteArray& sslClientKeyPassphrase);
QByteArray sslClientKeyPassphrase() const;

void setWebdriver(const QString& webdriverConfig);
QString webdriver() const;
bool isWebdriverMode() const;

void setWebdriverLogFile(const QString& webdriverLogFile);
QString webdriverLogFile() const;

void setWebdriverLogLevel(const QString& webdriverLogLevel);
QString webdriverLogLevel() const;

void setWebdriverSeleniumGridHub(const QString& hubUrl);
QString webdriverSeleniumGridHub() const;

public slots:
void handleSwitch(const QString& sw);
void handleOption(const QString& option, const QVariant& value);
Expand Down Expand Up @@ -262,11 +245,6 @@ public slots:
QString m_sslClientCertificateFile;
QString m_sslClientKeyFile;
QByteArray m_sslClientKeyPassphrase;
QString m_webdriverIp;
QString m_webdriverPort;
QString m_webdriverLogFile;
QString m_webdriverLogLevel;
QString m_webdriverSeleniumGridHub;
};

#endif // CONFIG_H
2 changes: 0 additions & 2 deletions src/consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,4 @@
#define PAGE_SETTINGS_JS_CAN_CLOSE_WINDOWS "javascriptCanCloseWindows"
#define PAGE_SETTINGS_DPI "dpi"

#define DEFAULT_WEBDRIVER_CONFIG "127.0.0.1:8910"

#endif // CONSTS_H
7 changes: 0 additions & 7 deletions src/ghostdriver/README.md

This file was deleted.

106 changes: 0 additions & 106 deletions src/ghostdriver/config.js

This file was deleted.

Loading

0 comments on commit 5da1448

Please sign in to comment.