2. 2
O čem bude řeč?
Testování UI webové aplikace
End to End testy
Funkční / akceptační testy
Náhrada ručních testů - automatizace
3. 3
Co je Selenium Webdriver
Webdriver
W3C specifikace protokolu pro vzdálené ovládání
prohlížeče - http://www.w3.org/TR/webdriver/
Selenium Webdriver 2.0
Nástupce Selenium RC
Poskytuje API pro webdriver
Java
JavaScript
Python
Ruby
C#
…
22. 22
Problémy
Stabilita
Kontrola předpokladů – fail fast
DOM – StaleElementException
Postranní info
Příprava prostředí
Testovací data
Paralelizace
Implementace WebDriver
Rozdíly mezi prohlížeči
Někdy nutné dělat ošklivé věci
Svádí ke zneužití
WebDriver driver = new HtmlUnitDriver();
WebDriver driver = new ChromeDriver();
WebDriver driver = new InternetExplorerDriver();
WebDriver driver = new FirefoxDriver();
// And now use this to visit Google
driver.get("http://www.google.com");
// Find the text input element by its name
WebElement element = driver.findElement(By.name("q"));
// Enter something to search for
element.sendKeys("Cheese!");
// Now submit the form. WebDriver will find the form for us from the element
element.submit();
// Check the title of the page
System.out.println("Page title is: " + driver.getTitle());
driver.quit();
public WebElement waitUntilElementIsVisible(final By elementSpecifiedBy, final SearchContext ctx) { new WebDriverWait(driver,timeout) .ignoring(StaleElementReferenceException.class) .until( new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return ctx.findElement(elementSpecifiedBy).isDisplayed(); } } ); return ctx.findElement(elementSpecifiedBy);}
PageObject nutné rozšířit na komponenty, strom je komponenta, wysiwyg je komponenta, toolbar je komponenta ….