1

I am creating the test cases for my learning using Selenium C# in Orange Hrm application. https://enterprise-demo.orangehrmlive.com/auth/login Username and password: admin.

Once I login, there are differen menu, I am traversing through Admin>User Management>users and click on Users. However, I am not getting way to how to use the MouseOver in Selenium C#. Attached is the screenshot for your reference.enter image description here

2 Answers 2

1

From my limited knowledge you'll have to do it in a few steps. Below is an example using NgWebDriver (angularJS app)

            Actions builder = new Actions(ngDriver);
            var elementToHover= ngDriver.FindElement(By.ClassName("dpcontract"));
            builder.MoveToElement(elementToHover, 10 , 0)
            builder.Build().Perform();

This builds a new action by finding the target element, moving the mouse to its position (x/y) with a 10 offset on the x (in my case).

You can add more events to that action trigger. The original (working) code for a drag and drop type-action i have is this

            Actions builder = new Actions(ngDriver);
            var elementToClick = ngDriver.FindElement(By.ClassName("dpcontract"));

            builder.MoveToElement(elementToClick, elementToClick.Size.Width - 1, 0)
            .ClickAndHold()
            .MoveByOffset(150, 0)
            .Release();

            builder.Build().Perform();
Sign up to request clarification or add additional context in comments.

1 Comment

You are certainly right, however I am not using the ngdriver. Based on your suggestions, I have modified and wrote which worked.
0

Thank you Jens Stragier for your suggestion. Based on your suggestion, I wrote as follows and it worked for me.

            Actions action = new Actions(Driver);
            action.MoveToElement(elemWomen);
            Thread.Sleep(500);
            action.ClickAndHold(elemWomen);
            action.Release(TShirt);
           action.Click(TShirt);
            action.Perform();

1 Comment

If you are performing ClickAndHold in Chrome, you may have to add a MoveByOffset(1,1) as a workaround.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.