package com.extjs.selenium.form;

import com.extjs.selenium.ExtJsComponent;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

public class LabelTest {
    public static ExtJsComponent container = new ExtJsComponent("container");

    @DataProvider
    public static Object[][] testConstructorPathDataProvider() {
        return new Object[][]{
                {new Label("LabelText"),            "//label[contains(text(),'LabelText')]"},
                {new Label(container),              "//*[contains(concat(' ', @class, ' '), ' container ')]//label"},
                {new Label(container, "LabelText"), "//*[contains(concat(' ', @class, ' '), ' container ')]//label[contains(text(),'LabelText')]"},
        };
    }

    @Test(dataProvider = "testConstructorPathDataProvider")
    public void getPathSelectorCorrectlyFromConstructors(Label label, String expectedXpath) {
        Assert.assertEquals(label.getPath(), expectedXpath);
    }
}

@@ -25,17 +25,19 @@
 um.form;
-%0A
+%0D%0A%0D
 %0Aimport 
@@ -70,16 +70,58 @@
 mponent;
+%0D%0Aimport com.sdl.selenium.web.SearchType;%0D
 %0Aimport 
@@ -138,16 +138,17 @@
 .Assert;
+%0D
 %0Aimport 
@@ -183,16 +183,17 @@
 rovider;
+%0D
 %0Aimport 
@@ -220,17 +220,19 @@
 ns.Test;
-%0A
+%0D%0A%0D
 %0Apublic 
@@ -248,16 +248,17 @@
 elTest %7B
+%0D
 %0A    pub
@@ -327,17 +327,19 @@
 ainer%22);
-%0A
+%0D%0A%0D
 %0A    @Da
@@ -348,16 +348,17 @@
 Provider
+%0D
 %0A    pub
@@ -414,16 +414,17 @@
 ider() %7B
+%0D
 %0A       
@@ -446,16 +446,17 @@
 ect%5B%5D%5B%5D%7B
+%0D
 %0A       
@@ -533,32 +533,33 @@
 'LabelText')%5D%22%7D,
+%0D
 %0A               
@@ -660,16 +660,843 @@
 label%22%7D,
+%0D%0A                %7Bnew Label(container).setLabel(%22Label%22, SearchType.CONTAINS), %22//*%5Bcontains(concat(' ', @class, ' '), ' container ')%5D//label%5Bcontains(text(),'Label')%5D//following-sibling::*//label%22%7D,%0D%0A                %7Bnew Label(container).setLabel(%22Label%22, SearchType.CONTAINS, SearchType.HTML_NODE), %22//*%5Bcontains(concat(' ', @class, ' '), ' container ')%5D//label%5B(normalize-space(concat(./*%5B1%5D//text(), ' ', text()%5B1%5D, ' ', ./*%5B2%5D//text(), ' ', text()%5B2%5D, ' ', ./*%5B3%5D//text(), ' ', text()%5B3%5D, ' ', ./*%5B4%5D//text(), ' ', text()%5B4%5D, ' ', ./*%5B5%5D//text(), ' ', text()%5B5%5D))='Label' or normalize-space(concat(text()%5B1%5D, ' ', ./*%5B1%5D//text(), ' ', text()%5B2%5D, ' ', ./*%5B2%5D//text(), ' ', text()%5B3%5D, ' ', ./*%5B3%5D//text(), ' ', text()%5B4%5D, ' ', ./*%5B4%5D//text(), ' ', text()%5B5%5D, ' ', ./*%5B5%5D//text()))='Label')%5D//following-sibling::*//label%22%7D,%0D
 %0A       
@@ -1635,16 +1635,17 @@
 xt')%5D%22%7D,
+%0D
 %0A       
@@ -1647,23 +1647,26 @@
       %7D;
+%0D
 %0A    %7D
-%0A
+%0D%0A%0D
 %0A    @Te
@@ -1717,16 +1717,17 @@
 ovider%22)
+%0D
 %0A    pub
@@ -1812,16 +1812,17 @@
 Xpath) %7B
+%0D
 %0A       
@@ -1878,13 +1878,16 @@
 th);
+%0D
 %0A    %7D
+%0D
 %0A%7D
+%0D
 %0A

add more tests LabelTest