Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- selenium.check("//input[@name=’checkboxes[]’ and @value=’cb3’]");
- isChecked = driver.findElement(By.xpath("//input[@type='checkbox']"));
- if (isChecked = false) {
- check the box;
- } else {
- do nothing;
- }
- WebElement checkBox1;
- WebElement checkBox3;
- checkBox1 = driver.findElement(By.cssSelector("input[value='cb1']"));
- checkBox3 = driver.findElement(By.cssSelector("input[value='cb3']"));
- if(!checkBox1.isSelected()){
- checkBox1.click();
- }
- //checkBox3 is selected by default
- if(checkBox3.isSelected()){
- checkBox3.click();
- }
- List<WebElement> selectElements=
- driver.findElements(By.cssSelector("input[name='checkboxes[]']"));
- selectElements.get(0).click();
- if( selectElements.get(2).isSelected()){
- selectElements.get(2).click();
- }
- for(WebElement checkbox : selectElements){
- // uncheck 'em all
- if(checkbox.isSelected()){
- checkbox.click();
- }
- }
- IWebElement element = driver.findElement(By.xpath("//input[@type='checkbox']"));
- if (!element.Selected)
- {
- element.Click();
- }
- IWebElement chkBox = driver.FindElement(By.Id("some id "));
- if (chkBox.Selected) {
- //perform actions
- } else {
- //perform actions
- }
- /* load that webelement list of radio buttons. then follow the below code & logic */
- List<WebElement> rdBtn_Sex = driver.findElements(By.name("sex"));
- // Create a boolean variable which will hold the value (True/False)
- boolean bValue = false;
- // This statement will return True, in case of first Radio button is selected
- bValue = rdBtn_Sex.get(0).isSelected();
- // This will check that if the bValue is True means if the first radio button is selected
- if (bValue = true) {
- // This will select Second radio button, if the first radio button is selected by default
- rdBtn_Sex.get(1).click();
- } else {
- // If the first radio button is not selected by default, the first will be selected
- rdBtn_Sex.get(0)).click();
- }
Add Comment
Please, Sign In to add comment