Answers for "checkbox and radio button"

0

radio and checkbox html

<!doctype html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Book Store</title>
    <meta name="description" content="This Is Our Book Store" />
  </head>
  <body>
    <div>
      <h1>Book Store</h1>
      <p>This Is My Book Store, Welcome</p>
    </div>
    <form action="" method="GET">
      <input type="hidden" value="Osama" />
      <div>
        <label>Username</label>
        <input type="text" required placeholder="Username" name="user" value="Osama" readonly />
      </div>
      <br />
      <div>
        <label>Subject</label>
        <input type="text" name="subject" autofocus />
      </div>
      <br />
      <div>
        <label>Password</label>
        <input
          type="password"
          required
          placeholder="Write A Complex Password"
          name="pass"
          minlength="10"
          maxlength="20"
        />
      </div>
      <br />
      <div>
        <label>Email</label>
        <input type="email" required placeholder="Write A Valid Email" value="[email protected]" name="mail" disabled />
      </div>
      <br />
      <div>
        <label>Color</label>
        <input type="color" name="Color" />
      </div>
      <br />
      <div>
        <label>Range</label>
        <input type="range" name="range" min="0" max="100" step="20" value="80" />
      </div>
      <br />
      <div>
        <label for="num">Number</label>
        <input id="num" type="number" name="number" min="10" max="100" step="10" />
      </div>
      <hr />
      <div>
        <input id="win" type="radio" name="os" value="Windows" checked />
        <label for="win">Windows</label>
      </div>
      <div>
        <input id="lin" type="radio" name="os" value="Linux" />
        <label for="lin">Linux</label>
      </div>
      <div>
        <input id="mac" type="radio" name="os" value="Mac" />
        <label for="mac">Mac</label>
      </div>
      <hr />
      <div>
        <input id="win1" type="checkbox" name="os" value="Windows" checked />
        <label for="win1">Windows</label>
      </div>
      <div>
        <input id="lin1" type="checkbox" name="os" value="Linux" />
        <label for="lin1">Linux</label>
      </div>
      <div>
        <input id="mac1" type="checkbox" name="os" value="Mac" />
        <label for="mac1">Mac</label>
      </div>
      <br />
      <input type="reset" value="Reset" />
      <input type="submit" value="Save" />
    </form>
  </body>
</html>
Posted by: Guest on October-22-2021
0

checkboxes and radio buttons

- We locate, and we click on them. 
isSelected() isSelected()--> true,  else --> false 
This method checks if the checkbox/radiobutton is selected or not selected. 
isEnabled() isEnabled -> true,  else --> false
This method checks if the checkbox/radiobutton is enabled to be clicked.      
isDispalyed()  isDispalyed()-> true, else --> false
verify the presence of a web element within the web page.                          

    syntax: driver.findElement(LOCATOR).isSelected();   
    syntax: driver.findElement(LOCATOR).isEnabled();
StaleElementReferenceException: 
A stale element reference exception is thrown in one of two cases
1- The element has been deleted entirely.
2- The element is no longer attached to the DOM.
    WebElement checkbox = driver.findElement(LOCATOR); 
    checkbox.click; driver.navigate().refresh(); 
    checkbox = driver.findElement(LOCATOR);
    checkbox.click();  <--stale element reference exception will be thrown
Posted by: Guest on May-29-2021

Code answers related to "checkbox and radio button"

Browse Popular Code Answers by Language