Code:
Host.Log("keep in mind that parts of the script fail when chrome devtools are attached to the browser.");
Host.Log("this sample depends on the path to chrome.exe and a free address already configured in the UI (\"Interface\"->\"config\" tab)");
Host.Log("if you have questions about the API or syntax or need help with a script, visit the forum at http://forum.botengine.de/cat/web/ or take a look at the wiki at https://github.com/Arcitectus/Limbara/wiki/");
Host.Log("\nthis script navigates to a web search engine and fills the form to initiate a search.");
var App = Limbara.App;
if(null == App)
throw new ArgumentNullException("App object not available. Make sure you are using an up to date version of the application.", "App");
var Process = Limbara.App.ReuseOrCreateProcess()?.Result;
var ConnectionAttempt = Process?.ReuseOrOpenConnection();
var WebBrowser = ConnectionAttempt?.Result;
if(null == WebBrowser)
throw new Exception("failed to connect to browser, " + ConnectionAttempt?.Error?.Message);
Host.Log("connected to browser.");
Host.Delay(1111);
Host.Log("navigating to website.");
WebBrowser.Document.Result.locationHref = "http://duckduckgo.com";
Host.Log("waiting for website to load.");
Host.Delay(4444);
var SearchBox = WebBrowser.Document?.Result?.GetElementFromXPath("//input[@type='text']");
if(null == SearchBox)
throw new Exception("search box not found");
Host.Log("search box found, entering search term.");
SearchBox.setAttribute("value", "Limbara");
var SubmitButton = WebBrowser.Document?.Result?.GetElementFromXPath("//input[@type='submit']");
if(null == SubmitButton)
throw new Exception("submit button not found");
Host.Log("submit button found, clicking.");
SubmitButton.click();