# -*- coding: utf-8 -*- class OperaWatir::Browser include Deprecated attr_accessor :driver, :active_window, :preferences, :keys, :spatnav, :utils def self.settings=(settings={}) @desired_capabilities = nil # Bust cache @settings = settings end def self.settings @settings || self.settings = {} end # Constructs a new OperaDriver::Browser object. # # @example # browser = OperaWatir::Browser.new # # @return [Object] OperaWatir::Browser class. def initialize OperaWatir.compatibility! unless OperaWatir.api >= 3 self.driver = OperaDriver.new(self.class.desired_capabilities) self.active_window = OperaWatir::Window.new(self) self.preferences = OperaWatir::Preferences.new(self) self.keys = OperaWatir::Keys.new(self) self.spatnav = OperaWatir::Spatnav.new(self) self.utils = OperaWatir::Utils.new(self) end alias_method :window, :active_window # Get the name of the browser currently being run. # # @return [String] Name of browser currently used. def name 'Opera' end # Navigate to a new URL and return a Window object. # # @param [String] url The URL you wish to go to. # @return [Object] A Window object. def url=(url) active_window.url = url end # Instruct the browser instance to quit and shut down. def quit driver.quit end # Get the version number of the driver. This _is not_ the same as # the version number for OperaWatir, which can be retrieved using # +OperaWatir.version+ instead. # # @return [String] Driver version. def version driver.getVersion end # Get the target device's platform. This is not equivalent of the # platform the OperaWatir server might be running on. # # @return [String] Operating system flavour of the device we're # testing on. def platform window.execute_script('navigator.platform') end # Get the full path to the attached browser binary. # # @return [String] Path to the attached browser's binary. def path driver.getPath end # Fetches the user agent (UA) string the browser currently uses. # # @return [String] User agent string. def ua_string window.execute_script('navigator.userAgent') end # Is attached browser instance of type internal build or public # desktop? # # @return [Boolean] True if browser attached is of type desktop, # false otherwise. def desktop? false # FIXME end # Sends an Opera action to the browser. # # @param [String] Name of the action. # @return [String] Optional return from the performed action. def opera_action(name, *args) driver.operaAction(name, args.to_java(:string)) end deprecated :opera_action # Full list of available Opera actions in the Opera build you're # using. Note that this list varies from configuration to # configuration, and from build to build. The Opera actions # available to devices-type builds will vary greatly from those # available to desktop-types. # # @return [String] List of available Opera actions. def opera_action_list driver.getOperaActionList.to_a end deprecated :opera_action_list # Selects all content in the currently focused element. Equivalent # to pressing C-a in a desktop browser. To select content in a #