API
Public
WebDriver.WebDriver
— ModuleWebDriver
A binding for the WebDriver and JSON Wire Protocol for the Julia programing language compatible with the Selenium WebDriver.
Example
julia> using WebDriver
WebDriver.Capabilities
— TypeCapabilities(browserName::AbstractString;
browserVersion::AbstractString = "",
platformName::AbstractString = "",
acceptInsecureCerts::Union{Nothing, Bool} = nothing,
pageLoadStrategy::AbstractString = "",
proxy::Union{Nothing, Proxy} = nothing,
setWindowRect::Union{Nothing, Bool} = nothing,
timeouts::Timeouts = Timeouts(),
strictFileInteractability::Union{Nothing, Bool} = nothing,
unhandledPromptBehavior::AbstractString = "dismiss and notify"
)::Capabilities
According to W3C.
Example
julia> capabilities = Capabilities("chrome")
Remote WebDriver Capabilities
browserName: chrome
WebDriver.Cookie
— TypeCookie(obj)::Cookie
Cookie(name::AbstractString, value;
path::AbstractString = "/",
domain::Union{Nothing, AbstractString} = nothing,
secure::Bool = false,
httpOnly::Bool = false,
expiry::Union{Nothing, Integer, DateTime} = nothing)::Cookie
A cookie per W3C.
WebDriver.Element
— TypeElement(session::Session, location_strategy::AbstractString, value::AbstractString)::Element
Element(element::Element, location_strategy::AbstractString, value::AbstractString)::Element
The Find Element command is used to find an element in the current browsing context that can be used as the web element context for future element-centric commands.
May use a location strategy from "css selector", "link text", "partial link text", "tag name" or "xpath".
julia> capabilities = Capabilities("chrome")
Remote WebDriver Capabilities
browserName: chrome
julia> wd = RemoteWebDriver(capabilities, host = ENV["WEBDRIVER_HOST"], port = parse(Int, ENV["WEBDRIVER_PORT"]))
Remote WebDriver
julia> session = Session(wd)
Session
julia> isa(session, Session)
true
julia> delete!(session);
WebDriver.Proxy
— TypeProxy(proxyType::AbstractString;
proxyAutoconfigUrl::Union{Nothing, AbstractString} = nothing,
ftpProxy::Union{Nothing, AbstractString} = nothing,
httpProxy::Union{Nothing, AbstractString} = nothing,
noProxy::Union{Nothing, AbstractVector{<:AbstractString}} = nothing,
sslProxy::Union{Nothing, AbstractString} = nothing,
socksProxy::Union{Nothing, AbstractString} = nothing,
socksVersion::Union{Nothing, Integer} = nothing)::Proxy
The proxy configuration capability is a JSON Object nested within the primary capabilities. According to the W3C.
WebDriver.RemoteWebDriver
— TypeRemoteWebDriver(capabilities::Capabilities;
host::AbstractString = "localhost",
port::Integer = 4444,
path::AbstractString = "/wd/hub",
kwargs...)::RemoteWebDriver
Specifies a remote web driver according to W3C.
julia> capabilities = Capabilities("chrome")
Remote WebDriver Capabilities
browserName: chrome
julia> wd = RemoteWebDriver(capabilities, host = ENV["WEBDRIVER_HOST"], port = parse(Int, ENV["WEBDRIVER_PORT"]))
Remote WebDriver
julia> status(wd) # Ready to accept new sessions?
true
WebDriver.Session
— TypeSession
This is a web session.
julia> capabilities = Capabilities("chrome")
Remote WebDriver Capabilities
browserName: chrome
julia> wd = RemoteWebDriver(capabilities, host = ENV["WEBDRIVER_HOST"], port = parse(Int, ENV["WEBDRIVER_PORT"]))
Remote WebDriver
julia> session = Session(wd)
Session
julia> isa(session, Session)
true
julia> delete!(session);
WebDriver.Timeouts
— TypeTimeouts
According to the W3C.
julia> Timeouts(script = 50_000, pageLoad = 100_000, implicit = 5)
Session Timeouts -- script: 50000, pageLoad: 100000, implicit: 5
WebDriver.WDError
— TypeWDError <: Exception
A Web Driver Exception.
Base.delete!
— Methoddelete!(session::Session, cookie::AbstractString)::Nothing
If cookie = "", delete all cookies. Otherwise, delete cookie matching the "cookie" name.
Base.delete!
— Methoddelete!(session::Session)
Deletes the session from the Remote Driver.
WebDriver.Elements
— MethodElements(element::Element, location_strategy::AbstractString, value::AbstractString)::Vector{Element}
Find Elements
See also: Element
WebDriver.Elements
— MethodElements(session::Session, location_strategy::AbstractString, value::AbstractString)::Vector{Element}
Find Elements
See also: Element
WebDriver.accept
— Methodaccept(session::Session)::Nothing
Accepts the currently displayed alert dialog.
This command uses the JSON Wire Protocol instead of the current W3c WebDriver API.
WebDriver.active_element
— Methodactive_element(session::Session)::Element
Get Active Element
WebDriver.alert_text!
— Methodalert_text!(session::Session, text::AbstractString)::Nothing
Sends keystrokes to a JavaScript prompt() dialog.
This command uses the JSON Wire Protocol instead of the current W3c WebDriver API.
WebDriver.alert_text
— Methodalert_text(session::Session)::String
Gets the text of the currently displayed JavaScript alert(), confirm(), or prompt() dialog.
This command uses the JSON Wire Protocol instead of the current W3c WebDriver API.
WebDriver.back!
— Methodback!(session::Session)
This command causes the browser to traverse one step backward in the joint session history of the current top-level browsing context. This is equivalent to pressing the back button in the browser chrome or invoking window.history.back.
WebDriver.clear!
— Methodclear!(element::Element)::Nothing
Element Clear
WebDriver.click!
— Methodclick!(element::Element)::Nothing
The Element Click command scrolls into view the element if it is not already pointer-interactable, and clicks its in-view center point. If the element’s center point is obscured by another element, an element click intercepted error is returned. If the element is outside the viewport, an element not interactable error is returned.
WebDriver.cookie!
— Methodcookie!(session::Session, cookie::Cookie)::Nothing
Add Cookie.
WebDriver.cookie
— Methodcookie(session::Session, cookie::AbstractString)::Cookie
Get Named Cookie.
WebDriver.cookies
— Methodcookies(session::Session)::Vector{Cookie}
The Get Page Source command returns a string serialization of the DOM of the current browsing context active document.
WebDriver.current_url
— Methodcurrent_url(session::Session)::String
Get Current URL.
WebDriver.dismiss
— Methoddismiss(session::Session)::Nothing
Dismisses the currently displayed alert dialog.
This command uses the JSON Wire Protocol instead of the current W3c WebDriver API.
WebDriver.document_title
— Methoddocument_title(session::Session)::String
This command returns the document title of the current top-level browsing context, equivalent to calling document.title.
WebDriver.element_attr
— Methodelement_attr(element::Element, attribute::AbstractString)
Get Element Attribute.
WebDriver.element_css
— Methodelement_css(element::Element, value::AbstractString)
Get Element CSS Value
WebDriver.element_keys!
— Methodclear!(element::Element)::Nothing
The Element Send Keys command scrolls into view the form control element and then sends the provided keys to the element. In case the element is not keyboard-interactable, an element not interactable error is returned.
Keyboard keys are not implemented yet.
WebDriver.element_property
— Methodelement_property(element::Element, property::AbstractString)
Get Element Property.
WebDriver.element_tag
— Methodelement_tag(element::Element)::String
Get Element Tag Name.
WebDriver.element_text
— Methodelement_text(element::Element)::String
The Get Element Text command intends to return an element’s text "as rendered". An element's rendered text is also used for locating a elements by their link text and partial link text.
WebDriver.forward!
— Methodforward!(session::Session)
This command causes the browser to traverse one step forwards in the joint session history of the current top-level browsing context.
WebDriver.frame!
— Functionframe!(frame::Element)::Nothing
The Switch To Frame command is used to select the current top-level browsing context or a child browsing context of the current browsing context to use as the current browsing context for subsequent commands.
WebDriver.isenabled
— Methodisenabled(element::Element)::Bool
Is Element Enabled.
WebDriver.isselected
— Methodisselected(element::Element)::Bool
The Is Element Selected command determines if the referenced element is selected or not. This operation only makes sense on input elements of the Checkbox and Radio Button states, or on option elements.
WebDriver.maximize!
— Methodmaximize!(session::Session; window::AbstractString = "current")::Dict{String,Int}
The Maximize Window command invokes the window manager-specific "maximize" operation, if any, on the window containing the current top-level browsing context. This typically increases the window to the maximum available size without going full-screen.
This command is implemented using the JSON Wire Protocol.
WebDriver.minimize!
— Methodminimize!(session::Session; window::AbstractString = "current")::NamedTuple{(:width, :height, :x, :y),NTuple{4,Int64}}
The Minimize Window command invokes the window manager-specific "minimize" operation, if any, on the window containing the current top-level browsing context. This typically hides the window in the system tray.
This command is implemented using the JSON Wire Protocol.
WebDriver.moveto!
— Methodmoveto!(session::Session; x::Integer = 0, y::Integer = 0)
moveto!(element::Element; x::Integer = 0, y::Integer = 0)
Move the mouse by an offset of the specificed element.
This command uses the JSON Wire Protocol instead of the current W3c WebDriver API.
WebDriver.navigate!
— Methodnavigate!(session::Session, url::AbstractString)
The command causes the user agent to navigate the current top-level browsing context to a new location.
WebDriver.parent_frame!
— Methodparent_frame!(session::Session)::Nothing
The Switch to Parent Frame command sets the current browsing context for future commands to the parent of the current browsing context.
WebDriver.rect
— Functionrect(session::Session; window::AbstractString = "current")::NamedTuple{(:width, :height, :x, :y),NTuple{4,Int64}}
The Get Window Rect command returns the size and position on the screen of the operating system window corresponding to the current top-level browsing context.
WebDriver.rect!
— Methodrect!(session::Session;
window::AbstractString = "current",
width::Union{Nothing, Real} = nothing,
height::Union{Nothing, Real} = nothing
)::NamedTuple{(:width, :height, :x, :y),NTuple{4,Int64}}
The Set Window Rect command alters the size and the position of the operating system window corresponding to the current top-level browsing context.
WebDriver.rect
— Methodrect(element::Element)::NamedTuple{(:width, :height, :x, :y),NTuple{4,Int64}}
The Get Element Rect command returns the dimensions and coordinates of the given web element. The returned value is a dictionary with the following members:
- x: X axis position of the top-left corner of the web element relative to the current browsing context’s document element in CSS pixels.
- y: Y axis position of the top-left corner of the web element relative to the current browsing context’s document element in CSS pixels.
- height: Height of the web element’s bounding rectangle in CSS pixels.
- width: Width of the web element’s bounding rectangle in CSS pixels.
WebDriver.refresh!
— Methodrefresh!(session::Session)
This command causes the browser to reload the page in the current top-level browsing context.
WebDriver.screenshot
— Functionscreenshot(session::Session)::String
screenshot(element::Element)::String
screenshot(source::Union{Session, Element}, sink::Union{AbstractString, IO})
Take Screenshot and optionally saves it.
WebDriver.script!
— Methodscript!(session::Session, script::AbstractString, args...; async::Bool = false)
Executes JavaScript (sync / async)
This command uses the JSON Wire Protocol instead of the current W3c WebDriver API.
WebDriver.sessions
— Methodsessions(wd::RemoteWebDriver)
Returns a list of the currently active sessions.
This is a JSON Wire Protocol functionality.
WebDriver.source
— Methodsource(session::Session)::String
The Get Page Source command returns a string serialization of the DOM of the current browsing context active document.
WebDriver.status
— Methodstatus(wd::WebDriver)::Bool
Returns true
if the server is running and ready to accept new sessions.
WebDriver.timeouts!
— Methodtimeouts!(session::Session, timeouts::Timeouts)::Nothing
Sets the timeouts.
WebDriver.timeouts
— Methodtimeouts(session::Session)
Get the timeouts according to webdriver2. Currently not supported by Selenium.
WebDriver.window!
— Methodwindow!(session::Session, handle::AbstractString)
The window handle associated with the current top-level browsing context.
WebDriver.window!
— Methodwindow!(session::Session)
Create a new top-level browsing context.
WebDriver.window_close!
— Methodwindow_close!(session::Session)::Nothing
The window handle associated with the current top-level browsing context.
WebDriver.window_handle
— Methodwindow_handle(session::Session)::String
The window handle associated with the current top-level browsing context.
WebDriver.window_handles
— Methodwindow_handles(session::Session)::Vector{String}
Switching window will select the current top-level browsing context used as the target for all subsequent commands. In a tabbed browser, this will typically make the tab containing the browsing context the selected tab.