Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» how to connect DB in selenium webriver
Fri Oct 06, 2017 4:09 pm by anbarasi

» How find any text in browser screen and click on it?
Thu Oct 05, 2017 2:02 pm by sandeepkommineni

» Selenium Webdriver
Tue Oct 03, 2017 1:35 pm by PiyushBiswas

» GRID setup tutorial.
Wed Sep 27, 2017 4:29 pm by johnyapp

» Drag & Drop Between Windows Using Selenium Driver
Wed Sep 27, 2017 2:10 pm by 26rondel

» Check if window is closed / verify input
Sat Sep 23, 2017 10:21 pm by brainstir

» How to work on pages with AJAX in selenium?
Mon Sep 18, 2017 6:08 pm by azharuddin

» pause test until user press a key like F2
Wed Aug 09, 2017 11:10 pm by djnforce

» Selecting the input for auto populating element
Sat Jul 29, 2017 7:53 pm by kdabbara

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

How to mark checkbox in WebDriver

View previous topic View next topic Go down

How to mark checkbox in WebDriver

Post by michalpelc on 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();
    }
}

michalpelc

Posts : 1
Join date : 2013-08-01

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum