This is related to my previous post about isolating buttons on the web page.
I have a DIV that’s set to hidden, and is made visible when a corresponding button is clicked. I’m having trouble getting the bot to click the correct “make it visible” button because there are multiple on the page and they’re not in any way unique within the HTML code.
Is it possible to send a click to a link within the hidden DIV without first clicking the button that makes it visible?
You can make use of the Inject JS activity. Here’s an example that clicks on the Search element (https://www.uipath.com/). This action would work regardless of the element being hidden.
Here’s the code:
"function(element, input) {
var item = document.getElementsByClassName('MainHeader-searchButton')[0];
item.click();
}"
Depending on the application and how the element is hidden you can also try using “send window messages” or “Simulate click”.
If the element is responsive while being hidden this could be another way.
I’m trying to use Inject JS cause a click event, but no matter what I do I keep getting this error:
Main has thrown an exception
Source: Inject js script
Message: Exception from HRESULT: 0x80020101
Exception Type: ElementOperationException
UiPath.Core.ElementOperationException: Exception from HRESULT: 0x80020101 —> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x80020101
at UiPath.UiNodeClass.InjectAndRunJS(String bstrCode, String bstrInputText)
at UiPath.Core.UiElement.InjectAndRunJS(String code, String input)
— End of inner exception stack trace —
at UiPath.Core.Activities.TaskAsyncCodeActivity`1.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)