void Config::handleOption(const QString &option, const QVariant &value) { bool boolValue = false; QStringList booleanFlags; booleanFlags << "debug"; booleanFlags << "disk-cache"; booleanFlags << "ignore-ssl-errors"; booleanFlags << "load-images"; booleanFlags << "local-to-remote-url-access"; booleanFlags << "remote-debugger-autorun"; booleanFlags << "web-security"; if (booleanFlags.contains(option)) { if ((value != "true") && (value != "yes") && (value != "false") && (value != "no")) { setUnknownOption(QString("Invalid values for '%1' option.").arg(option)); return; } boolValue = (value == "true") || (value == "yes"); } if (option == "cookies-file") { setCookiesFile(value.toString()); } if (option == "config") { loadJsonFile(value.toString()); } if (option == "debug") { setPrintDebugMessages(boolValue); } if (option == "disk-cache") { setDiskCacheEnabled(boolValue); } if (option == "ignore-ssl-errors") { setIgnoreSslErrors(boolValue); } if (option == "load-images") { setAutoLoadImages(boolValue); } if (option == "local-storage-path") { setOfflineStoragePath(value.toString()); } if (option == "local-storage-quota") { setOfflineStorageDefaultQuota(value.toInt()); } if (option == "local-to-remote-url-access") { setLocalToRemoteUrlAccessEnabled(boolValue); } if (option == "max-disk-cache") { setMaxDiskCacheSize(value.toInt()); } if (option == "output-encoding") { setOutputEncoding(value.toString()); } if (option == "remote-debugger-autorun") { setRemoteDebugAutorun(boolValue); } if (option == "remote-debugger-port") { setDebug(true); setRemoteDebugPort(value.toInt()); } if (option == "proxy") { setProxy(value.toString()); } if (option == "proxy-type") { setProxyType(value.toString()); } if (option == "proxy-auth") { setProxyAuth(value.toString()); } if (option == "script-encoding") { setScriptEncoding(value.toString()); } if (option == "web-security") { setWebSecurityEnabled(boolValue); } }
void Config::handleOption(const QString &option, const QVariant &value) { bool boolValue = false; QStringList booleanFlags; booleanFlags << "debug"; booleanFlags << "disk-cache"; booleanFlags << "ignore-ssl-errors"; booleanFlags << "load-images"; booleanFlags << "local-to-remote-url-access"; booleanFlags << "remote-debugger-autorun"; booleanFlags << "web-security"; if (booleanFlags.contains(option)) { if ((value != "true") && (value != "yes") && (value != "false") && (value != "no")) { setUnknownOption(QString("Invalid values for '%1' option.").arg(option)); return; } boolValue = (value == "true") || (value == "yes"); } if (option == "cookies-file") { setCookiesFile(value.toString()); } if (option == "config") { loadJsonFile(value.toString()); } if (option == "debug") { setPrintDebugMessages(boolValue); } if (option == "disk-cache") { setDiskCacheEnabled(boolValue); } if (option == "ignore-ssl-errors") { setIgnoreSslErrors(boolValue); } if (option == "load-images") { setAutoLoadImages(boolValue); } if (option == "local-storage-path") { setOfflineStoragePath(value.toString()); } if (option == "local-storage-quota") { setOfflineStorageDefaultQuota(value.toInt()); } if (option == "local-to-remote-url-access") { setLocalToRemoteUrlAccessEnabled(boolValue); } if (option == "max-disk-cache-size") { setMaxDiskCacheSize(value.toInt()); } if (option == "output-encoding") { setOutputEncoding(value.toString()); } if (option == "remote-debugger-autorun") { setRemoteDebugAutorun(boolValue); } if (option == "remote-debugger-port") { setDebug(true); setRemoteDebugPort(value.toInt()); } if (option == "proxy") { setProxy(value.toString()); } if (option == "proxy-type") { setProxyType(value.toString()); } if (option == "proxy-auth") { setProxyAuth(value.toString()); } if (option == "script-encoding") { setScriptEncoding(value.toString()); } if (option == "script-language") { setScriptLanguage(value.toString()); } if (option == "web-security") { setWebSecurityEnabled(boolValue); } if (option == "ssl-protocol") { setSslProtocol(value.toString()); } if (option == "ssl-certificates-path") { setSslCertificatesPath(value.toString()); } 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::processArgs(const QStringList &args) { QStringListIterator it(args); while (it.hasNext()) { const QString &arg = it.next(); if (arg == "--help" || arg == "-h") { setHelpFlag(true); return; } if (arg == "--version" || arg == "-v") { setVersionFlag(true); return; } if (arg == "--load-images=yes") { setAutoLoadImages(true); continue; } if (arg == "--load-images=no") { setAutoLoadImages(false); continue; } if (arg == "--disk-cache=yes") { setDiskCacheEnabled(true); continue; } if (arg == "--disk-cache=no") { setDiskCacheEnabled(false); continue; } if (arg.startsWith("--max-disk-cache-size=")) { setMaxDiskCacheSize(arg.mid(arg.indexOf("=") + 1).trimmed().toInt()); continue; } if (arg == "--ignore-ssl-errors=yes") { setIgnoreSslErrors(true); continue; } if (arg == "--ignore-ssl-errors=no") { setIgnoreSslErrors(false); continue; } if (arg == "--local-to-remote-url-access=no") { setLocalToRemoteUrlAccessEnabled(false); continue; } if (arg == "--local-to-remote-url-access=yes") { setLocalToRemoteUrlAccessEnabled(true); continue; } if (arg.startsWith("--proxy-type=")) { setProxyType(arg.mid(13).trimmed()); continue; } if (arg.startsWith("--proxy-auth=")){ setProxyAuth(arg.mid(13).trimmed()); continue; } if (arg.startsWith("--proxy=")) { setProxy(arg.mid(8).trimmed()); continue; } if (arg.startsWith("--cookies-file=")) { setCookiesFile(arg.mid(15).trimmed()); continue; } if (arg.startsWith("--local-storage-path=")) { setOfflineStoragePath(arg.mid(21).trimmed()); continue; } if (arg.startsWith("--local-storage-quota=")) { setOfflineStorageDefaultQuota(arg.mid(arg.indexOf("=") + 1).trimmed().toInt()); continue; } if (arg.startsWith("--output-encoding=")) { setOutputEncoding(arg.mid(18).trimmed()); continue; } if (arg.startsWith("--script-encoding=")) { setScriptEncoding(arg.mid(18).trimmed()); continue; } if (arg.startsWith("--config=")) { QString configPath = arg.mid(9).trimmed(); loadJsonFile(configPath); continue; } if (arg.startsWith("--remote-debugger-port=")) { setDebug(true); setRemoteDebugPort(arg.mid(23).trimmed().toInt()); continue; } if (arg == "--remote-debugger-autorun=yes") { setRemoteDebugAutorun(true); continue; } if (arg == "--remote-debugger-autorun=no") { setRemoteDebugAutorun(false); continue; } if (arg == "--web-security=yes") { setWebSecurityEnabled(true); continue; } if (arg == "--web-security=no") { setWebSecurityEnabled(false); continue; } if (arg == "--debug=yes") { setPrintDebugMessages(true); continue; } if (arg == "--debug=no") { setPrintDebugMessages(false); continue; } if (arg.startsWith("--")) { setUnknownOption(QString("Unknown option '%1'").arg(arg)); return; } // There are no more options at this point. // The remaining arguments are available for the script. m_scriptFile = arg; while (it.hasNext()) { m_scriptArgs += it.next(); } } }