Endtest

Endtest

›Web Tests

Web Tests

  • How to create Web Tests
  • Finding elements in Web Applications
  • How to execute Web Tests
  • Assertions for Web Tests
  • IF Statements for Web Tests
  • Web Applications with restricted access
  • How to test in iframes
  • How to test in multiple tabs
  • How to test File Uploads
  • How to test File Downloads
  • How to test Emails
  • How to test PDF files
  • How to test Chrome Extensions
  • Dealing with reCAPTCHA
  • Dealing with Dynamic Locators
  • Dealing with Canvas Elements
  • Performing a Drag and Drop
  • Execute JavaScript
  • Testing WebRTC Applications
  • How to scroll in Web Tests
  • How to test Checkboxes
  • How to test Dropdowns
  • Dealing with Sessions
  • Web Crawler
  • Export Web Tests
  • Migrating from Selenium

Mobile Tests

  • How to create Mobile Tests
  • Finding elements in Mobile Applications
  • How to execute Mobile Tests
  • Assertions for Mobile Tests
  • IF Statements for Mobile Tests
  • How to scroll in Mobile Tests
  • Performing Complex Gestures

Advanced

  • Variables
  • Waits
  • Endtest API
  • Scheduler
  • Drive
  • Adding Collaborators
  • Computer Vision
  • Importing Test Cases
  • Using Loops
  • Data-driven Testing
  • Send API Requests
  • Read SMS
  • Execute SQL queries
  • Self-Healing Tests
  • Email Notifications
  • Slack Notifications
  • PagerDuty Notifications
  • Webhook Notifications
  • Automatic Backup
  • Advanced Settings
  • Multiple environments
  • How to stop a test
  • Utilities
  • Utilities API
  • Team
  • On-Premises

Integrations

  • Atlassian Jira
  • Slack
  • PagerDuty
  • Microsoft Teams
  • Mattermost
  • Jenkins
  • GitHub
  • Azure DevOps
  • GitLab
  • TeamCity
  • CircleCI
  • TravisCI
  • Bitbucket
  • Heroku
  • Bamboo Server
  • Test Case Management
  • SSO
  • BrowserStack
  • Sauce Labs

How to test Checkboxes

Introduction

Checkboxes can be used to let a user select one or more options from a limited set of choices.





This is what the HTML of a checkbox element looks like:

<input type="checkbox">

Assert if a Checkbox element is checked

If the checkbox element is checked, it will have a checked attribute:

<input type="checkbox" checked>

In order to determine if the checkbox element is checked or not, you have to verify if the checked attribute is present.

That can be achieved in 2 different ways:

1. By asserting the presence of the checked attribute

You can use the Element Contains Attribute assertion type from the Add Assertion action:

endtest assert checkbox

Configure that assertion to verify if the checkbox element contains the checked attribute.

2. By using JavaScript

A different approach is to use an Execute JavaScript step.

In that step, you can fetch the checked property of the checkbox element.

isItChecked = document.querySelector("css-selector-of-your-checkbox").checked;

Don't forget to replace the css-selector-of-your-checkbox string with the CSS Selector for your checkbox element.

That isItChecked JavaScript variable will have a value of true or false, depending if the checkbox element is checked or not.

We can add an assertion for that, but first we need to transfer the value from the isItChecked JavaScript variable to an Endtest variable.

That can be done with the Extract Value From JavaScript option from the Set Variable action.

After that, we can use the Variable Assertion option from the Add Assertion action to verify if the value is true.

endtest test checkbox

← How to scroll in Web TestsHow to test Dropdowns →
  • Introduction
  • Assert if a Checkbox element is checked
    • 1. By asserting the presence of the checked attribute
    • 2. By using JavaScript
© Endtest Inc.