ExecuteScriptAsync help wanted!

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

ExecuteScriptAsync help wanted!

Postby Shrooms » Fri Dec 23, 2016 6:35 pm

The following code was when I used webBrowser (native) .net control.

Code: Select all
 string GetSubstringByString(string a, string b, string c)
        {
            return c.Substring((c.IndexOf(a) + a.Length), (c.IndexOf(b) - c.IndexOf(a) - a.Length));
        }

SupremeSize.SetAttribute("value", GetSubstringByString("=", ">", element.OuterHtml));
                                    SupremeSize.InvokeMember("onchange");
                                    SupremeSize.InvokeMember("click");


The following dropdown list;

Code: Select all
<select id="size" name="size">
    <option value="36153">Medium</option>
    <option value="36154">Large</option>
    </select>


What I have so far which works;

Code: Select all
 Browser.ExecuteScriptAsync("document.getElementById('size').value=" + '\'' + "36154" + '\'');

switch(Wishlist[item].Size)
                    {
                        case "Small":
                            index = 0;
                            break;

                        case "Medium":
                            index = 1;
                            break;

                        case "Large":
                            index = 2;
                            break;

                        case "XLarge":
                            index = 3;
                            break;
                    }

                    Browser.ExecuteScriptAsync("document.getElementById('size').selectedIndex=" + '\'' + index + '\'');


The problem with the code above is that it assumes I know the option value and if I change the selectedIndex it just shows a blank!

I am wondering how I can replicate the following into CEFSharp as the following actually works!

Code: Select all
 string GetSubstringByString(string a, string b, string c)
        {
            return c.Substring((c.IndexOf(a) + a.Length), (c.IndexOf(b) - c.IndexOf(a) - a.Length));
        }

SupremeSize.SetAttribute("value", GetSubstringByString("=", ">", element.OuterHtml));
                                    SupremeSize.InvokeMember("onchange");
                                    SupremeSize.InvokeMember("click");
Shrooms
Newbie
 
Posts: 2
Joined: Tue Dec 20, 2016 3:16 pm

Return to Support Forum

Who is online

Users browsing this forum: clown, Google [Bot] and 40 guests