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
public class WebDriverSupplier { | |
private static final Supplier<WebDriver> FIREFOX_SUPPLIER = new Supplier<WebDriver>() { | |
private WebDriver firefoxDriver; | |
@Override | |
public WebDriver get() { | |
if (firefoxDriver == null) { | |
firefoxDriver = new FirefoxDriver(); | |
} |
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
@Test | |
public void runSomeIntegrationTest() { | |
WebDriver driver = new FirefoxDriver() | |
Selenium selenium = new WebDriverBackedSelenium(driver, SharedConfiguration.BASE_URL); | |
selenium.open("page.html"); | |
// wait until the table row has been loaded | |
SeleniumUtils.waitForElementPresent(selenium, "xpath=//tr[@id='task-TASK_001']"); | |
// navigate to the associated details page | |
SeleniumUtils.clickElement(driver, By.linkText("1001")); | |
// the browser now opens the details.html page |
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
public class WebDriverSupplier { | |
private static final Supplier<WebDriver> FIREFOX_SUPPLIER = new Supplier<WebDriver>() { | |
@Override | |
public WebDriver get() { | |
return new FirefoxDriver(); | |
} | |
}; | |
private static final Supplier<WebDriver> INTERNET_EXPLORER_SUPPLIER = new Supplier<WebDriver>() { |
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
@Test | |
public void runSomeIntegrationTest() { | |
for (Supplier<WebDriver> supplier : WebDriverSupplier.getWebDrivers()) { | |
WebDriver driver = supplier.get(); | |
Selenium selenium = new WebDriverBackedSelenium(driver, SharedConfiguration.BASE_URL); | |
selenium.open("page.html"); | |
SeleniumUtils.waitForElementPresent(selenium, "xpath=//tr[@id='task-TASK_001']"); | |
SeleniumUtils.clickElement(driver, By.linkText("1001")); | |
SeleniumUtils.waitForElementPresent(selenium, "xpath=//tr[@id='wo-1001']"); | |
assertEquals("CANCELLED", selenium.getText("xpath=//tr[@id='wo-1001']/td[3]")); |
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
if (System.getProperty("os.name").startsWith("Windows")) | |
suppliers.add(INTERNET_EXPLORER_SUPPLIER) | |
} |
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
public static void clickElement(WebDriver driver, By condition) { | |
WebElement sbutton = driver.findElement(condition); | |
sbutton.sendKeys("\n"); | |
try { | |
sbutton = driver.findElement(condition); | |
sbutton.click(); | |
} catch (NoSuchElementException e) {} | |
} |
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
(function($) { | |
var app = $.sammy('#main', function() { | |
this.get('#/', function(context) { | |
alert('index!'); | |
}); | |
}); | |
$(function() { | |
app.run('#/'); | |
}); |
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
this.get('#/', function(context) { | |
this.load('thread') | |
.then( function(threads) { | |
$.each(threads, function(i, thread) { | |
context.render('templates/thread.template', {thread : thread}).appendTo(context.$element()); | |
}); | |
}); | |
}); |
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
<pre> | |
<div class="thread"> | |
<div class="thread-title"> | |
<a href="#/thread/<%= thread.title %>"><%= thread.title %></a> | |
</div> | |
<time><%= thread.postdate %></time> | |
<div class="thread-author"><%= thread.author %></div> | |
</div> | |
</pre> |
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
this.post('#/thread', function(context) { | |
$.post('thread', this.params); | |
this.redirect('#/thread/' + this.params.title); | |
}); |
OlderNewer