<commit_before>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 SiteMapPage {

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

	}
	
	public boolean checkSiteMap( String language ) {
		System.out.println( "[checkSiteMap]" );
		String idDiv = "";
		if( language.equals( "EN" ) )
			idDiv = "post-2764";
		else 
			idDiv = "post-2659";

		String xpathDiv = "//*[@id=\""+ idDiv +"\"]/div/div/div"; //find the div tag
		try{
		   WebElement divTag = ( new WebDriverWait( driver, timeout ) ) /* Wait Up to 50 seconds should throw RunTimeExcpetion*/
	                .until(
	                		ExpectedConditions.presenceOfElementLocated(
	                				By.xpath( xpathDiv ) ) );
	        
		   //find all the a tags in the div tag
		   List< WebElement > allAnchors = divTag.findElements( By.tagName( "a" ) );
    		
		   System.out.println( "[SiteMap] results size = " + allAnchors.size( ) );
		   for( WebElement elem : allAnchors ) {
			   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 checkOPSite" );
            e.printStackTrace( );
            return false;
    	}
    	
	}
	

	
}<commit_msg>[SiteMapTest] Add switch language<commit_after>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 SiteMapPage {

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

	}
	
	public boolean checkSiteMap( String language ) {
		System.out.println( "[checkSiteMap]" );
		String idDiv = "";
		if( language.equals( "EN" ) ){
			switchLanguage( );
			idDiv = "post-2764";
		}else 
			idDiv = "post-2659";

		String xpathDiv = "//*[@id=\""+ idDiv +"\"]/div/div/div"; //find the div tag
		try{
		   WebElement divTag = ( new WebDriverWait( driver, timeout ) ) /* Wait Up to 50 seconds should throw RunTimeExcpetion*/
	                .until(
	                		ExpectedConditions.presenceOfElementLocated(
	                				By.xpath( xpathDiv ) ) );
	        
		   //find all the a tags in the div tag
		   List< WebElement > allAnchors = divTag.findElements( By.tagName( "a" ) );
    		
		   System.out.println( "[SiteMap] results size = " + allAnchors.size( ) );
		   for( WebElement elem : allAnchors ) {
			   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 checkOPSite" );
            e.printStackTrace( );
            return false;
    	}
    	
	}
	
    /**
    * Change to the English version
    */
    private void switchLanguage( ){
    	String xpathEnglishVersion = "//*[@id=\"menu-item-4506-en\"]/a";
      	if( driver.findElement( By.xpath( xpathEnglishVersion ) ).getText( ).equals( "English" ) ) {
      		System.out.println( "Change language to English" );
      		driver.findElement( By.xpath( xpathEnglishVersion ) ).click( );
      		IndexSobrePage.sleepThread( );
      	}
    }
    
	
}
{'fraction_non_alphanumeric': 0.12801564877200608, 'fraction_numerical': 0.006520321669202347, 'mean_word_length': 2.7082997582594683, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '928800', 'n_tokens_mistral': 1660, 'n_tokens_neox': 1480, 'n_words': 330}