How to simulate hover activity?

Hi all,

I am making background automation and the problem here is that UiPath is not allowing me to hover in the background. Like if we click simulate hover. It does not work. Is there any way to deal with this problem or any other workaround that anyone can suggest?

Hi,

InjectJS activity with the following code may help you if the event is implemented by JaveScript.

"function(e,v){
    var evt = new Event('mouseover');
    e.dispatchEvent(evt);
}"

Regards,

Website url ends with aspx. So ig it is asp.net

@Yoichi

Hi,

It depends client side technology such as JavaScript or CSS etc, if the above works or not.
For now can you try the above?

Regards,

Lemme try. A bit confused here. How will it know where to hover?
@Yoichi

Hi,

InjectJS script activity can indicate an element on the web page, as the following. And information of the element is passed into script code (e is the element in the above code)

image

Regards,

@Yoichi i tried its not working. Any other way around?

Hi @Umer_Shahid,

use activity invoke code with below code.

string javaScriptCode = @"
    var element = document.querySelector('your_selector'); // Replace 'your_selector' with the CSS selector of the element you want to hover over
    var event = new MouseEvent('mouseover', {
        bubbles: true,
        cancelable: true,
        view: window
    });
    element.dispatchEvent(event);
";

// Execute JavaScript code
System.Windows.Forms.HtmlDocument document = (System.Windows.Forms.HtmlDocument)WebBrowser.Document;
document.InvokeScript("eval", new object[] { javaScriptCode });

@ABHIMANYU_THITE1 tried it. But invoke code activity expects to be passed as vb script or c#. That is why it is throwing error

@Umer_Shahid try

// Inject JavaScript code to trigger hover effect on the target element
string javaScriptCode = @"
    // Find the target element by its CSS selector
    var element = document.querySelector('your_selector'); // Replace 'your_selector' with the CSS selector of the element you want to hover over

    // Create a new MouseEvent for the hover event
    var event = new MouseEvent('mouseover', {
        bubbles: true,
        cancelable: true,
        view: window
    });

    // Dispatch the hover event to the target element
    element.dispatchEvent(event);
";

// Execute the JavaScript code
var browser = new UiPath.Core.Browser("browser_variable_name"); // Replace 'browser_variable_name' with the variable name of your browser instance
browser.InvokeScript(javaScriptCode);


This error is coming

@Umer_Shahid - try delcare variable like UiPath.Core.Browser browser = ... rather than var.

@Umer_Shahid -
try to change the name of the variable.
OR Check if this variable is already declared or not.

Its declared and tried changing the variable. Still throwing error.

can you show the workflow and code written in invoke code?

New folder.zip (107.2 KB)
Here is the xaml file. Please help. I am trapped here : (

we assume a webpage / webapplication is involved

which browser is used? Was the Chromium API as input method checked?

Maybe we can handle it more directly eg. element / attribute / value retrievals.

what is the aim of the hover? Can you elaborate more on the your case including some screenshots? Thanks

@Umer_Shahid - I think that is not going to work!

Use inject JS as above mentioned. OR as @ppr ask explain aim of the hover might find different alternative.

@ppr I have attached the workflow above. Actually the UI I am dealing with. I need to hover over specific fields so that options can be available to me.