package com.sdl.selenium.extjs6.form;

import com.sdl.selenium.web.SearchType;
import com.sdl.selenium.web.WebLocator;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;

public class DisplayFieldTest {
    public static WebLocator container = new WebLocator("container");

    @DataProvider
    public static Object[][] testConstructorPathDataProvider() {
        return new Object[][]{
                {new DisplayField(), "//div[contains(concat(' ', @class, ' '), ' x-form-display-field ')]"},
                {new DisplayField(container), "//*[contains(concat(' ', @class, ' '), ' container ')]//div[contains(concat(' ', @class, ' '), ' x-form-display-field ')]"},
                {new DisplayField(container, "Project"), "//*[contains(concat(' ', @class, ' '), ' container ')]//label[(contains(.,'LabelText') or count(*//text()[contains(.,'LabelText')]) > 0)]//following-sibling::*//div[contains(concat(' ', @class, ' '), ' x-form-display-field ')]"},
                {new DisplayField(container, "|File Name|Project", SearchType.CONTAINS_ANY), "//*[contains(concat(' ', @class, ' '), ' container ')]//label[(.='LabelText' or count(*//text()[.='LabelText']) > 0)]//following-sibling::*//div[contains(concat(' ', @class, ' '), ' x-form-display-field ')]"},
                {new DisplayField(container).setLabel("|File Name|Project", SearchType.CONTAINS_ANY), "//*[contains(concat(' ', @class, ' '), ' container ')]//label[(.='LabelText' or count(*//text()[.='LabelText']) > 0)]//following-sibling::*//div[contains(concat(' ', @class, ' '), ' x-form-display-field ')]"},
        };
    }

    @Test(dataProvider = "testConstructorPathDataProvider")
    public void getPathSelectorCorrectlyFromConstructors(DisplayField field, String expectedXpath) {
        assertThat(field.getXPath(), equalTo(expectedXpath));
    }
}

@@ -927,24 +927,22 @@
 ains(.,'
-LabelTex
+Projec
 t') or c
@@ -968,24 +968,22 @@
 ains(.,'
-LabelTex
+Projec
 t')%5D) %3E 
@@ -1231,36 +1231,35 @@
 ')%5D//label%5B(
-.='LabelText
+('File Name
 ' or count(*
@@ -1263,35 +1263,83 @@
 t(*//text()%5B
-.='LabelTex
+'File Name'%5D) %3E 0) or ('Project' or count(*//text()%5B'Projec
 t'%5D) %3E 0)%5D//
@@ -1327,32 +1327,33 @@
 'Project'%5D) %3E 0)
+)
 %5D//following-sib
@@ -1600,60 +1600,56 @@
 el%5B(
-.='LabelText'
+contains(.,'File Name')
  or co
-u
 nt
-(*//text()%5B.='LabelText'%5D) %3E 0
+ains(.,'Project')
 )%5D//

add DisplayFieldTest.java