This is a wrapper around Selenium WebDriver's python bindings. It can be used to write web-browser interaction tests in Julia.
This wrapper is auto-generated from the API documentation page and provides some nieceties that Julia programmers are used to. See usage section for more.
- you will need to install the
seleniumpython package. - you will need to set up ChromeDriver to use the google chrome for running web driver
- a good backend to use to run the web driver is PhantomJS
- if you have firefox already installed, you should be able to use the Firefox backend. See below to learn how to use different backends to run webdriver scripts.
You will need to driver object first to use the other methods. The init_* functions start off different browsers and give you back a Driver object.
using WebDriver
driver = init_phantomjs() # assuming phantomjs is in path, otherwise you can pass in the path as the first argument
driver = init_firefox()
driver = init_chrome() # needs ChromeDriverjulia> d = init_firefox()
julia> get(d, "https://duckduckgo.com")find and findall are shorthands for find_element_by_css_selector and find_elements_by_css_selector respectively. It might remind you of jQuery.$. These provide the most convenient way to look up elements in the DOM.
julia> search_box = find(d, "[name=q]")julia> send_keys(search_box, "Julia")
julia> get(d, "[name=x]") |> submit # find the search form and submit it
julia> find(find(d, "#r1-1"), ".result__title") |> text
"The Julia Language"You can chain a bunch of actions together and perform them at once using the ActionChain object.
actions = ActionChain(driver)
move_to_element(actions, menu)
click(actions, hidden_submenu)
perform(actions)There are curried methods for these functions to make for a "fluent" way of writing these.
ActionChain(driver) |>
move_to_element(menu) |>
click() |>
send_keys(Keys.TAB) |>
perform