package test;
import com.thoughtworks.selenium.*;
import org.openqa.selenium.server.*;
import org.testng.annotations.*;
public class Checkboxcount {
public Selenium selenium;
public SeleniumServer seleniumserver;
@BeforeClass
public void setUp() throws Exception {
RemoteControlConfiguration rc = new RemoteControlConfiguration();
seleniumserver = new SeleniumServer(rc);
selenium = new DefaultSelenium("localhost", 4444, "*firefox","http://");
seleniumserver.start();
selenium.start();
}
@Test
public void testDefaultTNG() throws Exception {
selenium.open("http://browsershots.org/");
selenium.windowMaximize();
//Count of check boxes
Number c =selenium.getXpathCount("//input[@type['checkbox']]");
System.out.println("Count of check boxes " +c);
//Number of check boxes checked
Number d = selenium.getXpathCount("//input[@type='checkbox' and @checked]");
System.out.println("Count of Checked check boxes " +d);
//Number of check boxes unchecked
Number e = selenium.getXpathCount("//input[@type='checkbox' and not(@checked)]");
System.out.println("Count of Checked check boxes " +e);
}
@AfterClass
public void tearDown() throws Exception {
selenium.stop();
seleniumserver.stop();
}
}
If you uncheck some check boxes and try the above script it will not work....bcos if you check and uncheck this wouldn't change any thing in their html....
Could you please tell me how to delete particular check box out of 10 check box.
ReplyDeleteMail=info.bhanupratap@gmail.com
Hi thats great work.......
ReplyDeleteI need your help...
When i used ur code
//Number of check boxes checked
Number d = selenium.getXpathCount("//input[@type='checkbox' and @checked]");
System.out.println("Count of Checked check boxes " +d);
//Number of check boxes unchecked
Number e = selenium.getXpathCount("//input[@type='checkbox' and not(@checked)]");
System.out.println("Count of Checked check boxes " +e);
Iam getting output as
Count of check boxes 12
Count of Checked check boxes 0
Count of UnChecked check boxes 0
Can u help me with this
Thanks in advance:)
Hi,
ReplyDeleteI get the same output as Sindhu :( Been trying a lot... :(
No Solution :(