2

I am using Selenium.WebDriver and Selenium.Support 3.0.1 in my tests, but after update to higher version my code throws error.

Failing code:

// Element locating        
// [FindsBy(How = How.ClassName, Using = "dot")]
// private IList<IWebElement> gameDots { get; set; }        

for (int i = 0; i < levelIndicators.Count; i++)
{
    Browser.Action.ClickAndHold(gameDots[0]);
    foreach (IWebElement gameDot in gameDots)
    {
       Browser.Action.MoveToElement(gameDot);
    }
    Browser.Action.MoveToElement(gameDots[0])
       .Build()
       .Perform();
}

Browser class:

public static Actions Action { get; set; }
public static IWebDriver Driver { get; set; }

static Browser()
{
   Action = new Actions(Driver);  
}

After update to any newer version of Selenium I am getting StaleElementReferenceException on the line with Perform() method. After downgrade to 3.0.1 it's working again.

OpenQA.Selenium.StaleElementReferenceException : stale element reference: element is not attached to the page document (Session info: chrome=58.0.3029.110) (Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 10.0.15063 x86_64)

If i try to interact with gameDot[0] element without doing any Actions everything is working as intended.

nEkis
  • 320
  • 1
  • 14

1 Answers1

0

Have the same problem. First click works fine, second click (no dom change!) throws exception! replace action.clikc(clikckingElement).build.perform with clickingElement.Click() helps. But it's a bug for sure!

All was fine with crhome v. 59, but selenium 3.0.1 instead of latest 3.4

Artem A
  • 2,154
  • 2
  • 23
  • 30
  • I found out that i am using static Actions and it repeats all previously performed actions as well. So now I create instance of Actions in each extension method I am using it in. This removed some of mine problems, but not all. – nEkis Oct 26 '17 at 12:49
  • I also recreate an element each time I plan to use \click it. – Artem A Jan 30 '18 at 16:28
  • Not element, but instance of `Actions` object. – nEkis Feb 05 '18 at 15:15