In my Angular page there are 15 checkboxes and a label that when I select on each checkbox individually, a result will appear in the label. Plus when a checkbox click with a combination with others, the result will change in the label.

How can I run a Protractor loop to test these checkbox with a combination with each other, without involving with a lot of loops?

More Explanation

I have 15 checkboxes and I have to run a smoketest using Protractor. Run every possibility combination of these checkboxes and check the label that has the result to have expected result. Now is there a simple way to run these checkboxes combinations!

  • 2
    It sounds like a question with many answers. Perhaps you can be more specific. Ideally if you also show your example code how you approached this problem. – pavelsaman Jan 18 at 20:10
  • Do you really want to verify all 225 combinations? When the label value is set by back-end logic, it might be better to create unit tests for the back-end code. – Bouke Jan 21 at 12:47
  • Does your application show 225 unique label text based on each combination?? I doubt that. If it doesn't display that many different label values , then we shouldn't create that many test combinations. – Vishal Aggarwal Feb 7 at 11:17
  • Let's say it is creating 15 different label text covering all these 225 checkbox combinations then we can reduce it substantially to only make 15-20 checks only. – Vishal Aggarwal Feb 7 at 11:23

Assuming you have a pagebject method pageObject.selectCheckbox(idx) which select a checkbox using index. and pageObject.verify("Message") which takes in the expected message and verifies its present.

let final = []
printCombination = function (arr, n, r) {
    data = Array(r)
    combinationUtil(arr, data, 0, n - 1, 0, r)

combinationUtil = function (arr, data, start,
    end, index, r) {
    let i = ""
    if (index == r) {
        for (j of [...Array(r).keys()]) {
            i += data[j]
        return i

    i = start
    while (i <= end && end - i + 1 >= r - index) {
        data[index] = arr[i]
        combinationUtil(arr, data, i + 1,
            end, index + 1, r)
        i += 1

arr = [...Array(15).keys()]

n = arr.length

arr.forEach((val, r, array) => {
    printCombination(arr, n, r)

//print final to see the full combination list generated
final.forEach((a) => {

    [...a].forEach((idx) => {
        console.log("char", idx)



This will text all 15 combination ( Order ignored and no duplicates)

credit :


  • Thank you that seems helpful. I will try it and get back to you. – WhiteFlower Jan 21 at 17:15
  • @PDhide, are you suggesting to test 225 checkbox combinations one by one and verifying label in UI? Do you think its correct & efficient approach? – Vishal Aggarwal Feb 7 at 11:27
  • @VishalAggarwal its an exhaustive approach if its that the user wants – PDHide Feb 7 at 11:28
  • Any automation purely reflects the quality of manual process its automating. Garbage in garbage out. – Vishal Aggarwal Feb 7 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.