package com.agile611.testng.webdriver;

import java.io.File;
import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class BrokenImages {
    WebDriver driver;

    @BeforeMethod
    public void setUp() throws Exception {
        FirefoxOptions options = new FirefoxOptions();
        System.setProperty("webdriver.gecko.driver",
                "src" + File.separator + "main"
                        + File.separator + "resources"
                        + File.separator + "geckodriver-macos");
        driver = new FirefoxDriver(options);
    }

    @AfterMethod
    public void tearDown() {
        driver.quit();
    }

    @Test
    public void allImagesLoaded() {
        driver.navigate().to("http://the-internet.herokuapp.com/broken_images");
        List<WebElement> images = driver.findElements(By.tagName("img"));
        // Simplified test, no proxy check
    }
}
