Welcome Guest Search | Active Topics | Sign In | Register

Headless Webview in Threadrunner vs UI Application - Different Behavior on Same Websites Options
Pat Miranda
Posted: Thursday, June 13, 2024 11:57:22 AM
Rank: Newbie
Groups: Member

Joined: 1/31/2024
Posts: 1
Hello,

Just some background:
We are using a WebView in a VB.NET Windows Form Application running .NET Framework 4.7.2 to automate filling out online forms using the EvalScript method. For example, we will fill an input box with an Id number, then send 'Tab' to navigate away from the element:

Code: Visual Basic.NET
webView.EvalScript("document.getElementById('Dc-c').click();")
webView.EvalScript("document.getElementById('Dc-c').value='" & idnumber & "';")
webView.SendKeyEvent(True, EO.WebBrowser.KeyCode.Tab)


We also use a WebView in a C# .NET 8 Web API project. This WebView is headless and is run inside a ThreadRunner. For the majority of websites, they work the same. However, there are cases where on certain websites when we set a value, it disappears when we navigate away from the input field, as if the value was never set at all. For example, running the identical commands as above results in the input not holding any value:

Code: C#
webView.EvalScript("document.getElementById('Dc-c').click();");
webView.EvalScript($"document.getElementById('Dc-c').value='{idnumber}';");
webView.SendKeyEvent(true, EO.WebBrowser.KeyCode.Tab);


We have tried setting the value directly as shown above, and also by focusing on the element and sending each char individually using .SendChar(). We tried to force the element to update by using the JavaScript "dispatchEvent(new Event('input', { bubbles: true })" to force any updating that may need to occur. However, no matter what we try, no value is set in these inputs. The strange thing is that these same sites work fine in the UI WebView version.

Our Question
We are struggling to identify why the same exact logic works perfectly fine not using ThreadRunner in a UI application, but fails to work headless using ThreadRunner. Could anyone help shed some light on why this may be the case, if there are any workarounds, or if anyone has shared a similar experience?

Thank you!
eo_support
Posted: Friday, June 14, 2024 3:08:58 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

There are many possible reasons. One reason is the window size for the UI application can be different than the one used by the ThreadRunner thus the page behaves differently due to responsive UI design. However we are not able to tell you exactly why the value is not set without actually debug into the code. Would you be able to isolate the problem into a test project and send the test project to us? See here for more details:

https://www.essentialobjects.com/forum/test_project.aspx

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.