Created
November 24, 2015 19:14
-
-
Save asolntsev/eabf9c8cf3108142ec17 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.codeborne.selenide.Configuration; | |
import org.junit.Before; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.junit.runners.Parameterized; | |
import org.openqa.selenium.By; | |
import java.util.Arrays; | |
import java.util.List; | |
import static com.codeborne.selenide.Condition.hidden; | |
import static com.codeborne.selenide.Condition.text; | |
import static com.codeborne.selenide.Selenide.$; | |
import static com.codeborne.selenide.Selenide.open; | |
import static com.codeborne.selenide.WebDriverRunner.closeWebDriver; | |
@RunWith(Parameterized.class) | |
public class TwitterTypeahead { | |
@Parameterized.Parameters | |
public static List<Object[]> browsers() { | |
return Arrays.asList(new Object[]{"firefox"}, new String[]{"chrome"}, new String[]{"phantomjs"}, new String[]{"htmlunit"}); | |
} | |
public TwitterTypeahead(String browser) { | |
if (!Configuration.browser.equals(browser)) { | |
closeWebDriver(); | |
Configuration.browser = browser; | |
} | |
} | |
@Before | |
public void setUp() { | |
Configuration.fastSetValue = false; | |
open("https://twitter.github.io/typeahead.js/examples/"); | |
$(".tt-suggestion.tt-selectable").shouldBe(hidden); | |
} | |
@Test | |
public void setValue() { | |
$(By.xpath("//span[@class='twitter-typeahead']/input[2]")).setValue("Alab"); | |
$(".tt-suggestion.tt-selectable").shouldHave(text("Alabama")); | |
} | |
@Test | |
public void fastSetValue() { | |
Configuration.fastSetValue = true; | |
$(By.xpath("//span[@class='twitter-typeahead']/input[2]")).setValue("Alab"); | |
$(".tt-suggestion.tt-selectable").shouldHave(text("Alabama")); | |
} | |
@Test | |
public void sendKeys() { | |
$(By.xpath("//span[@class='twitter-typeahead']/input[2]")).sendKeys("Alaba"); | |
$(".tt-suggestion.tt-selectable").shouldHave(text("Alabama")); | |
} | |
@Test | |
public void sendKeysForWrapperElement() { | |
$(By.xpath("//span[@class='twitter-typeahead']/input[2]")).getWrappedElement().sendKeys("Alabam"); | |
$(".tt-suggestion.tt-selectable").shouldHave(text("Alabama")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment