I am getting Stale reference exception(Element no longer valid), I am using c# - Webdriver for automation.
I am using Selenium for automation framework. In that I have used EventFiringWebDriver class of Selenium Event. that listens to every event of InterenetExplorerWebdriver (Like Click() or SendKeys()). In the events of the EventFiringWebDriver class like (ElementClicked,ElementValueChanged) I have implemented the logic that logs the WebElementEventArgs object s attributes to XML based log file. so at the end of the execution I can see the details of the execution of each test case in XSLT format and track functional errors.
code:-
public class SeleniumEventListener : EventFiringWebDriver
{
public SeleniumEventListener(IWebDriver webDriver):base(webDriver)
{
ElementClicked += new EventHandler<WebElementEventArgs>SeleniumEventListener_ElementClicked);
//more events handled here..
iii
void SeleniumEventListener_ElementValueChanged(object sender,WebElementEventArgs e)
{
LogPassedStep(e)
iii
private LogPassedStep(e)
{
string title = e.Element.value;
string status = "clicked"
//XML based logging here.
iii
iii
In my application which I automate using selenium. I have some text boxes and Buttons, The EventFiringWebDriver class XMLLogging works correctly for the textboxes through out the test case execution But for the Buttons Or Links some of the times it Gives the "Element no longer valid" Stale reference exception(The some buttons are of the type Expand collapse which causes DOM to change, and In my application I have a Task page which refreshes at regular interval in that the Stale reference exception comes often)
The Webdriver clicks works correctly throughout the execution but the EventFiringWebDriver fails to recognize the object and Stale reference exception comes
Please help me.. or please suggest me the way to get that details of the webpage objects (like button,link) so that I can implement the Logging functionality(I am using C#-webdriver)/