From 5bfc0010df0dcc5068ed195c0fc18be902196e34 Mon Sep 17 00:00:00 2001 From: Chris Holt Date: Sun, 27 Mar 2016 17:10:24 -0600 Subject: [PATCH] Fix #253 multiple dropdowns on the same page with same values --- docs/files/testpages/selectOptions.html | 18 ++++++++++++++++++ src/canopy/canopy.fs | 4 ++-- tests/basictests/Program.fs | 7 +++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 docs/files/testpages/selectOptions.html diff --git a/docs/files/testpages/selectOptions.html b/docs/files/testpages/selectOptions.html new file mode 100644 index 00000000..c5055542 --- /dev/null +++ b/docs/files/testpages/selectOptions.html @@ -0,0 +1,18 @@ + + + + + +
+ + + + \ No newline at end of file diff --git a/src/canopy/canopy.fs b/src/canopy/canopy.fs index d63657e6..fbb8af54 100644 --- a/src/canopy/canopy.fs +++ b/src/canopy/canopy.fs @@ -287,9 +287,9 @@ let last cssSelector = (List.rev (elements cssSelector)).Head let private writeToSelect (elem:IWebElement) (text:string) = let options = if writeToSelectWithOptionValue then - unreliableElementsWithin (sprintf """//option[text()="%s"] | //option[@value="%s"]""" text text) elem + unreliableElementsWithin (sprintf """option[text()="%s"] | option[@value="%s"] | optgroup/option[text()="%s"] | optgroup/option[@value="%s"]""" text text text text) elem else //to preserve previous behaviour - unreliableElementsWithin (sprintf """//option[text()="%s"]""" text) elem + unreliableElementsWithin (sprintf """option[text()="%s"] | optgroup/option[text()="%s"]""" text text) elem match options with | [] -> raise (CanopyOptionNotFoundException(sprintf "element %s does not contain value %s" (elem.ToString()) text)) diff --git a/tests/basictests/Program.fs b/tests/basictests/Program.fs index 617a2325..bd9a9d5b 100644 --- a/tests/basictests/Program.fs +++ b/tests/basictests/Program.fs @@ -451,6 +451,13 @@ context "other tests" "#states" << "95" "#states" == "Palmyra Atoll" +"writting (selecting) to drop down test, two selects same value" &&& fun _ -> + !^ "http://lefthandedgoat.github.io/canopy/testpages/selectOptions" + "#test-select" << "g" + "#test-select2" << "b" + "#test-select" == "Green" + "#test-select2" == "Blue" + "writting (selecting) to drop down test, value list, opt group" &&& fun _ -> !^ testpage "#test-select" << "Audi"