improveyourautomatedwebapplicationtesting内容摘要:

WebElement countryElement = ((GWT_DEBUG + ))。 (Does not exist)。 WebElement loadCitiesButton = ((GWT_DEBUG + ))。 ()。 WebDriverWait wait = new WebDriverWait(driver, 5000)。 (((GWT_DEBUG + )))。 WebElement noCitiesElement = ((GWT_DEBUG + ))。 assertTrue(())。 WebElement cityRowElement = ((GWT_DEBUG + ))。 assertFalse(())。 } Now It Looks Like… @Test public void testUnknownCountryName() { setText(, Does not exist)。 click()。 WebDriverWait wait = createDefaultWait()。 (())。 assertIsDisplayed()。 assertIsNotDisplayed()。 } Much Better!!! Any More Problems? • Today you select a country by: – Typing a country name. – Clicking the “Load Cities” button. • What if we change it to: – Select the country from a dropdown list. • Our tests all break! Tip 3: Use Page Objects • Create higherlevel action abstractions on a perpage basis. • Write tests that use those abstractions. • Then, if the underlying UI changes, we can update a single Page Object instead of many individual tests. Page Object Design Considerations • Put your Locator definitions there. • Give it access to your WebDriver API helpers. • Put your pagespecific action and (more optionally) assertion methods there. Page Object Example public class WeatherHomePageObject { public static interface WeatherHomeLocators { public static final String GWT_DEBUG = gwtdebug。 By countryName = (GWT_DEBUG + )。 By loadCities = (GWT_DEBUG + )。 // etc. } private WebDriverWrapper driverWrapper。 public WeatherHomePageObject(WebDriverWrapper driverWrapper) { = driverWrapper。 } public void loadCitiesForCountry(String countryName) { (, Does not exist)。 ()。 } public void assertCitiesNotLoadedDisplay() { ()。 ()。 } } Now It Looks Like… @Test public void testUnknownCountryName() { (Does not exist)。 WebDriverWait wait = createDefaultWait()。 (( ))。 ()。 } This change is subtle…but important! It makes your tests maintainable and robust to change in the UI! We are pretty happy, but… That Seems Like a Lot of Work! • It is! Selenium WebDriver tests are: – Timeconsuming to develop. – Somewhat susceptible to being “flaky” (example: use of “wait”s). – Highly susceptible to breaking when the UI changes. – Sometimes hard to maintain. • Consequently, we often focus more on unit testing, less on endtoend tests. • Usually this is pretty successful, but can we do better? Big Idea What if we could generate and regenerate interesting tests automatically, and find bugs in the process? WebTestingExplorer • Supports Automated Exploratory Testing. – Automated: Easy to replay (and regenerate) interesting test cases. – Exploratory: Systematically discovers new application states. – Testing: Includes test case generation, oracle generation, realtime bug detection, and test case replay. Advantages • Efficiently test through the user interface. • Test like a real user. • Don39。 t miss integration issues and things that are hard to observe. – Behind the scenes in the browser. – Or on other application tiers. WebTestingExplorer Design • Assumes a testable application. – Example: We can ask developers to add id。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。