Ashok Reddy

Ashok Reddy

  • NA
  • 11
  • 6.9k

How to fix System.Reflection.TargetInvocationException

Nov 24 2017 9:31 AM
I am Developing POM with Page Factory in Selenium automation Script with C#. but, when I am trying to click on same Element second Time, I am getting Exception like: "System.Reflection.TargetInvocationException","OpenQA.Selenium.StaleElementReferenceException". Plese, tell me how to fix that.
  1. MyAccountHeadCarotMaster.Click();  
  2.        MyReports.Click();  
  3.        MyJob1.Click();  
  4.        Thread.Sleep(4000);  
  5.        MyAccountHeadCarotMaster.Click();  
  6.        Reports.Click();  
  7.        MyJob2.Click();  
  8.        Thread.Sleep(4000);  
  9.        MyAccountHeadCarotMaster.Click();  
  10.        Reports.Click();  
  11.        MyJob3.Click();  
  12.        Thread.Sleep(4000);  
  13.        MyAccountHeadCarotMaster.Click();  
  14.        Reports.Click();  
  15.        MyJob4.Click();  
  16.        Thread.Sleep(4000);  
  17.        MyAccountHeadCarotMaster.Click();  
  18.        Reports.Click();  
  19.        MyJob5.Click();  
  20.        Thread.Sleep(4000);  
  21.        MyAccountHeadCarotMaster.Click();  
  22.        Reports.Click();  
  23.        MyJob6.Click();  
  24.        Thread.Sleep(4000);  

Answers (1)