selenium icon indicating copy to clipboard operation
selenium copied to clipboard

Object reference not set to an instance of an object. at OpenQA.Selenium.Interactions.Actions.Perform()

Open Festivejelly opened this issue 9 years ago • 7 comments

Meta -

OS:
Windows 10 Selenium Version:
3.6 Browser:
Chrome

Browser Version:
Version 62.0.3202.75 (Official Build) (64-bit)

Expected Behavior -

When performing an Action i'd expect it to work

Actual Behavior -

Throws an error:System.NullReferenceException : Object reference not set to an instance of an object. at OpenQA.Selenium.Interactions.Actions.Perform() when .Perform is called

Steps to reproduce -

Using C# bindings create a simple test

        var actions = new Actions(browser);
        actions.MoveToElement(element).Build();
        actions.Perform();

Notes -

I can get this to work with 3.6 at all.

Festivejelly avatar Nov 02 '17 11:11 Festivejelly

You have built sequence and than called method Perform() which builds sequence again.

Try to build sequence of actions on this way:

Actions actions = new Actions(browser);
actions.MoveToElement(element);
Action moveToElement = actions.Build();
moveToElement.Perform();

Besides that I recommend you to read this wiki.

matijalucman avatar Nov 02 '17 13:11 matijalucman

Thats odd it works fine on 3.0.1 i'll try your suggestion.

Festivejelly avatar Nov 02 '17 15:11 Festivejelly

the above you quoted wont compile

Festivejelly avatar Nov 02 '17 15:11 Festivejelly

btw im using C#

Festivejelly avatar Nov 02 '17 15:11 Festivejelly

You are right, I made a mistake because I was not able to test the code, this should work:

Actions actions = new Actions(driver);
actions.MoveToElement(element);
IAction moveToElement = actions.Build();
moveToElement.Perform();

I have also tested your code and I can not reproduce the error.

matijalucman avatar Nov 02 '17 19:11 matijalucman

For issues please provide a concise reproducible test case and describe what results you are seeing and what results you expect.

See CONTRIBUTING.md

barancev avatar Nov 08 '17 14:11 barancev

Closing the issue, there is no reproduction scenario provided.

barancev avatar Dec 02 '17 20:12 barancev