web-driver.Firefox class

Summary

It's a class for the WebDriver for Firefox.

You can start a session with the Firefox via geckodriver.

Class methods

web-driver.Firefox.new(options) -> web-driver.Firefox

options: Startup option of the Firefox.

It create new web-driver.Firefox object.

You can specify startup options as below.

Example:

local web_driver = require("web-driver")

local options = {}
options.host = "192.168.0.1"
options.port = "1111"
local driver = web_driver.Firefox.new(options)

Possible options to set in options.arguments and options.args as see a below.

Command Line Options

web-driver.Firefox.start_session(callback) -> return value of callback

callback: Specify your callback function.

It starts a session with the Firefox and calls the given callback function. It returns the return value of the given callback function.

If you don't set the argument, this method returns a web-driver.Session object.

You can write the processing that you want to execute with the Firefox in the callback function as below.

Here is an example to start a session and navigate to a website:

local web_driver = require("web-driver")
local driver = web_driver.Firefox.new()

local URL =
  "https://clear-code.gitlab.io/lua-web-driver/sample/"

-- Start session with the Firefox
driver:start_session(function(session)
--Navigate to a website
  session:navigate_to(URL)
end)

If you set the callback to the argument, the session is deleted automatically after calling the callback function. If you don't set the argument, you must delete session manually with web-driver.Session:delete().