Question

i want to get element by id and then get attribute and etc....

in web browser i use from this code :

                HtmlElement element = wb.Document.Body.Document.GetElementById("dnn_ctr730_ViewTMUrbanFileStatusFromWebService_fb_Captcha_CaptchaImageUP");
                if (element != null)
                {
                    string link = element.GetAttribute("src");

but in awesomium how can i do this ?

and also when i want to set value to element in web browser using from this code :

wb.Document.GetElementById("txtFileNo").SetAttribute("Value", "12345");
wb.Document.GetElementById("BTN").InvokeMember("click");

but i don't know how can i do this in awesomium ....

i found this code for set value :

        dynamic document = (JSObject)webctrl.ExecuteJavascriptWithResult("document");
        if (document == null)
            return "";
        using (document)
        {
            dynamic elem = document.getElementById("txt1");

            if (elem == null)
                return "";

            using (elem)
                elem.value = "test";

but i don't know how to invoke Click and also how to get attribute value...

anye one can help me ..?

Kind regards

Was it helpful?

Solution

I would use jQuery's attr() and jQuery's trigger():

webctrl.ExecuteJavascript("$(#txtFileNo).attr('value', '12345');");
webctrl.ExecuteJavascript("$(#BTN).trigger('click');");

Since you are targeting a single browser, you could use plain old Javascript for this against the Chromium DOM. But, I find jQuery's trigger() to be much easier to use than the alternative.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top