• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 266
  • Last Modified:

Remove ticked checkboxes test automation java CSS

I am doing test automation and have a problem with writing a function removing checked/ticked tick boxes.

I have three tickboxes and in this test automation function I want to remove all three ticks and what makes it complicated is that I only want to click in the tickboxes if they are already ticked to remove the ticks.

There is a tag showing if the box is ticked:

<input type="checkbox" name="companyPopularNames[0].reservationOnline" checked="checked" class="info">
<span>Online/Mobile</span>

<input type="checkbox" name="companyPopularNames[0].reservationPrint" class="info">
<span>Print</span>

<input type="checkbox" name="companyPopularNames[0].reservationVoice" checked="checked" class="info">
<span>Voice</span>

In the example above 2 of 3 tick boxes are ticked. Online/Mobile and Voice tick boxes are ticked because checked="checked". So I need to be able to determine which tick boxes are ticked and only click on those tick boxes in this function. The end result of the function should always be that all tick boxes are removed no matter of how many tick boxes are ticked from the beginning!
0
Bear2
Asked:
Bear2
  • 3
  • 2
1 Solution
 
RobOwner (Aidellio)Commented:
http://jsbin.com/sebevedi/1/edit

function uncheck() {
    
$("input:checked").prop("checked",false);
}

Open in new window

0
 
Bear2Author Commented:
I'm getting this error message:


java: cannot find symbol
  symbol:   method $(java.lang.String)
  location: class com.eniro.swat.ecoadmin.page.PlacePage
0
 
Bear2Author Commented:
public void removeNameReservation(String name) {
        for (PlaceNamePopular placeNamePopular: namePopularList){
            if (textEquals(name, placeNamePopular.summary)) if (isDisplayed(placeNamePopular.reservations)) {
                click(summaryPlaceNamePopular);

                    $("input:checked").prop("checked", false);

            }
        }
    }



Getting error message: java: cannot find symbol
  symbol:   method $(java.lang.String)
  location: class com.eniro.swat.ecoadmin.page.PlacePage


What to do?
0
 
Bear2Author Commented:
Ok the problem is that the solution is in java script and I am using java.
0
 
RobOwner (Aidellio)Commented:
Sorry... been away for the holiday.

Yes, the problem is you are using java and I've given you JavaScript. However you should still be able to use my code, it would just run on the client rather than the server.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now