Sammy
Sammy

Reputation: 77

Unable to click on checkboxes using Robot Framework and selenium2library

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.

enter image description here

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!!

enter image description here

HTML screenshot.

enter image description here

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

Answers (1)

Murthi
Murthi

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

Related Questions