Selenium testNG assertion breaks the script even when everything is ok
I wrote below two lines at the end of the script, but second line does not run giving an assert error (please see below). Everything runs properly when I disabled the Assertion. What’s happening here? Thank you.
Assert.assertEquals(driver.findElements(By.cssSelector("input[type='checkbox']")).size(), "6"); driver.findElement(By.xpath("//input[@id='ctl00_mainContent_btn_FindFlights']")).click();
ERROR
Exception in thread "main" java.lang.AssertionError: expected [6] but found [6] at org.testng.Assert.fail(Assert.java:89) at org.testng.Assert.failNotEquals(Assert.java:489) at org.testng.Assert.assertEquals(Assert.java:118) at org.testng.Assert.assertEquals(Assert.java:160) at assignment1.main(assignment1.java:128)
Not an expert, but it looks like you’re getting a size which is an integer and comparing it to a string with a value of 6, and that will always fail because strings are never integers.