I'm facing an issue where an image disappears after reaching a certain width size. I'm unsure how to address this using Selenium.
<img id="removeimg" class="col-md-5" src="images/abc-image.png" alt="abc">
Below is the corresponding CSS code.
@media only screen and (max-width: 991px) {
#removeimg {
display: none;
}
I've written some Java test code for this scenario, but I have doubts about its correctness.
@BeforeClass
public static void setUp() throws Exception {
driver = new RemoteWebDriver(new URL(System.getProperty("webDriverUrl")), DesiredCapabilities.firefox());
driver.manage().window().setSize(new Dimension(991, 1100));
baseUrl = System.getProperty("baseUrl");
driver.get(baseUrl + "/");
}
@Test
public void testImageNotPresent(){
driver.findElements(By.id("removeimg");
}
UPDATE
I made an update to my Java test code.
@Test
public void testImageNotPresent(){
driver.findElement(By.id("removeimg")).isDisplayed();
assertFalse(isElementPresent(By.id("removeimg")));
}
However, this test case fails when executed. The goal is for it to pass if the image is not visible on the page, but fail if it is visible.