0

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

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

thanks for your info , all good but only submit code "$(BTN).trigger('click');" not work for me ! do you can give me more solution ?kind regards
:also i use from these code : dynamic element = (JSObject)webctrl.ExecuteJavascriptWithResult("document.getElementById('btn')"); if (element != null) { element.Invoke("click"); element.Invoke("submit"); } but not work too......
:OPS WTF ! :( I don't use from correct ElementById !!! OMG ! i used from textbox ElementById for BTN ! ....Thanks for your time ... OMG fffff ! Thanks kind regards :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.