I've successfully achieved fullscreen mode in Chrome using the following WATIR code:
require 'watir'
chrome_options = { args: ["--start-fullscreen"] }
b = Watir::Browser.new :chrome, options: chrome_options
However, I'm facing difficulty replicating the same for Firefox. Could you please provide the correct syntax to enable fullscreen mode for Firefox in Selenium(Ruby Binding) or WATIR?
To achieve fullscreen mode in Firefox using Watir (which is built on top of Selenium), you can use the --start-fullscreen argument, much like you did with Chrome. However, Firefox has a slightly different command-line argument for starting in fullscreen mode, which is --kiosk.
Here’s how you can set up Firefox to start in fullscreen mode using Watir with Ruby bindings:
require 'watir'
firefox_options = {
args: ['-kiosk']
}
b = Watir::Browser.new :firefox, options: firefox_options
The code snippet above creates a new instance of the Firefox browser in kiosk mode, which is essentially a fullscreen mode that hides the GUI elements like the address bar and other browser chrome.
Alternatively, you can also use the Selenium WebDriver directly to achieve the same result:
require 'selenium-webdriver'
options = Selenium::WebDriver::Firefox::Options.new
options.add_argument('-kiosk')
driver = Selenium::WebDriver.for :firefox, options: options
Make sure that you have the GeckoDriver executable available in your system PATH or specify the path to the driver when initializing the Firefox browser instance. Also, ensure that your versions of Firefox, GeckoDriver, and selenium-webdriver gem are compatible with each other to avoid any compatibility issues.