3
 System.setProperty("webdriver.chrome.driver", "C:\\Users\\srajendran\\Documents\\chromedriver.exe");
 WebDriver driver=new ChromeDriver();
 driver.get("http://qaclickacademy.com/practice.php");
 driver.manage().window().maximize();
 WebElement Radio = driver.findElement(By.xpath("//input[@value='radio1']"));
 Radio.click();
 Thread.sleep(2000);
 WebElement Radio2 = driver.findElement(By.xpath("//input[@value='radio2']"));
 Radio2.click();
 Thread.sleep(2000);
 Assert.assertEquals(driver.findElements(By.xpath("//input[@class='radioButton']")).size(), "3");
 System.out.println(driver.findElements(By.xpath("//input[@class='radioButton']")).size());
 Thread.sleep(2000);
 WebElement Checkb1= driver.findElement(By.xpath("//input[@value='option1']"));
 Checkb1.click();
 WebElement Checkb2= driver.findElement(By.xpath("//input[@value='option2']"));
 Checkb2.click();
 System.out.println(driver.findElements(By.xpath("//input[@type='checkbox']")).size());
Niels van Reijmersdal
32.7k4 gold badges59 silver badges125 bronze badges
asked Dec 6, 2019 at 10:33

1 Answer 1

8

Hi size() returns integer and you are comparing with string

You can use the size() method of java. util. ArrayList to find the length or size of ArrayList in Java. The size() method returns an integer equal to a number of elements present in the array list. https://www.java67.com/2016/07/how-to-find-length-size-of-arraylist-in-java.html

So the fix would be to change "3" to 3:

Assert.assertEquals(driver.findElements(By.xpath("//input[@class='radioButton']")).size(), 3);
answered Dec 6, 2019 at 10:44

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.