package com.codeborne.selenide.impl;

import com.codeborne.selenide.SelenideElement;
import org.junit.Test;
import org.openqa.selenium.By;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class ElementFinderTest {
  @Test
  public void testToString() {
    SelenideElement parent = mock(SelenideElement.class);
    when(parent.toString()).thenReturn("table");
    when(parent.getTagName()).thenReturn("table");

    assertEquals("{By.id: app}", new ElementFinder(null, By.id("app"), 0).toString());
    assertEquals("{By.id: app[3]}", new ElementFinder(null, By.id("app"), 3).toString());
    assertEquals("{By.id: app}", new ElementFinder(parent, By.id("app"), 0).toString());
    assertEquals("{By.id: app[3]}", new ElementFinder(parent, By.id("app"), 3).toString());
  }
}

@@ -326,16 +326,39 @@
 ToString
+ForFinderByCssSelectors
 () %7B%0A   
@@ -874,11 +874,709 @@
 ());%0A  %7D
+%0A%0A  @Test%0A  public void testToStringForFinderByXpathExpration() %7B%0A    SelenideElement parent = mock(SelenideElement.class);%0A    when(parent.toString()).thenReturn(%22table%22);%0A    when(parent.getTagName()).thenReturn(%22table%22);%0A%0A    assertEquals(%22%7BBy.xpath: //*%5B@id='app'%5D%7D%22, new ElementFinder(null, By.xpath(%22//*%5B@id='app'%5D%22), 0).toString());%0A    assertEquals(%22%7BBy.xpath: //*%5B@id='app'%5D%5B3%5D%7D%22, new ElementFinder(null, By.xpath(%22//*%5B@id='app'%5D%22), 3).toString());%0A    assertEquals(%22%7BBy.xpath: //*%5B@id='app'%5D%7D%22, new ElementFinder(parent, By.xpath(%22//*%5B@id='app'%5D%22), 0).toString());%0A    assertEquals(%22%7BBy.xpath: //*%5B@id='app'%5D%5B3%5D%7D%22, new ElementFinder(parent, By.xpath(%22//*%5B@id='app'%5D%22), 3).toString());%0A  %7D
 %0A%7D%0A

add new test for ElementFinder class with By.xpath search