मैं विधि Selenium::WebDriver.for
को ओवरराइड करना चाहता हूं।क्लास विधियों को ओवरराइड करने के लिए कैसे करें
module SeleniumWebDriverExtension
def self.for(browser, *args)
if browser != :phantomjs
super(browser, *args)
else
options = {
"phantomjs.cli.args" => ["--ssl-protocol=tlsv1"]
}
capabilities = Selenium::WebDriver::Remote::Capabilities.phantomjs(options)
super(browser, desired_capabilities: capabilities)
end
end
end
Selenium::WebDriver.prepend(SeleniumWebDriverExtension)
लेकिन जब Selenium::Webdriver.for(:phantomjs)
कहा जाता है मैं त्रुटि मिली: यह है कि मैं क्या करने की कोशिश की है।
NoMethodError: super: no superclass method `for' for Selenium::WebDriver::Driver:Class
मैं मूल विधि को ओवरराइडिंग विधि से कैसे कॉल कर सकता हूं?
चालाक, धन्यवाद! अब हम सुपर के फॉलबैक के साथ 'न्यूरेलिक :: एजेंट :: होस्टनाम.get' में संशोधन करने के लिए इसका उपयोग करते हैं। – Raffael