public class GalenPageActionRunJavascriptTest {
private static final String TEST_URL = "file://" + GalenPageActionCheckTest.class.getResource("/html/page-for-js-check.html").getPath();
@Test public void shouldRun_javascriptFile_andPerformActions_onBrowser() throws Exception {
WebDriver driver = new FirefoxDriver();
Browser browser = new SeleniumBrowser(driver);
browser.load(TEST_URL);
WebElement element = driver.findElement(By.id("search-query"));
assertThat("Search input should not contain any text yet", element.getAttribute("value"), is(""));
GalenPageActionRunJavascript action = new GalenPageActionRunJavascript(getClass().getResource("/scripts/to-run-1.js").getFile());
action.setJsonArguments("{prefix: 'This was'}");
action.execute(new TestReport(), browser, new GalenPageTest(), null);
assertThat("Search input should contain text", element.getAttribute("value"), is("This was typed by a selenium from javascript text from imported script"));
browser.quit();
}