testdevlab / TestUI

MIT License
33 stars 9 forks source link

Validate that screenshot has `.png` extension #81

Open aleksslitvinovs opened 1 year ago

aleksslitvinovs commented 1 year ago

saveScreenshot() allows passing any extension into path parameter and no errors are thrown. IMO, before making a screenshot, it must be verified that filename has .png extension

Here's an example script

import static testUI.UIOpen.open;
import static testUI.Utils.By.byCssSelector;
import static testUI.elements.TestUI.E;

import org.testng.annotations.Test;

public class Testing {
    @Test
    public void test() {
        open("https://example.com");

        E(byCssSelector("")).saveScreenshot("test.png"); // valid screenshot

        E(byCssSelector("")).saveScreenshot("test.y4m"); // invalid screenshot extension
    }
}