### Question:
FluentBy extends By { public static ByAttribute attribute(final String name) { return attribute(name, null); }  void beforeFindElement(WebDriver driver); static ByStrictClassName strictClassName(final String className); static ByAttribute attribute(final String name); static ByAttribute attribute(final String name, final String value); static ByAttribute notAttribute(final String name); static ByComposite composite(By.ByTagName b0, By.ByClassName b1); static ByComposite composite(By.ByTagName b0, FluentBy.ByAttribute b1); static ByLast last(By by); static ByLast last();  }### Answer:
@Test public void attribute() throws IllegalAccessException { By fooBar = FluentBy.attribute("foo", "bar"); assertThat(fooBar.toString(), is("FluentBy.attribute: foo = 'bar'")); FindsByXPathSearchContext context = mock(FindsByXPathSearchContext.class); WebElement we = mock(WebElement.class); when(context.findElementByXPath(". WebElement bar = fooBar.findElement(context); assertThat(bar, is(we)); By lastFooBar = FluentBy.last(fooBar); assertThat(lastFooBar.toString(), is("FluentBy.last(FluentBy.attribute: foo = 'bar')")); when(context.findElementByXPath(". WebElement lastBar = fooBar.findElement(context); assertThat(lastBar, is(we)); }
@Test public void attribute_without_value() throws IllegalAccessException { By fooBar = FluentBy.attribute("foo"); assertThat(fooBar.toString(), is("FluentBy.attribute: foo")); FindsByXPathSearchContext context = mock(FindsByXPathSearchContext.class); WebElement we = mock(WebElement.class); WebElement we2 = mock(WebElement.class); when(context.findElementByXPath(". WebElement bar = fooBar.findElement(context); assertThat(bar, is(we)); when(context.findElementsByXPath(". List<WebElement> bars = fooBar.findElements(context); assertThat(bars.get(0), is(we)); }