java - Selenium WebDriver -- How can I know a certain line has executed successfully? -
i testing web application , sample test case has 3 steps:
- enter username
- enter password
click 'login'
driver.findelement(by.id("username")).sendkeys(username); driver.findelement(by.id("password")).sendkeys(password); driver.findelement(by.id("loginbutton")).click();
i need generate report specifies steps passed , failed. there mechanism can know each of lines executed successfully? selenium have kind of inbuilt activity/event listener?
if want log basic steps click, navigate, on find element, etc
i recommend add event listener. can use class eventfiringwebdriver.
an example:
eventfiringwebdriver events = new eventfiringwebdriver(this._driver); events.navigated += new eventhandler<webdrivernavigationeventargs>(eventafternavigate);
and can define event handler as
private void eventafternavigate(object sender, webdrivernavigationeventargs e) { log("url visited: " + e.driver.url); // call favourite log method }
you can find more possible event handlers in webdriver api reference: http://selenium.googlecode.com/svn/trunk/docs/api/dotnet/html/allmembers_t_openqa_selenium_support_events_eventfiringwebdriver.htm
Comments
Post a Comment