Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default path & content header change for selenium 4 #17

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/01_structs/04_WebDriver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
RemoteWebDriver(capabilities::Capabilities;
host::AbstractString = "localhost",
port::Integer = 4444,
path::AbstractString = "/wd/hub",
path::AbstractString = "",
kwargs...)::RemoteWebDriver

Specifies a remote web driver according to [W3C](https://www.w3.org/TR/webdriver).
Expand All @@ -25,7 +25,7 @@ struct RemoteWebDriver{C<:Capabilities}
capabilities::Capabilities;
host::AbstractString = "localhost",
port::Integer = 4444,
path::AbstractString = "/wd/hub",
path::AbstractString = "",
kwargs...,
)::RemoteWebDriver
addr = URI(scheme = "http", host = host, port = port, path = path)
Expand Down
2 changes: 1 addition & 1 deletion src/01_structs/05_Session.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct Session{D<:Object}
@unpack addr = wd
response = HTTP.post(
"$(wd.addr)/session",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
JSON3.write(Dict("desiredCapabilities" => wd.capabilities, wd.kw...)),
)
@assert response.status == 200
Expand Down
4 changes: 2 additions & 2 deletions src/01_structs/06_Element.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct Element
# value = "//select[@id='selecttype']"
response = HTTP.post(
"$addr/session/$id/element",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
JSON3.write(Dict("using" => location_strategy, "value" => value)),
)
@assert response.status == 200
Expand All @@ -58,7 +58,7 @@ struct Element
element_id = element.id
response = HTTP.post(
"$addr/session/$id/element/$element_id/element",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
JSON3.write(Dict("using" => location_strategy, "value" => value)),
)
@assert response.status == 200
Expand Down
2 changes: 1 addition & 1 deletion src/01_structs/07_Errors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ struct WDError <: Exception
error::String
message::String
function WDError(err::StatusError)
json = JSON3.read(err.response.body).value
json = JSON3.read(err.response.body)
new(err.status, json.error, json.message)
end
end
2 changes: 1 addition & 1 deletion src/02_commands/01_Sessions/02_Delete_Session.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function delete!(session::Session)
try
@unpack addr, id = session
response =
HTTP.delete("$addr/session/$id", [("Content-Type" => "application/json")])
HTTP.delete("$addr/session/$id", [("Content-Type" => "application/json; charset=utf-8")])
@assert response.status == 200
@assert JSON3.read(response.body).status == 0
id
Expand Down
2 changes: 1 addition & 1 deletion src/02_commands/01_Sessions/03_Status.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Returns `true` if the server is running and ready to accept new sessions.
"""
function status(wd::RemoteWebDriver)::Bool
@unpack addr = wd
response = HTTP.get("$addr/status", [("Content-Type" => "application/json")])
response = HTTP.get("$addr/status", [("Content-Type" => "application/json; charset=utf-8")])
@assert response.status == 200
json = JSON3.read(response.body).value
json.ready
Expand Down
2 changes: 1 addition & 1 deletion src/02_commands/02_Timeouts/01_Get_Timeouts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Currently not supported by Selenium.
function timeouts(session::Session)
@unpack addr, id = session
response =
HTTP.get("$addr/session/$id/timeouts", [("Content-Type" => "application/json")])
HTTP.get("$addr/session/$id/timeouts", [("Content-Type" => "application/json; charset=utf-8")])
@assert response.status == 200
JSON3.read(response.body).status
end
2 changes: 1 addition & 1 deletion src/02_commands/02_Timeouts/02_Set_Timeouts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function timeouts!(session::Session, timeouts::Timeouts)::Nothing
@unpack addr, id = session
response = HTTP.post(
"$addr/session/$id/timeouts",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
JSON3.write(timeouts),
)
@assert response.status == 200
Expand Down
2 changes: 1 addition & 1 deletion src/02_commands/03_Navigation/01_Navigate_To.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function navigate!(session::Session, url::AbstractString)
@unpack addr, id = session
response = HTTP.post(
"$addr/session/$id/url",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
"""{"url": "$url"}""",
)
nothing
Expand Down
2 changes: 1 addition & 1 deletion src/02_commands/03_Navigation/02_Get_Current_URL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Get Current URL.
"""
function current_url(session::Session)::String
@unpack addr, id = session
response = HTTP.get("$addr/session/$id/url", [("Content-Type" => "application/json")])
response = HTTP.get("$addr/session/$id/url", [("Content-Type" => "application/json; charset=utf-8")])
@assert response.status == 200
JSON3.read(response.body).value
end
2 changes: 1 addition & 1 deletion src/02_commands/03_Navigation/03_Back.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This is equivalent to pressing the back button in the browser chrome or invoking
"""
function back!(session::Session)
@unpack addr, id = session
response = HTTP.post("$addr/session/$id/back", [("Content-Type" => "application/json")])
response = HTTP.post("$addr/session/$id/back", [("Content-Type" => "application/json; charset=utf-8")])
@assert response.status == 200
nothing
end
2 changes: 1 addition & 1 deletion src/02_commands/03_Navigation/04_Forward.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This command causes the browser to traverse one step forwards in the joint sessi
function forward!(session::Session)
@unpack addr, id = session
response =
HTTP.post("$addr/session/$id/forward", [("Content-Type" => "application/json")])
HTTP.post("$addr/session/$id/forward", [("Content-Type" => "application/json; charset=utf-8")])
@assert response.status == 200
nothing
end
2 changes: 1 addition & 1 deletion src/02_commands/03_Navigation/05_Refresh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This command causes the browser to reload the page in the current top-level brow
function refresh!(session::Session)
@unpack addr, id = session
response =
HTTP.post("$addr/session/$id/timeouts", [("Content-Type" => "application/json")])
HTTP.post("$addr/session/$id/timeouts", [("Content-Type" => "application/json; charset=utf-8")])
@assert response.status == 200
nothing
end
2 changes: 1 addition & 1 deletion src/02_commands/03_Navigation/06_Get_Title.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This command returns the document title of the current top-level browsing contex
"""
function document_title(session::Session)::String
@unpack addr, id = session
response = HTTP.get("$addr/session/$id/title", [("Content-Type" => "application/json")])
response = HTTP.get("$addr/session/$id/title", [("Content-Type" => "application/json; charset=utf-8")])
@assert response.status == 200
JSON3.read(response.body).value
end
2 changes: 1 addition & 1 deletion src/02_commands/04_Contexts/01_Get_Window_Handle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function window_handle(session::Session)::String
@unpack addr, id = session
response = HTTP.get(
"$addr/session/$id/window_handle",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
)
@assert response.status == 200
convert(String, JSON3.read(response.body).value)
Expand Down
2 changes: 1 addition & 1 deletion src/02_commands/04_Contexts/02_Close_Window.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The window handle associated with the current top-level browsing context.
function window_close!(session::Session)::Nothing
@unpack addr, id = session
response =
HTTP.delete("$addr/session/$id/window", [("Content-Type" => "application/json")])
HTTP.delete("$addr/session/$id/window", [("Content-Type" => "application/json; charset=utf-8")])
@assert response.status == 200
nothing
end
2 changes: 1 addition & 1 deletion src/02_commands/04_Contexts/03_Switch_To_Window.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function window!(session::Session, handle::AbstractString)
@unpack addr, id = session
response = HTTP.post(
"$addr/session/$id/window",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
JSON3.write("handle" => handle),
)
@assert response.status == 200
Expand Down
2 changes: 1 addition & 1 deletion src/02_commands/04_Contexts/04_Get_Window_Handles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function window_handles(session::Session)::Vector{String}
@unpack addr, id = session
response = HTTP.get(
"$addr/session/$id/window_handles",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
)
@assert response.status == 200
convert(Vector{String}, JSON3.read(response.body).value)::Vector{String}
Expand Down
2 changes: 1 addition & 1 deletion src/02_commands/04_Contexts/05_New_Window.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Create a new top-level browsing context.
function window!(session::Session)::NamedTuple{(:type, :handle),NTuple{2, String}}
@unpack addr, id = session
response =
HTTP.post("$addr/session/$id/window/new", [("Content-Type" => "application/json")])
HTTP.post("$addr/session/$id/window/new", [("Content-Type" => "application/json; charset=utf-8")])
@assert response.status == 200
result = JSON3.read(response.body, NamedTuple)
@assert result.status == 0
Expand Down
4 changes: 2 additions & 2 deletions src/02_commands/04_Contexts/06_Switch_To_Frame.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function frame! end
# @unpack addr, id = session
# response = HTTP.post(
# "$addr/session/$id/frame",
# [("Content-Type" => "application/json")],
# [("Content-Type" => "application/json; charset=utf-8")],
# JSON3.write(Dict("id" => nothing))),
# )
# @assert response.status == 200
Expand All @@ -18,7 +18,7 @@ function frame!(frame::Element)::Nothing
@unpack addr, id = frame.session
response = HTTP.post(
"$addr/session/$id/frame",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
JSON3.write(Dict("id" => ("ELEMENT" => frame.id))),
)
@assert response.status == 200
Expand Down
2 changes: 1 addition & 1 deletion src/02_commands/04_Contexts/07_Switch_To_Parent_Frame.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function parent_frame!(session::Session)
@unpack addr, id = session
response = HTTP.post(
"$addr/session/$id/frame/parent",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
)
@assert response.status == 200
end
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function rect(
@unpack addr, id = session
response = HTTP.get(
"$addr/session/$id/window/$window/size",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
)
@assert response.status == 200
output = JSON3.read(response.body).value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function rect!(
@unpack addr, id = session
response = HTTP.post(
"$addr/session/$id/window/$window/size",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
JSON3.write(Dict("width" => width, "height" => height)),
)
@assert response.status == 200
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function maximize!(session::Session; window::AbstractString = "current")
@unpack addr, id = session
response = HTTP.post(
"$addr/session/$id/window/$window/maximize",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
)
@assert response.status == 200
output = JSON3.read(response.body).value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function minimize!(
@unpack addr, id = session
response = HTTP.post(
"$addr/session/$id/window/$window/minimize",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
)
@assert response.status == 200
output = JSON3.read(response.body).value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function active_element(session::Session)::Element
@unpack addr, id = session
response = HTTP.post(
"$addr/session/$id/element/active",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
)
@assert response.status == 200
Element(session, first(values(JSON3.read(response.body).value)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function Elements(
@unpack addr, id = session
response = HTTP.post(
"$addr/session/$id/elements",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
JSON3.write(Dict("using" => location_strategy, "value" => value)),
)
@assert response.status == 200
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function Elements(
element_id = element.id
response = HTTP.post(
"$addr/session/$id/element/$element_id/elements",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
JSON3.write(Dict("using" => location_strategy, "value" => value)),
)
@assert response.status == 200
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function isselected(element::Element)::Bool
element_id = element.id
response = HTTP.get(
"$addr/session/$id/element/$element_id/selected",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
)
@assert response.status == 200
JSON3.read(response.body).value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function element_attr(element::Element, attribute::AbstractString)
element_id = element.id
response = HTTP.get(
"$addr/session/$id/element/$element_id/attribute/$attribute",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
)
@assert response.status == 200
JSON3.read(response.body).value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function element_property(element::Element, property::AbstractString)
element_id = element.id
response = HTTP.get(
"$addr/session/$id/element/$element_id/property/$property",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
)
@assert response.status == 200
JSON3.read(response.body).value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function element_css(element::Element, value::AbstractString)
element_id = element.id
response = HTTP.get(
"$addr/session/$id/element/$element_id/css/$value",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
)
@assert response.status == 200
JSON3.read(response.body).value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function element_text(element::Element)::String
element_id = element.id
response = HTTP.get(
"$addr/session/$id/element/$element_id/text",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
)
@assert response.status == 200
JSON3.read(response.body).value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function element_tag(element::Element)::String
element_id = element.id
response = HTTP.get(
"$addr/session/$id/element/$element_id/name",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
)
@assert response.status == 200
JSON3.read(response.body).value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function rect(element::Element)::NamedTuple{(:width, :height, :x, :y),NTuple{4,I
element_id = element.id
response = HTTP.get(
"$addr/session/$id/element/$element_id/rect",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
)
@assert response.status == 200
output = JSON3.read(response.body).value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function isenabled(element::Element)::Bool
element_id = element.id
response = HTTP.get(
"$addr/session/$id/element/$element_id/enabled",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
)
@assert response.status == 200
JSON3.read(response.body).value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function click!(element::Element)::Nothing
element_id = element.id
response = HTTP.post(
"$addr/session/$id/element/$element_id/click",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
)
@assert response.status == 200
end
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function clear!(element::Element)::Nothing
element_id = element.id
response = HTTP.post(
"$addr/session/$id/element/$element_id/clear",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
)
@assert response.status == 200
end
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function element_keys!(element::Element, value::AbstractString)::Nothing
element_id = element.id
response = HTTP.post(
"$addr/session/$id/element/$element_id/value",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
JSON3.write("value" => split(value, "")),
)
@assert response.status == 200
Expand Down
2 changes: 1 addition & 1 deletion src/02_commands/06_Documents/01_Get_Page_Source.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The Get Page Source command returns a string serialization of the DOM of the cur
function source(session::Session)::String
@unpack addr, id = session
response =
HTTP.get("$addr/session/$id/source", [("Content-Type" => "application/json")])
HTTP.get("$addr/session/$id/source", [("Content-Type" => "application/json; charset=utf-8")])
@assert response.status == 200
JSON3.read(response.body).value
end
2 changes: 1 addition & 1 deletion src/02_commands/06_Documents/02_Execute_Script.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function script!(session::Session, _script::AbstractString, args...; async::Bool
@unpack addr, id = session
response = HTTP.post(
"$addr/session/$id/execute$(async ? "_async" : "")",
[("Content-Type" => "application/json")],
[("Content-Type" => "application/json; charset=utf-8")],
JSON3.write(Dict(
"script" => _script,
"args" => [isa(arg, Element) ? "ELEMENT" => arg.id : arg for arg in args],
Expand Down
Loading