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 HomePageITest { | |
@Test | |
public we_should_be_able_to_search_from_the_homepage() { | |
pageFactory.getHomePage() | |
.get() | |
.doSomethingOnTheHomePage() | |
.clickSearchWidgetSubmitButton() | |
.doSomethingElseOnTheHomePage() | |
; | |
} |
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
var SearchWidget = require('./widgets/SearchWidget'); | |
var Page = require('./Page'); | |
module.exports = function HomePage() { | |
Page.call(this); | |
SearchWidget.call(this); | |
this.doSomethingOnTheHomePage = function() { | |
// do something | |
return this; |
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
module.exports = function SearchWidget() { | |
var SEARCH_WIDGET_SUBMIT_BUTTON_SELECTOR = '#searchWidgetSubmitButtonSelector'; | |
this.clickSearchWidgetButton = function() { | |
this.driver.findElement(By.id(SEARCH_WIDGET_SUBMIT_BUTTON_SELECTOR)).click(); | |
return this; | |
}; | |
}; |
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
module.exports = function Page(driver, endpoint) { | |
this.driver = driver; | |
this.get = function() { | |
driver.get(endpoint + this.getPagePath()); | |
return this; | |
}; | |
}; |
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
describe('the home page', function() { | |
it('should allow users to search', function() { | |
pageFactory.getHomePage() | |
.get() | |
.doSomethingOnTheHomePage() | |
.clickSearchWidgetSubmitButton() | |
.doSomethingElseOnTheHomePage() | |
; | |
}); | |
}); |
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
package my.project; | |
import org.testng.annotations.Test; | |
import com.github.jsdevel.testng.selenium.AbstractSuite; | |
public class SampleSuiteITest extends AbstractSuite<MyPageFactory> { | |
@Test | |
public void we_should_be_able_to_view_the_home_page() { | |
getPageFactory().getHomePage(); |
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
<dependency> | |
<groupId>com.github.jsdevel</groupId> | |
<artifactId>testng-selenium</artifactId> | |
<!-- Change this to the version you wish to use. --> | |
<version>RELEASE</version> | |
</dependency> |
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
package my.project; | |
import com.github.jsdevel.testng.selenium.PageFactory; | |
public interface MyPageFactory extends PageFactory { | |
MyHomePage getHomePage(); | |
MyHomePage getHomePage(String path); | |
} |
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
package com.github.jsdevel.testng.selenium.samples; | |
import com.github.jsdevel.testng.selenium.AbstractPage; | |
import java.net.URL; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.support.FindBy; | |
public class GoogleHomePage extends AbstractPage<GoogleHomePage, SamplePageFactory> { | |
@FindBy(css = "[name=q]") | |
public WebElement q; |
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 @UserAgent("some new user agent") | |
public void verify_that_we_can_override_a_user_agent() { | |
// hooray! | |
} |