diff --git a/basictests/Program.fs b/basictests/Program.fs index 2e5ca090..924c5d60 100644 --- a/basictests/Program.fs +++ b/basictests/Program.fs @@ -183,6 +183,10 @@ test (fun _ -> count ".item" 5 2 === (element "span" |> elementsWithin ".item" |> List.length)) +"parent of firstItem and secondItem is list" &&&& (fun _ -> + url "http://localhost:4567/parent" + "list" === (element "#firstItem" |> parent).GetAttribute("id")) + context "reddit tests" once (fun _ -> Console.WriteLine "once: reddit tests") before (fun _ -> Console.WriteLine "before: reddit tests") diff --git a/canopy/canopy.fs b/canopy/canopy.fs index 9b1932f0..8d860004 100644 --- a/canopy/canopy.fs +++ b/canopy/canopy.fs @@ -208,6 +208,8 @@ let element cssSelector = find cssSelector elementTimeout browser let elementWithin cssSelector (elem:IWebElement) = find cssSelector elementTimeout elem +let parent (elem:IWebElement) = elem |> elementWithin ".." + let elements cssSelector = findMany cssSelector elementTimeout browser let elementsWithin cssSelector (elem:IWebElement) = findMany cssSelector elementTimeout elem diff --git a/testpages/app.rb b/testpages/app.rb index 347b27e0..19fbe760 100644 --- a/testpages/app.rb +++ b/testpages/app.rb @@ -75,4 +75,8 @@ get '/elementWithin' do erb :elementWithin +end + +get '/parent' do + erb :parent end \ No newline at end of file diff --git a/testpages/views/parent.erb b/testpages/views/parent.erb new file mode 100644 index 00000000..61a78b6d --- /dev/null +++ b/testpages/views/parent.erb @@ -0,0 +1,16 @@ + + + canopy testing page + + + + + + + + + + diff --git a/testpages/views/waitFor.erb b/testpages/views/waitFor.erb index 1e82ebdb..c493c6a8 100644 --- a/testpages/views/waitFor.erb +++ b/testpages/views/waitFor.erb @@ -1,6 +1,6 @@ - floak testing page + canopy testing page