-1

I am looking for a way to test mouse wheel events in Robot framework using the Browser library. I was looking in the documentation but couldn't find any way.

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
  • Please provide enough code so others can better understand or reproduce the problem. – Community Oct 27 '21 at 07:15
  • 2
    It is fine to answer your own question and it's also fine to post a self-answered question. But please [edit] this into an ***actual question*** that fits our Q&A model. Read about [ask] and fix your question accordingly – Tomerikoo Oct 27 '21 at 18:40
  • Sure Tomerikoo, I just wanted to share a solution I'm new to all this. But looking at the negative points I'm demotivated. It's hard to find the solution to the above question. I wanted to share this with the community. But I'm discouraged in the beginning. – SANDESH TH Oct 28 '21 at 06:07
  • So don't be. Simply follow the guidelines. Currently your "question" seems like part of the answer. Simply [edit] it to resemble an actual question that someone else might be looking for – Tomerikoo Oct 28 '21 at 06:11
  • Sure Will do it When I find Time. – SANDESH TH Oct 28 '21 at 06:41

1 Answers1

1

I have the below approach of using JavaScript to test/run mouse events. There might be other ways to achieve mouse wheels events using Selenium or other methods. There is no straightforward method to test mouse wheel events in Robot Framework using Browser Library. Here is a solution which I got after Researching:

Emit Mouse Wheel Events
    [Documentation] Takes some parameter and emits the wheel event to 
    simulate mouse event
    [Arguments] ${CtrlKey} ${ShiftKey} ${deltaY}
    ${ElementToApplyMouseEvents} = Get Element //valid-selector
    Log ${ElementToApplyMouseEvents}
    Execute Javascript (elem) => { let event = new WheelEvent(“wheel”, {deltaX: 
    -400,deltaY: 
     ${deltaY},view: window,bubbles:true,ctrlKey: ${CtrlKey}, shiftKey: ${ShiftKey}}); 
     elem.dispatchEvent(event); } ${ElementToApplyMouseEvents}
     Sleep 1s
    Take Screenshot EMBED fullPage=true
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
  • This is a solution Maybe u can try once, In Robot framework using Browser library It is not straight forward to test mouse wheel events. After Reasearching I have found this working method – SANDESH TH Oct 27 '21 at 07:52