Skip to content

Commit

Permalink
Fix for issue #170
Browse files Browse the repository at this point in the history
  • Loading branch information
lefthandedgoat committed Oct 20, 2014
1 parent 2f96835 commit ce9f4f1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Rakefile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
task :default => [:build, :ui]

task :build do
sh 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe canopy.sln'
sh 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe canopy.sln /p:VisualStudioVersion=12.0'
end

task :ui do
Expand Down
12 changes: 5 additions & 7 deletions src/canopy/canopy.fs
Original file line number Diff line number Diff line change
Expand Up @@ -295,17 +295,15 @@ let last cssSelector = (List.rev (elements cssSelector)).Head

//read/write
let private writeToSelect (elem:IWebElement) (text:string) =
let options =
let optionsByText = unreliableElementsWithin (sprintf "option[text()='%s']" text) elem
if writeToSelectWithOptionValue then
let optionsByValue = unreliableElementsWithin (sprintf "option[value='%s']" text) elem
optionsByText @ optionsByValue
let options =
if writeToSelectWithOptionValue then
unreliableElementsWithin (sprintf """option[text()="%s"] | option[@value="%s"]""" text text) elem
else //to preserve previous behaviour
optionsByText
unreliableElementsWithin (sprintf """option[text()="%s"]""" text) elem

match options with
| [] -> raise (CanopyOptionNotFoundException(sprintf "element %s does not contain value %s" (elem.ToString()) text))
| head::tail -> head.Click()
| head::_ -> head.Click()

let private writeToElement (e : IWebElement) (text:string) =
if e.TagName = "select" then
Expand Down
8 changes: 8 additions & 0 deletions tests/basictests/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,14 @@ context "other tests"
url "http://lefthandedgoat.github.io/canopy/testpages/iframe2"
first "body" |> elementWithin "#states" |> elementWithin "1" |> read |> is "Alabama"

"selecting option in iframe works by text and value" &&& fun _ ->
url "http://lefthandedgoat.github.io/canopy/testpages/iframe1"

"#item_list" << "Item 2"
"#item_list" == "Item 2"
"#item_list" << "3"
"#item_list" == "Item 3"

context "hints tests"
"css hint" &&& fun _ ->
url testpage
Expand Down

0 comments on commit ce9f4f1

Please sign in to comment.