Take screenshots

Screenshot of page <code lang="java"> public void takeScreenshot() throws IOException { File scrFile = ((TakesScreenshot) driver) .getScreenshotAs(OutputType.FILE); String fileName = UUID.randomUUID().toString(); File targetFile = new File("target/screenshots/" + fileName + ".jpg"); FileUtils.copyFile(scrFile, targetFile); } </code> Screenshot […]

Interact with WebElements

Interact with a button <code lang="java"> package book.chapter05; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import book.chapter09.tests.DriverBase; public class InteractWithButton extends DriverBase { @BeforeMethod public void setUp() { driver.get("http://techblog.polteq.com/testshop/"); } @Test public void interactButton() […]

Finding WebElements

We have the option to find a single WebElements or create a list of multiple elements. Find a single WebElement <code lang="java"> package book.chapter05; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import book.chapter09.tests.DriverBase; public […]

Using WebDriver

Every supported browser has its own driver class implementation. This section provides examples on how to use those different browsers. In practice Firefox FirefoxDriver is part of WebDriver itself. public void startFirefoxBrowser() { WebDriver driver […]

Interact with the Browser – Introduction

This chapter reveals the Selenium WebDriver API. It will provide working examples of the most frequently used Selenium WebDriver functionality. Further references Selenium JavaDoc: http://selenium.googlecode.com/git/docs/api/java/index.html