Reputation: 77
I used 3 different waits purposely to locate the element (a checkbox) on the page as shown below and they get passed. After that I click on that same element which also gets passed.
Now my question is if the click element method gets passed then why does Checkbox should be selected fails because in click element method I am clicking on that checkbox only!!
HTML screenshot.
I have tried this clicking on checkbox multiple times using various strategies but it fails every time. Please help and suggest some solution!!
Code I wrote:
` sleep 2
wait until page contains element id_service_levels_0
wait until element is enabled id=id_service_levels_0
wait until element is enabled id=id_service_levels_0
page should contain element id=id_service_levels_0
click element id=id_service_levels_0
checkbox should be selected id=id_service_levels_0
`
Upvotes: 3
Views: 4342
Reputation: 5347
You can try with JavaScript executor as given below.
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("document.getElementById('id_service_levels_0').click()");
Upvotes: 1