From e72978b4bdd19992ee1201141562e969a48040cb Mon Sep 17 00:00:00 2001 From: Chris Holt Date: Sun, 26 Jan 2014 20:51:18 -0600 Subject: [PATCH] Issue128-Progress iFrame not working --- basictests/Program.fs | 319 +++++++++++++++++++++------------------- canopy/canopy.fs | 70 +-------- canopy/canopy.fsproj | 1 + canopy/configuration.fs | 3 +- 4 files changed, 172 insertions(+), 221 deletions(-) diff --git a/basictests/Program.fs b/basictests/Program.fs index 480c8555..16728ed7 100644 --- a/basictests/Program.fs +++ b/basictests/Program.fs @@ -28,13 +28,13 @@ let testpage = "http://lefthandedgoat.github.io/canopy/testpages/" "intentionally skipped shows blue in LiveHtmlReport" &&! skipped -"#welcome should have Welcome" &&& (fun _ -> +"#welcome should have Welcome" &&& fun _ -> url testpage - "#welcome" == "Welcome") + "#welcome" == "Welcome" //ntest "description" (fun _ -> url "http://www.google.com") //and -//"description" &&& (fun _ -> url "http://www.google.com") +//"description" &&& fun _ -> url "http://www.google.com") //do the same thing ntest "find by label, following field" (fun _ -> url testpage @@ -49,17 +49,17 @@ test (fun _ -> url testpage "Test Field 2" == "test value 2") -"#firstName should have John (using == infix operator)" &&& (fun _ -> +"#firstName should have John (using == infix operator)" &&& fun _ -> url testpage - "#firstName" == "John") + "#firstName" == "John" -"id('firstName') should have John (using == infix operator), basic xpath test" &&& (fun _ -> +"id('firstName') should have John (using == infix operator), basic xpath test" &&& fun _ -> url testpage - "id('firstName')" == "John") + "id('firstName')" == "John" -"#lastName should have Doe" &&& (fun _ -> +"#lastName should have Doe" &&& fun _ -> !^ testpage - "#lastName" == "Doe") + "#lastName" == "Doe" "#lastName should have Doe via read cssSelector" &&& fun _ -> !^ testpage @@ -69,181 +69,182 @@ test (fun _ -> !^ testpage element "#lastname" |> read |> is "Doe" -"clearing #firstName sets text to new empty string" &&& (fun _ -> +"clearing #firstName sets text to new empty string" &&& fun _ -> !^ testpage clear "#firstName" - "#firstName" == "") + "#firstName" == "" -"clearing #firstName sets text to new empty string via IWebElement" &&& (fun _ -> +"clearing #firstName sets text to new empty string via IWebElement" &&& fun _ -> !^ testpage element "#firstName" |> clear - "#firstName" == "") + "#firstName" == "" -"writing to #lastName sets text to Smith" &&& (fun _ -> +"writing to #lastName sets text to Smith" &&& fun _ -> !^ testpage clear "#lastName" "#lastName" << "Smith" - "#lastName" == "Smith") + "#lastName" == "Smith" -"writing to .lastName sets text to new Smith in both boxes" &&& (fun _ -> +"writing to .lastName sets text to new Smith in both boxes" &&& fun _ -> !^ testpage clear "#lastName" ".lastName" << "Smith" "#lastName" == "Smith" - "#lastName2" == "Smith") + "#lastName2" == "Smith" -"writing to .lastName sets text to new Smith in both boxes, xpath test" &&& (fun _ -> +"writing to .lastName sets text to new Smith in both boxes, xpath test" &&& fun _ -> !^ testpage clear "#lastName" "//input[@class='lastName']" << "Smith" "#lastName" == "Smith" - "#lastName2" == "Smith") + "#lastName2" == "Smith" -"writing to #lastName sets text to new Smith (implicit clear in write)" &&& (fun _ -> +"writing to #lastName sets text to new Smith (implicit clear in write)" &&& fun _ -> !^ testpage "#lastName" << "Smith" - "#lastName" == "Smith") + "#lastName" == "Smith" -"#ajax label should have ajax loaded" &&& (fun _ -> +"#ajax label should have ajax loaded" &&& fun _ -> !^ testpage - "#ajax" == "ajax loaded") + "#ajax" == "ajax loaded" -"Value 1 listed in #value_list" &&& (fun _ -> +"Value 1 listed in #value_list" &&& fun _ -> !^ testpage - "#value_list td" *= "Value 1") + "#value_list td" *= "Value 1" -"Value 2 listed in #value_list" &&& (fun _ -> +"Value 2 listed in #value_list" &&& fun _ -> !^ testpage - "#value_list td" *= "Value 2") + "#value_list td" *= "Value 2" -"Value 3 listed in #value_list" &&& (fun _ -> +"Value 3 listed in #value_list" &&& fun _ -> !^ testpage - "#value_list td" *= "Value 3") + "#value_list td" *= "Value 3" -"Value 4 listed in #value_list" &&& (fun _ -> +"Value 4 listed in #value_list" &&& fun _ -> !^ testpage - "#value_list td" *= "Value 4") + "#value_list td" *= "Value 4" -"Item 1 listed in #item_list" &&& (fun _ -> +"Item 1 listed in #item_list" &&& fun _ -> !^ testpage - "#item_list option" *= "Item 1") + "#item_list option" *= "Item 1" -"Item 2 listed in #item_list" &&& (fun _ -> +"Item 2 listed in #item_list" &&& fun _ -> !^ testpage - "#item_list option" *= "Item 2") + "#item_list option" *= "Item 2" -"Item 3 listed in #item_list" &&& (fun _ -> +"Item 3 listed in #item_list" &&& fun _ -> !^ testpage - "#item_list option" *= "Item 3") + "#item_list option" *= "Item 3" -"Item 4 listed in #item_list" &&& (fun _ -> +"Item 4 listed in #item_list" &&& fun _ -> !^ testpage - "#item_list option" *= "Item 4") + "#item_list option" *= "Item 4" -"clicking #button sets #button_clicked to button clicked" &&& (fun _ -> +"clicking #button sets #button_clicked to button clicked" &&& fun _ -> !^ testpage "#button_clicked" == "button not clicked" click "#button" - "#button_clicked" == "button clicked") + "#button_clicked" == "button clicked" -"clicking button with text 'Click Me!!' sets #button_clicked to button clicked" &&& (fun _ -> +"clicking button with text 'Click Me!!' sets #button_clicked to button clicked" &&& fun _ -> !^ testpage "#button_clicked" == "button not clicked" click "Click Me!!" - "#button_clicked" == "button clicked") + "#button_clicked" == "button clicked" -"clicking (element #button) sets #button_clicked to button clicked" &&& (fun _ -> +"clicking (element #button) sets #button_clicked to button clicked" &&& fun _ -> !^ testpage "#button_clicked" == "button not clicked" click (element "#button") - "#button_clicked" == "button clicked") + "#button_clicked" == "button clicked" -"clicking hyperlink sets #link_clicked to link clicked" &&& (fun _ -> +"clicking hyperlink sets #link_clicked to link clicked" &&& fun _ -> !^ testpage "#link_clicked" == "link not clicked" click "#hyperlink" - "#link_clicked" == "link clicked") + "#link_clicked" == "link clicked" -"clicking hyperlink via text sets #link_clicked to link clicked" &&& (fun _ -> +"clicking hyperlink via text sets #link_clicked to link clicked" &&& fun _ -> !^ testpage "#link_clicked" == "link not clicked" click "Click Me!" - "#link_clicked" == "link clicked") + "#link_clicked" == "link clicked" -"clicking #radio1 selects it" &&& (fun _ -> +"clicking #radio1 selects it" &&& fun _ -> !^ testpage click "#radio1" - selected "#radio1") + selected "#radio1" -"clicking #radio1 selects it via IWebElement" &&& (fun _ -> +"clicking #radio1 selects it via IWebElement" &&& fun _ -> !^ testpage click "#radio1" - element "#radio1" |> selected) + element "#radio1" |> selected -"clicking #radio2 selects it" &&& (fun _ -> +"clicking #radio2 selects it" &&& fun _ -> !^ testpage click "#radio2" - selected "#radio2") + selected "#radio2" -"clicking #checkbox selects it" &&& (fun _ -> + +"clicking #checkbox selects it" &&& fun _ -> !^ testpage check "#checkbox" - selected "#checkbox") + selected "#checkbox" -"clicking #checkbox selects it via sizzle" &&& (fun _ -> +"clicking #checkbox selects it via sizzle" &&& fun _ -> !^ testpage check "#checkbox" - count "input:checked" 1) + count "input:checked" 1 -"clicking selected #checkbox deselects it" &&& (fun _ -> +"clicking selected #checkbox deselects it" &&& fun _ -> !^ testpage check "#checkbox" uncheck "#checkbox" - deselected "#checkbox") + deselected "#checkbox" -"clicking selected #checkbox deselects it via IWebElement" &&& (fun _ -> +"clicking selected #checkbox deselects it via IWebElement" &&& fun _ -> !^ testpage check "#checkbox" uncheck "#checkbox" - element "#checkbox" |> deselected) + element "#checkbox" |> deselected -"element within only searching within the element" &&& (fun _ -> +"element within only searching within the element" &&& fun _ -> url "http://lefthandedgoat.github.io/canopy/testpages/elementWithin" count ".item" 5 - "spanned item 4" === (element "span" |> elementWithin ".item").Text) + "spanned item 4" === (element "span" |> elementWithin ".item").Text -"elements within only searching within element" &&& (fun _ -> +"elements within only searching within element" &&& fun _ -> url "http://lefthandedgoat.github.io/canopy/testpages/elementWithin" count ".item" 5 - 2 === (element "span" |> elementsWithin ".item" |> List.length)) + 2 === (element "span" |> elementsWithin ".item" |> List.length) -"someElementWithin only searching within element" &&& (fun _ -> +"someElementWithin only searching within element" &&& fun _ -> url "http://lefthandedgoat.github.io/canopy/testpages/elementWithin" count ".item" 5 - true === (element "span" |> someElementWithin ".specialItem").IsSome) + true === (element "span" |> someElementWithin ".specialItem").IsSome -"parent of firstItem and secondItem is list" &&& (fun _ -> +"parent of firstItem and secondItem is list" &&& fun _ -> url "http://lefthandedgoat.github.io/canopy/testpages/parent" - "list" === (element "#firstItem" |> parent).GetAttribute("id")) + "list" === (element "#firstItem" |> parent).GetAttribute("id") -"some parent of firstItem and secondItem is list" &&& (fun _ -> +"some parent of firstItem and secondItem is list" &&& fun _ -> url "http://lefthandedgoat.github.io/canopy/testpages/parent" true === (element "#firstItem" |> someParent).IsSome - "list" === (element "#firstItem" |> someParent).Value.GetAttribute("id")) + "list" === (element "#firstItem" |> someParent).Value.GetAttribute("id") -"someElement returns Some when element found" &&& (fun _ -> +"someElement returns Some when element found" &&& fun _ -> url testpage true === (someElement "#testfield2").IsSome - "test value 2" === (someElement "#testfield2").Value.GetAttribute("value")) + "test value 2" === (someElement "#testfield2").Value.GetAttribute("value") -"someElement returns None when element not found" &&& (fun _ -> +"someElement returns None when element not found" &&& fun _ -> url testpage - None === (someElement "#thisIdDoesNotExist")) + None === (someElement "#thisIdDoesNotExist") -"someElement fails when more than one element found" &&& (fun _ -> +"someElement fails when more than one element found" &&& fun _ -> url testpage failsWith "More than one element was selected when only one was expected for selector: .lastName" - someElement ".lastName" |> ignore) + someElement ".lastName" |> ignore "Navigating to a url should be on url" &&& fun _ -> url testpage @@ -285,211 +286,219 @@ before (fun _ -> Console.WriteLine "before: reddit tests") after (fun _ -> Console.WriteLine "after: reddit tests") lastly (fun _ -> Console.WriteLine "lastly: reddit tests") -"browsing to redit should be on reddit" &&& (fun _ -> +"browsing to redit should be on reddit" &&& fun _ -> url "http://www.reddit.com/" - on "http://www.reddit.com/") + on "http://www.reddit.com/" -"reloading redit should be on reddit" &&& (fun _ -> +"reloading redit should be on reddit" &&& fun _ -> url "http://www.reddit.com/" on "http://www.reddit.com/" reload () - on "http://www.reddit.com/") + on "http://www.reddit.com/" context "post reddit tests" before (fun _ -> Console.WriteLine "only before set now") -"textbox should not equals dontequalme" &&& (fun _ -> +"textbox should not equals dontequalme" &&& fun _ -> !^ testpage - "#welcome" != "dontequalme") + "#welcome" != "dontequalme" -"list should not have item" &&& (fun _ -> +"list should not have item" &&& fun _ -> !^ testpage - "#value_list td" *!= "Value 5") + "#value_list td" *!= "Value 5" -"ajax button should click" &&& (fun _ -> +"ajax button should click" &&& fun _ -> !^ testpage "#ajax_button_clicked" == "ajax button not clicked" click "#ajax_button" - "#ajax_button_clicked" == "ajax button clicked") + "#ajax_button_clicked" == "ajax button clicked" -"pressing keys should work (may need to verify visually)" &&& (fun _ -> +"pressing keys should work (may need to verify visually)" &&& fun _ -> !^ testpage click "#firstName" press tab press tab - press down) + press down -"click polling" &&& (fun _ -> +"click polling" &&& fun _ -> url "http://lefthandedgoat.github.io/canopy/testpages/autocomplete" click "#search" click "table tr td" - "#console" == "worked") + "#console" == "worked" -"ajax button should click after sleep" &&& (fun _ -> +"ajax button should click after sleep" &&& fun _ -> !^ testpage "#ajax_button_clicked" == "ajax button not clicked" sleep 2.5 click "#ajax_button" - "#ajax_button_clicked" == "ajax button clicked") + "#ajax_button_clicked" == "ajax button clicked" -"readonly should throw error on read only field with clear" &&& (fun _ -> +"readonly should throw error on read only field with clear" &&& fun _ -> failsWith "element #read_only is marked as read only, you can not clear read only elements" !^ "http://lefthandedgoat.github.io/canopy/testpages/readonly" - clear "#read_only") + clear "#read_only" -"readonly should throw error on read only field with write" &&& (fun _ -> +"readonly should throw error on read only field with write" &&& fun _ -> failsWith "element #read_only is marked as read only, you can not write to read only elements" !^ "http://lefthandedgoat.github.io/canopy/testpages/readonly" - "#read_only" << "new text") + "#read_only" << "new text" -"when value is wrong and changes to empty string prior to time out, it should show wrong value, not empty string" &&& (fun _ -> +"when value is wrong and changes to empty string prior to time out, it should show wrong value, not empty string" &&& fun _ -> failsWith "equality check failed. expected: John1, got: John" url testpage - "#firstName" == "John1") + "#firstName" == "John1" context "other tests" -"define a custom wait for using any function that takes in unit and returns bool" &&& (fun _ -> +"define a custom wait for using any function that takes in unit and returns bool" &&& fun _ -> let pageLoaded () = (element "#wait_for").Text = "Done!" !^ "http://lefthandedgoat.github.io/canopy/testpages/waitFor" waitFor pageLoaded - "#wait_for" == "Done!") + "#wait_for" == "Done!" -"another example of another wait for, waiting on opacity to be 100% before clicking" &&& (fun _ -> +"another example of another wait for, waiting on opacity to be 100% before clicking" &&& fun _ -> compareTimeout <- 10.0 !^ "http://lefthandedgoat.github.io/canopy/testpages/noClickTilVisible" waitFor (fadedIn "#link") click "#link" - on "http://lefthandedgoat.github.io/canopy/testpages/home") + on "http://lefthandedgoat.github.io/canopy/testpages/home" -"define a custom wait for using any function that takes in unit and returns bool, example using lists" &&& (fun _ -> +"define a custom wait for using any function that takes in unit and returns bool, example using lists" &&& fun _ -> let fiveNumbersShown () = (elements ".number").Length = 5 !^ "http://lefthandedgoat.github.io/canopy/testpages/waitFor" waitFor fiveNumbersShown - (elements ".number").Length === 5) + (elements ".number").Length === 5 -"regex test" &&& (fun _ -> +"regex test" &&& fun _ -> url testpage "#lastName" << "Gray" "#lastName" =~ "Gr[ae]y" "#lastName" << "Grey" - "#lastName" =~ "Gr[ae]y") + "#lastName" =~ "Gr[ae]y" -"regex one of many test" &&& (fun _ -> +"regex one of many test" &&& fun _ -> url testpage - "#colors li" *~ "gr[ea]y") + "#colors li" *~ "gr[ea]y" -"test for first function" &&& (fun _ -> +"test for first function" &&& fun _ -> !^ testpage - (first "#value_list td").Text === "Value 1") + (first "#value_list td").Text === "Value 1" -"test for last function" &&& (fun _ -> +"test for last function" &&& fun _ -> !^ testpage - (last "#value_list td").Text === "Value 4") + (last "#value_list td").Text === "Value 4" -"test for nth function" &&& (fun _ -> +"test for nth function" &&& fun _ -> !^ testpage - (nth 2 "#value_list td").Text === "Value 3") + (nth 2 "#value_list td").Text === "Value 3" -"writting (selecting) to drop down test" &&& (fun _ -> +"writting (selecting) to drop down test" &&& fun _ -> !^ testpage "#item_list" << "Item 2" - "#item_list" == "Item 2") + "#item_list" == "Item 2" -"writting (selecting) to drop down test, many options" &&& (fun _ -> +"writting (selecting) to drop down test, many options" &&& fun _ -> !^ testpage "#states" << "Kingman Reef" - "#states" == "Kingman Reef") + "#states" == "Kingman Reef" -"double clicking" &&& (fun _ -> +"double clicking" &&& fun _ -> !^ "http://lefthandedgoat.github.io/canopy/testpages/doubleClick" "#clicked" == "Not Clicked" doubleClick "#double_click" - "#clicked" == "Clicked") + "#clicked" == "Clicked" -"displayed test" &&& (fun _ -> +"displayed test" &&& fun _ -> !^ "http://lefthandedgoat.github.io/canopy/testpages/displayed" - displayed "#displayed") + displayed "#displayed" -"displayed test via element" &&& (fun _ -> +"displayed test via element" &&& fun _ -> !^ "http://lefthandedgoat.github.io/canopy/testpages/displayed" - element "#displayed" |> displayed) + element "#displayed" |> displayed -"displayed test2" &&& (fun _ -> +"displayed test2" &&& fun _ -> !^ "http://lefthandedgoat.github.io/canopy/testpages/displayed" - waitFor (fun _ -> (element "#displayed").Displayed)) + waitFor (fun _ -> (element "#displayed").Displayed) -"displayed test3" &&& (fun _ -> +"displayed test3" &&& fun _ -> !^ "http://lefthandedgoat.github.io/canopy/testpages/waitFor" - waitFor (fun _ -> (element "#wait_for_2").Displayed)) + waitFor (fun _ -> (element "#wait_for_2").Displayed) -"notDisplayed test" &&& (fun _ -> +"notDisplayed test" &&& fun _ -> !^ "http://lefthandedgoat.github.io/canopy/testpages/notDisplayed" - notDisplayed "#notDisplayed") + notDisplayed "#notDisplayed" -"notDisplayed test via element" &&& (fun _ -> +"notDisplayed test via element" &&& fun _ -> !^ "http://lefthandedgoat.github.io/canopy/testpages/notDisplayed" - element "#notDisplayed" |> notDisplayed) + element "#notDisplayed" |> notDisplayed -"notDisplayed test for element that is not on the screen" &&& (fun _ -> +"notDisplayed test for element that is not on the screen" &&& fun _ -> !^ "http://lefthandedgoat.github.io/canopy/testpages/notDisplayed" - notDisplayed "#nalsjdfalfalsdjfalsjfaljsflsjf") + notDisplayed "#nalsjdfalfalsdjfalsjfaljsflsjf" -"count test" &&& (fun _ -> +"count test" &&& fun _ -> !^ "http://lefthandedgoat.github.io/canopy/testpages/count" - count ".number" 5) + count ".number" 5 -"count test via sizzle" &&& (fun _ -> +"count test via sizzle" &&& fun _ -> !^ testpage - count "option:selected" 2) + count "option:selected" 2 + +"#firstName should have John (using == infix operator), iframe1" &&& fun _ -> + url "http://lefthandedgoat.github.io/canopy/testpages/iframe1" + "#firstName" == "John" + +"#firstName should have John (using == infix operator), iframe2" &&& fun _ -> + url "http://lefthandedgoat.github.io/canopy/testpages/iframe2" + "#firstName" == "John" context "dragging" -"draging works" &&& (fun _ -> +"draging works" &&& fun _ -> url "http://scrumy.com/silenter39delayed" click ".plus-button a img" "#task_title" << "Demo" click "#task_editor_buttons .save_button" ".handle" --> ".inprogress" - click "Blog") + click "Blog" if not (browser :? OpenQA.Selenium.PhantomJS.PhantomJSDriver) then context "alert tests" before (fun _ -> !^ "http://lefthandedgoat.github.io/canopy/testpages/alert") - "alert box should have 'Alert Test'" &&& (fun _ -> + "alert box should have 'Alert Test'" &&& fun _ -> click "#alert_test" alert() == "Alert Test" - acceptAlert()) + acceptAlert() - "alert box should have 'Alert Test'" &&& (fun _ -> + "alert box should have 'Alert Test'" &&& fun _ -> click "#alert_test" alert() == "Alert Test" - dismissAlert()) + dismissAlert() - "alert box should fail correctly when expecting wrong message" &&& (fun _ -> + "alert box should fail correctly when expecting wrong message" &&& fun _ -> failsWith "equality check failed. expected: Not the message, got: Alert Test" click "#alert_test" - alert() == "Not the message") + alert() == "Not the message" - "confirmation box should have 'Confirmation Test'" &&& (fun _ -> + "confirmation box should have 'Confirmation Test'" &&& fun _ -> click "#confirmation_test" alert() == "Confirmation Test" - acceptAlert()) + acceptAlert() - "confirmation box should have 'Confirmation Test'" &&& (fun _ -> + "confirmation box should have 'Confirmation Test'" &&& fun _ -> click "#confirmation_test" alert() == "Confirmation Test" - dismissAlert()) + dismissAlert() - "confirmation box should fail correctly when expecting wrong message" &&& (fun _ -> + "confirmation box should fail correctly when expecting wrong message" &&& fun _ -> failsWith "equality check failed. expected: Not the message, got: Confirmation Test" click "#confirmation_test" - alert() == "Not the message") + alert() == "Not the message" context "multiple elements test" diff --git a/canopy/canopy.fs b/canopy/canopy.fs index bdca4a7d..2e50d669 100644 --- a/canopy/canopy.fs +++ b/canopy/canopy.fs @@ -106,63 +106,11 @@ let waitFor (f : unit -> bool) = puts "Condition not met in given amount of time. If you want to increase the time, put compareTimeout <- 10.0 anywhere before a test to increase the timeout" raise (CanopyWaitForException(sprintf "waitFor condition failed to become true in %.1f seconds" compareTimeout)) -//find related -let private findByCss cssSelector f = - try - f(By.CssSelector(cssSelector)) |> List.ofSeq - with | ex -> [] - -let private findBySizzle cssSelector f = - try - f(BySizzle.CssSelector(cssSelector)) |> List.ofSeq - with | ex -> [] - -let private findByJQuery cssSelector f = - try - f(ByJQuery.CssSelector(cssSelector)) |> List.ofSeq - with | ex -> [] - -let private findByXpath xpath f = - try - f(By.XPath(xpath)) |> List.ofSeq - with | ex -> [] - -let private findByLabel locator f = - let isInputField (element : IWebElement) = - element.TagName = "input" && element.GetAttribute("type") <> "hidden" - - let isField (element : IWebElement) = - element.TagName = "select" || element.TagName = "textarea" || isInputField element - - let firstFollowingField (label : IWebElement) = - let followingElements = label.FindElements(By.XPath("./following-sibling::*[1]")) |> Seq.toList - match followingElements with - | head :: tail when isField head-> [head] - | _ -> [] - try - let label : IWebElement = f(By.XPath(sprintf ".//label[text() = '%s']" locator)) - if (label = null) then - [] - else - match label.GetAttribute("for") with - | null -> firstFollowingField label - | id -> [f(By.Id(id))] - with | _ -> [] - -let private findByText text f = - try - f(By.XPath(sprintf ".//*[text() = '%s']" text)) |> List.ofSeq - with | _ -> [] - -let private findByValue value f = - try - findByCss (sprintf "*[value='%s']" value) f |> List.ofSeq - with | _ -> [] - -let rec private findElements cssSelector (searchContext : ISearchContext) = +//find related +let rec private findElements cssSelector (searchContext : ISearchContext) : IWebElement list = searchedFor <- (cssSelector, browser.Url) :: searchedFor let findInIFrame () = - let iframes = findByCss "iframe" searchContext.FindElements + let iframes = finders.findByCss "iframe" searchContext.FindElements if iframes.IsEmpty then browser.SwitchTo().DefaultContent() |> ignore [] @@ -175,16 +123,8 @@ let rec private findElements cssSelector (searchContext : ISearchContext) = !webElements try - seq { - yield (findByCss cssSelector searchContext.FindElements) - yield (findByValue cssSelector searchContext.FindElements) - yield (findByXpath cssSelector searchContext.FindElements) - yield (findByLabel cssSelector searchContext.FindElement) - yield (findByText cssSelector searchContext.FindElements) - yield (findBySizzle cssSelector searchContext.FindElements) - yield (findByJQuery cssSelector searchContext.FindElements) - yield (findInIFrame()) - } + configuredFinders cssSelector searchContext.FindElements + |> Seq.append (seq { yield (findInIFrame()) }) |> Seq.filter(fun list -> not(list.IsEmpty)) |> Seq.head with | ex -> [] diff --git a/canopy/canopy.fsproj b/canopy/canopy.fsproj index 60f0f1f8..74a5704f 100644 --- a/canopy/canopy.fsproj +++ b/canopy/canopy.fsproj @@ -57,6 +57,7 @@ + diff --git a/canopy/configuration.fs b/canopy/configuration.fs index 5bbeb5af..e33345cd 100644 --- a/canopy/configuration.fs +++ b/canopy/configuration.fs @@ -15,4 +15,5 @@ let mutable runFailedContextsFirst = false let mutable reporter : IReporter = new ConsoleReporter() :> IReporter let mutable disableSuggestOtherSelectors = false let mutable autoPinBrowserRightOnLaunch = true -let mutable throwIfMoreThanOneElement = false \ No newline at end of file +let mutable throwIfMoreThanOneElement = false +let mutable configuredFinders = finders.defaultFinders \ No newline at end of file