<commit_before>package com.orasi.core;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.interactions.internal.Coordinates;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import com.orasi.core.interfaces.Button;
import com.orasi.core.interfaces.Element;
import com.orasi.core.interfaces.impl.ButtonImpl;
import com.orasi.core.interfaces.impl.ElementImpl;
import com.orasi.utils.TestEnvironment;

public class TestElement extends TestEnvironment{
        
    @BeforeTest(groups ={"regression", "interfaces", "element", "dev"})
    @Parameters({ "runLocation", "browserUnderTest", "browserVersion",
	    "operatingSystem", "environment" })
    public void setup(@Optional String runLocation, String browserUnderTest,
	    String browserVersion, String operatingSystem, String environment) {
	setApplicationUnderTest("Test Site");
	setBrowserUnderTest(browserUnderTest);
	setBrowserVersion(browserVersion);
	setOperatingSystem(operatingSystem);
	setRunLocation(runLocation);
	setTestEnvironment(environment);
	setPageURL("http://www.cs.tut.fi/~jkorpela/www/testel.html");
	testStart("TestElement");
    }
    
    @AfterTest(groups ={"regression", "interfaces", "element", "dev"})
    public void close(){
	endTest("TestElement");
    }

    @Test(groups ={"regression", "interfaces", "element"}, dependsOnMethods="getAttribute")
    public void clear(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	element.sendKeys("testing");
	element.clear();
	Assert.assertTrue(element.getAttribute("value").equals(""));
    }
    
    @Test(groups ={"regression", "interfaces", "element"}, dependsOnMethods="clear") 
    public void click(){
	Element element = new ElementImpl(getDriver().findElement(By.name("reset")));
	element.click();
	Assert.assertTrue(new ElementImpl(getDriver().findElement(By.id("f1"))).getAttribute("value").equals("Default text."));
    }
        
    @Test(groups ={"regression", "interfaces", "element"})
    public void elementWired(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	Assert.assertTrue(element.elementWired());
    }
    
    @Test(groups ={"regression", "interfaces", "element"})
    public void getAttribute(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	Assert.assertTrue(element.getAttribute("type").equals("text"));
    }
  
    @Test(groups ={"regression", "interfaces", "element"})
    public void getCoordinates(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	Assert.assertTrue(element.getCoordinates().onPage().getX() > 0);
	Assert.assertTrue(element.getCoordinates().onPage().getY() > 0);
    }
    
    @Test(groups ={"regression", "interfaces", "element"})
    public void getCssValue(){
	Element element= new ElementImpl(getDriver().findElement(By.name("reset")));
	if(getBrowserUnderTest().equalsIgnoreCase("html")) Assert.assertTrue(element.getCssValue("width").equals("auto"));  
	else Assert.assertTrue(!element.getCssValue("font-family").isEmpty()); 
    }
   
    @Test(groups ={"regression", "interfaces", "element"})
    public void getElementIdentifier(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	Assert.assertTrue(element.getElementIdentifier().equals("f1"));
    }
    
    @Test(groups ={"regression", "interfaces", "element"})
    public void getElementLocator(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	Assert.assertNotNull(element.getElementLocator());
    }
    
    @Test(groups ={"regression", "interfaces", "element"})
    public void getElementLocatorInfo(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	Assert.assertNotNull(element.getElementLocatorInfo());
    }
    
    @Test(groups ={"regression", "interfaces", "element"})
    public void getLocation(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	Assert.assertTrue(element.getLocation().getX() > 0);
	Assert.assertTrue(element.getLocation().getY() > 0);
    }
    
    @Test(groups ={"regression", "interfaces", "element"})
    public void getSize(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	Assert.assertTrue(element.getSize().getHeight() > 0);
	Assert.assertTrue(element.getSize().getWidth() > 0);
    }
    
    @Test(groups ={"regression", "interfaces", "element"})
    public void getTagName(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	Assert.assertTrue(element.getTagName().equals("input"));
    }
    
    @Test(groups ={"regression", "interfaces", "element"})
    public void getText(){
	Element element= new ElementImpl(getDriver().findElement(By.xpath("//a[@href='../index.html']")));
	Assert.assertTrue(element.getText().equals("main page"));
    }    
    
    @Test(groups ={"regression", "interfaces", "element"}, dependsOnMethods="getCssValue")
    public void highlight(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f2")));
	element.highlight(getDriver());
	if(getBrowserUnderTest().toLowerCase().contains("explorer")) Assert.assertTrue(element.getAttribute("style").toLowerCase().contains("red"));
	else Assert.assertTrue(element.getCssValue("border").toLowerCase().contains("red"));
    }
    
    @Test(groups ={"regression", "interfaces", "element"})
    public void isDisplayed(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	Assert.assertTrue(element.isDisplayed());
    }
    
    @Test(groups ={"regression", "interfaces", "element"})
    public void isEnabled(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	Assert.assertTrue(element.isEnabled());
    }
    
    @Test(groups ={"regression", "interfaces", "element"})
    public void isSelected(){
	Element element= new ElementImpl(getDriver().findElement(By.xpath("//*[@id='f10']/option[2]")));
	Assert.assertTrue(element.isSelected());
    }
    
    @Test(groups ={"regression",  "element"})
    public void isSelectedNegative(){
	Element element= new ElementImpl(getDriver().findElement(By.xpath("//*[@id='f10']/option[3]")));
	Assert.assertFalse(element.isSelected());
    }    
    
