package pt.fccn.sobre.arquivo.pages;

import java.io.FileNotFoundException;
import java.nio.charset.Charset;
import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import pt.fccn.arquivo.tests.util.AnalyzeURLs;

public class PresentationsPage {
	
	WebDriver driver;
	private final int timeout = 50;
	
	public PresentationsPage( WebDriver driver ) throws FileNotFoundException{
		this.driver = driver;

		
	}
	
	public boolean checkPresentationLinks( String language ) {
		System.out.println( "[checkPresentationLinks]" );
		String idDiv = "";
		 
		if( language.equals( "PT" ) )
			idDiv = "post-3036";
		else
			idDiv = "post-3219";
		
		String xpatha = "//*[@id=\""+ idDiv +"\"]/div/div/ul/li/a";
		try{
    		List< WebElement > results = ( new WebDriverWait( driver, timeout ) )
	                .until( ExpectedConditions
	                        .visibilityOfAllElementsLocatedBy(
	                        		      By.xpath( xpatha )
	                        )
	        );
    		
    		System.out.println( "[Presentation Links] results size = " + results.size( ) );
    		for( WebElement elem : results ) {
    			String url = elem.getAttribute( "href" );
    			int statusCode = AnalyzeURLs.linkExists( url );
    			String text = elem.getText( );
    			Charset.forName( "UTF-8" ).encode( text );
    			if( !AnalyzeURLs.checkOk( statusCode ) ) {
    				System.out.println( "Failed: text["+text+"] link[" + url + "] status-code[" + statusCode + "]" );
    				return false;
    			}
    		}
    		
	    	return true;
    	} catch( NoSuchElementException e ){
            System.out.println( "Error in checkPresentationLinks" );
            e.printStackTrace( );
            return false;
    	}
		
	}
	
}

@@ -1547,59 +1547,8 @@
  %09%09%09
-if( !AnalyzeURLs.checkOk( statusCode ) ) %7B%0A    %09%09%09%09
 Syst
@@ -1637,24 +1637,85 @@
 de + %22%5D%22 );%0A
+    %09%09%09/*if( !AnalyzeURLs.checkOk( statusCode ) ) %7B%0A    %09%09%09%09%0A
     %09%09%09%09retu
@@ -1732,16 +1732,18 @@
     %09%09%09%7D
+*/
 %0A    %09%09%7D

Check PresentationTest