lefthandedgoat / canopy

f# web automation and testing library, built on top of Selenium (friendly to c# also)
http://lefthandedgoat.github.io/canopy/
MIT License
507 stars 115 forks source link

'count' finds exactly 1 matching checkbox, but subsequent 'check' times out. #508

Closed toddmarek closed 4 years ago

toddmarek commented 4 years ago

Hi,

Thanks to all the canopy developers. It is very elegant and I'm loving it already.

Describe the bug I am running some tests that require checkboxes to be checked.

When I run 'count' using the element ID as the selector, it finds exactly 1 matching checkbox, but subsequently try to 'check' the checkbox returns a times out error: canopy.types.CanopyWaitForException: '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

I have added compareTimeout <- 10.0 right below the test (see below), and it makes not difference.

To Reproduce Here is the test code:

open canopy.runner.classic open canopy.configuration open canopy.classic

canopy.configuration.chromeDir <- System.AppContext.BaseDirectory

//start an instance of chrome start chrome

let baseUrl = "https://ascent.greencountywi.org/LandRecordsStaging/"

"asserting there is exactly 1 'remember me' checkbox" &&& fun _ -> url baseUrl

click "#loginLink"

count "#RememberMeChkBox" 1

"checking the 'remember me' checkbox" &&& fun _ -> compareTimeout <- 10.0 check "#RememberMeChkBox"

Expected behavior I expected the #RememberMeChkBox to be checked.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Any insight is appreciated!

Thanks again!

vbop9834 commented 4 years ago

Could you share the snippet of html with the checkbox?

Edit: Thanks for providing a link to the page

<input id="RememberMeChkBox" name="RememberMe" type="checkbox" value="true" class="ng-scope"><label for="RememberMeChkBox" id="RememberMeLabel" name="RememberMeLabel" class="ng-scope">Remember me</label>

The input tag is not displayed on the page (css: display: none) Selenium can only interact with visible elements. Try click "#RememberMeLabel"

toddmarek commented 4 years ago

Hi Jeremy,

Thanks so much for the speedy reply and the helpful information! That did in fact address the issue. Apologies for taking up your time.

Your help is really appreciated!

Best, Todd

vbop9834 commented 4 years ago

You're welcome! :)

Let us know if you have any other questions

Here's a code snippet of the function for the interested https://github.com/lefthandedgoat/canopy/blob/c13b4666eedd16d8e1a1ed57dfa24d21a93285f6/src/canopy/canopy.parallell.functions.fs#L726-L737