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?
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)
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 });
// 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);
@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.