Skip to content

Commit

Permalink
Add right click for #237
Browse files Browse the repository at this point in the history
  • Loading branch information
lefthandedgoat committed Jul 8, 2016
1 parent 7864a01 commit 33384df
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/canopy/canopy.fs
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,17 @@ let ctrlClick item =
true))
| _ -> raise (CanopyNotStringOrElementException(sprintf "Can't ctrlClick %O because it is not a string or webelement" item))

let rightClick item =
let actions = Actions(browser)

match box item with
| :? IWebElement as elem -> actions.ContextClick(elem).Perform() |> ignore
| :? string as cssSelector ->
wait elementTimeout (fun _ -> ( let elem = element cssSelector
actions.ContextClick(elem).Perform()
true))
| _ -> raise (CanopyNotStringOrElementException(sprintf "Can't rightClick %O because it is not a string or webelement" item))

let check item =
try
match box item with
Expand Down
9 changes: 9 additions & 0 deletions tests/basictests/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ test (fun _ ->
uncheck "#checkbox"
element "#checkbox" |> deselected

"rightClicking Works" &&& fun _ ->
!^ "https://api.jquery.com/contextmenu/"
let iframe = element "iframe"
browser.SwitchTo().Frame(iframe) |> ignore
notDisplayed ".contextmenu"

rightClick "div:first"
displayed ".contextmenu"

"element within only searching within the element" &&& fun _ ->
url "http://lefthandedgoat.github.io/canopy/testpages/elementWithin"
count ".item" 5
Expand Down

0 comments on commit 33384df

Please sign in to comment.