Getting Started

semperos edited this page Feb 18, 2012 · 6 revisions

Quick Start

Here's an example of logging into Github:

    (use 'clj-webdriver.core)
    (def b (start {:browser :firefox} ""))

    ;; Click "Login" link
    (-> b
        (find-element {:text "Login"})

    ;; Input username/email into the "Login or Email" field
    (-> b
        (find-element {:class "text", :name "login"}) ; use multiple attributes
        (input-text "username"))

    ;; Input password into the "Password" field
    (-> b
        (find-element {:xpath "//input[@id='password']"}) ; even in "easy" mode, you still
        (input-text "password"))                     ; have :xpath and :css options

    ;; Click the "Log in" button"
    (-> b
        (find-element {:tag :input, :value #"Log"}) ; use regular expressions
        click)                                 ; also used optional tag arg, :input