Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
michalpelc
Posts : 1
Join date : 2013-08-01

How to mark checkbox in WebDriver Empty How to mark checkbox in WebDriver

Thu Aug 01, 2013 4:52 pm
Hi,

At the first I must inform that I'm new in Selenium testing automation Smile ...
I have to test registration functionality of website. 
Unit TC: 
1 open registration xkom website
2 fill all of editable fields
3 mark checkboxes 
4 Click Save button.

As for 1 i 2 my script is working ok, but as for 3 not and I don't know how to perform 4'th step. Please help.

As for checkboxes I've tried many examples - without any success:
1. WebElement oRadioBtn = driver.findElement(By.xpath(".//form[@name='register_form']//input[@name='accept_personal_agr']"));
oRadioBtn.isSelected();
oRadioBtn.click();

2. WebElement oRadioBtn = driver.findElement(By.xpath(".//form[@name='register_form']//input[@name='accept_personal_agr']"));
oRadioBtn.click();
3. WebElement kancheck = driver.findElement(By.name("accept_reg_agr"));
kancheck.click();
System.out.println(kancheck.isSelected());

4. WebElement oRadioBtn = driver.findElement(By.cssSelector("input[name='accept_reg_agr']"));
oRadioBtn.click();

5. WebElement oRadioBtn = driver.findElement(By.xpath("//input[@value='Akceptu']"));
oRadioBtn.click();

6. driver.findElement(By.id("qf_589fee")).click();


7.        List CHECKBOXlist = driver.findElements(By.xpath("//input[@type='CHECKBOX']"));
        for(int i=0;i            System.out.println(CHECKBOXlist.get(i).isSelected());
    }
       
        for(int i=0;i            CHECKBOXlist.get(i).click();
}
        
        for(int i=0;i            System.out.println(CHECKBOXlist.get(i).isSelected());
    }





//REGISTRATION CLASS

package mojpackage;

import org.openqa.selenium.By;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

public class KLASA1  {
    public static void main(String[] args) throws InterruptedException {
     
        WebDriver driver = new FirefoxDriver();

        driver.get("registration xkom site");
              
       WebElement element =  driver.findElement(By.name("user_login"));
        WebElement element1 = driver.findElement(By.name("user_pass1"));
        WebElement element2 = driver.findElement(By.name("user_pass2"));
        WebElement element3 = driver.findElement(By.name("user_name1"));
        WebElement element4 = driver.findElement(By.name("user_name2"));
        WebElement element5 = driver.findElement(By.name("user_email"));
        WebElement element6 = driver.findElement(By.name("user_email_repeat"));
        WebElement element7 = driver.findElement(By.name("user_tel_stac"));

        element.sendKeys("mojlogin");
        element1.sendKeys("mojehaslo");
        element2.sendKeys("mojehaslo");
        element3.sendKeys("mojeimie");
        element4.sendKeys("mojenazwisko");
        element5.sendKeys("mojemailwp.pl");
        element6.sendKeys("mojemailwp.pl");
        element7.sendKeys("597837465");

        element.submit();
        element1.submit();
        element2.submit();
        element3.submit();
        element4.submit();
        element5.submit();
        element6.submit();
        element7.submit();
                
        List CHECKBOXlist = driver.findElements(By.xpath("//input[@type='CHECKBOX']"));
        for(int i=0;i            System.out.println(CHECKBOXlist.get(i).isSelected());
    }
       
        for(int i=0;i            CHECKBOXlist.get(i).click();
}
        
        for(int i=0;i            System.out.println(CHECKBOXlist.get(i).isSelected());
    }
                           
        
            driver.quit();
    }
}
Back to top
Permissions in this forum:
You cannot reply to topics in this forum