I am creating a UWP app using c#. The app is supposed to fetch information from a website and present it to the user. I\'ve went through the DOM of the site and managed to downl
Here is an example for Entering text in search box and Click search button in Bing
Use WebView to do all the work
WebView webView = new WebView();
Use InvokeScriptAsync method for WebView to use JS code
webView.InvokeScriptAsync("eval", new string[] {});
Get the HTML of the site using below code
public LoadURI()
{
webView.Navigate(new Uri("https://www.bing.com/"));
webView.NavigationCompleted += webView_NavigationCompletedAsync;
}
string siteHtML = null;
private async void webView_NavigationCompletedAsync(WebView sender, WebViewNavigationCompletedEventArgs args)
{
siteHtML = await webView.InvokeScriptAsync("eval", new string[] { "document.documentElement.outerHTML;" });
}
Enter text in search box using below code
private async void EnterTextAsync(string enterText)
{
var functionString = string.Format(@"document.getElementsByClassName('b_searchbox')[0].innerText = '{0}';", enterText);
await webView.InvokeScriptAsync("eval", new string[] { functionString });
}
Simulate click using below code
private async void SimulateClickAsync()
{
var functionString = string.Format(@"ddocument.getElementsByClassName('b_searchboxSubmit')[0].click();");
await webView.InvokeScriptAsync("eval", new string[] { functionString });
}
Here is a Sample app for LogIn to StackOverflow: StackOverFlow-LogIn