    @Test(groups ={"regression", "interfaces", "element"}, dependsOnMethods="click") <commit_msg>Fixing unit test<commit_after>package com.orasi.core;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.interactions.internal.Coordinates;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import com.orasi.core.interfaces.Button;
import com.orasi.core.interfaces.Element;
import com.orasi.core.interfaces.impl.ButtonImpl;
import com.orasi.core.interfaces.impl.ElementImpl;
import com.orasi.utils.TestEnvironment;

public class TestElement extends TestEnvironment{
        
    @BeforeTest(groups ={"regression", "interfaces", "element", "dev"})
    @Parameters({ "runLocation", "browserUnderTest", "browserVersion",
	    "operatingSystem", "environment" })
    public void setup(@Optional String runLocation, String browserUnderTest,
	    String browserVersion, String operatingSystem, String environment) {
	setApplicationUnderTest("Test Site");
	setBrowserUnderTest(browserUnderTest);
	setBrowserVersion(browserVersion);
	setOperatingSystem(operatingSystem);
	setRunLocation(runLocation);
	setTestEnvironment(environment);
	setPageURL("http://www.cs.tut.fi/~jkorpela/www/testel.html");
	testStart("TestElement");
    }
    
    @AfterTest(groups ={"regression", "interfaces", "element", "dev"})
    public void close(){
	endTest("TestElement");
    }

    @Test(groups ={"regression", "interfaces", "element"}, dependsOnMethods="getAttribute")
    public void clear(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	element.sendKeys("<PASSWORD>");
	element.clear();
	Assert.assertTrue(element.getAttribute("value").equals(""));
    }
    
    @Test(groups ={"regression", "interfaces", "element"}, dependsOnMethods="clear") 
    public void click(){
	Element element = new ElementImpl(getDriver().findElement(By.name("reset")));
	element.click();
	Assert.assertTrue(new ElementImpl(getDriver().findElement(By.id("f1"))).getAttribute("value").equals("Default text."));
    }
        
    @Test(groups ={"regression", "interfaces", "element"})
    public void elementWired(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	Assert.assertTrue(element.elementWired());
    }
    
    @Test(groups ={"regression", "interfaces", "element"})
    public void getAttribute(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	Assert.assertTrue(element.getAttribute("type").equals("text"));
    }
  
    @Test(groups ={"regression", "interfaces", "element"})
    public void getCoordinates(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	Assert.assertTrue(element.getCoordinates().onPage().getX() > 0);
	Assert.assertTrue(element.getCoordinates().onPage().getY() > 0);
    }
    
    @Test(groups ={"regression", "interfaces", "element"})
    public void getCssValue(){
	Element element= new ElementImpl(getDriver().findElement(By.name("reset")));
	if(getBrowserUnderTest().equalsIgnoreCase("html")) Assert.assertTrue(element.getCssValue("width").equals("auto"));  
	else Assert.assertTrue(!element.getCssValue("font-family").isEmpty()); 
    }
   
    @Test(groups ={"regression", "interfaces", "element"})
    public void getElementIdentifier(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	Assert.assertTrue(element.getElementIdentifier().equals("f1"));
    }
    
    @Test(groups ={"regression", "interfaces", "element"})
    public void getElementLocator(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	Assert.assertNotNull(element.getElementLocator());
    }
    
    @Test(groups ={"regression", "interfaces", "element"})
    public void getElementLocatorInfo(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	Assert.assertNotNull(element.getElementLocatorInfo());
    }
    
    @Test(groups ={"regression", "interfaces", "element"})
    public void getLocation(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	Assert.assertTrue(element.getLocation().getX() > 0);
	Assert.assertTrue(element.getLocation().getY() > 0);
    }
    
    @Test(groups ={"regression", "interfaces", "element"})
    public void getSize(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	Assert.assertTrue(element.getSize().getHeight() > 0);
	Assert.assertTrue(element.getSize().getWidth() > 0);
    }
    
    @Test(groups ={"regression", "interfaces", "element"})
    public void getTagName(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	Assert.assertTrue(element.getTagName().equals("input"));
    }
    
    @Test(groups ={"regression", "interfaces", "element"})
    public void getText(){
	Element element= new ElementImpl(getDriver().findElement(By.xpath("//a[@href='../index.html']")));
	Assert.assertTrue(element.getText().equals("main page"));
    }    
    
    @Test(groups ={"regression", "interfaces", "element"}, dependsOnMethods="getAttribute")
    public void highlight(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f2")));
	element.highlight(getDriver());
	Assert.assertTrue(element.getAttribute("style").toLowerCase().contains("red"));
    }
    
    @Test(groups ={"regression", "interfaces", "element"})
    public void isDisplayed(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	Assert.assertTrue(element.isDisplayed());
    }
    
    @Test(groups ={"regression", "interfaces", "element"})
    public void isEnabled(){
	Element element= new ElementImpl(getDriver().findElement(By.id("f1")));
	Assert.assertTrue(element.isEnabled());
    }
    
    @Test(groups ={"regression", "interfaces", "element"})
    public void isSelected(){
	Element element= new ElementImpl(getDriver().findElement(By.xpath("//*[@id='f10']/option[2]")));
	Assert.assertTrue(element.isSelected());
    }
    
    @Test(groups ={"regression",  "element"})
    public void isSelectedNegative(){
	Element element= new ElementImpl(getDriver().findElement(By.xpath("//*[@id='f10']/option[3]")));
	Assert.assertFalse(element.isSelected());
    }    
    
    @Test(groups ={"regression", "interfaces", "element"}, dependsOnMethods="click") 
{'fraction_non_alphanumeric': 0.1723851269649335, 'fraction_numerical': 0.004081015719467957, 'mean_word_length': 5.686710459828196, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '5316469', 'n_tokens_mistral': 3956, 'n_tokens_neox': 3971, 'n_words': 659}