import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class CheckBox_Alternate_click
{
public static void main(String[] args) throws InterruptedException
{
WebDriver driver=new FirefoxDriver();
driver.get("http://www.flipkart.com/mobiles/apple~brand/pr?sid=tyy%2C4io&otracker=ch_vn_mobile_filter_Top+Brands_Apple");
driver.manage().window().maximize();
Thread.sleep(2000);
//List<WebElement> chkboxes = driver.findElements(By.xpath("//input[@type='checkbox']"));////input[contains(@class,'compare-checkbox')]
List<WebElement> chkboxes = driver.findElements(By.xpath("//input[contains(@class,'compare-checkbox')]"));//
for(int i = 0; i<chkboxes.size(); i=i+2)
{
chkboxes.get(i).click();
System.out.println("clicking check boxes : ");
}
driver.quit();
}
}
++++++++++++++++++++++++++++++++
public void verifyHandlingCheckBox()
{
driver.get("http://toolsqa.com/automation-practice-form/?firstname=&lastname=&sex=Female&photo=&continents=Asia&submit=");
//get and click select check boxes
List<WebElement> checkBox=driver.findElements(By.cssSelector("input[name=profession]"));
for(int i=0;i<checkBox.size();i++)
{
checkBox.get(i).click();
}
int checkedCount = 0;
int uncheckedCount = 0;
for(int i=0;i<checkBox.size();i++)
{
System.out.println(i + " : check box is selected" + checkBox.get(i).isSelected());
if(checkBox.get(i).isSelected())
{
checkedCount++;
}
else
{
uncheckedCount++;
}
}
System.out.println("number of selected checkbox: "+checkedCount);
System.out.println("number of unselected checkbox: "+uncheckedCount);
}
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class CheckBox_Alternate_click
{
public static void main(String[] args) throws InterruptedException
{
WebDriver driver=new FirefoxDriver();
driver.get("http://www.flipkart.com/mobiles/apple~brand/pr?sid=tyy%2C4io&otracker=ch_vn_mobile_filter_Top+Brands_Apple");
driver.manage().window().maximize();
Thread.sleep(2000);
//List<WebElement> chkboxes = driver.findElements(By.xpath("//input[@type='checkbox']"));////input[contains(@class,'compare-checkbox')]
List<WebElement> chkboxes = driver.findElements(By.xpath("//input[contains(@class,'compare-checkbox')]"));//
for(int i = 0; i<chkboxes.size(); i=i+2)
{
chkboxes.get(i).click();
System.out.println("clicking check boxes : ");
}
driver.quit();
}
}
++++++++++++++++++++++++++++++++
public void verifyHandlingCheckBox()
{
driver.get("http://toolsqa.com/automation-practice-form/?firstname=&lastname=&sex=Female&photo=&continents=Asia&submit=");
//get and click select check boxes
List<WebElement> checkBox=driver.findElements(By.cssSelector("input[name=profession]"));
for(int i=0;i<checkBox.size();i++)
{
checkBox.get(i).click();
}
int checkedCount = 0;
int uncheckedCount = 0;
for(int i=0;i<checkBox.size();i++)
{
System.out.println(i + " : check box is selected" + checkBox.get(i).isSelected());
if(checkBox.get(i).isSelected())
{
checkedCount++;
}
else
{
uncheckedCount++;
}
}
System.out.println("number of selected checkbox: "+checkedCount);
System.out.println("number of unselected checkbox: "+uncheckedCount);
}
No comments:
Post a Comment