0

Hi im programming in WPF/C# and using awesomium WebControl

I'm trying to click in this:

<li class="playlist-item-favorite" data-title="Ulubione" data-is-private="False">
      <a href="javascript: void(0);">
        <span class="playlist-title">
          Ulubione

          <span class="playlist-video-count-container">
            (<span class="playlist-video-count">1</span>)
          </span>
        </span>

        <span class="playlist-public-private">
Publiczny
        </span>
      </a>
    </li>

My code C#:

 dynamic lists = (JSObject)Browser.ExecuteJavascriptWithResult("document.getElementsByClassName('playlist-item-favorite')");

            if (lists == null)
                return;

        length = lists.length;
        if (length == 0)
            return;

        using (lists)
        {
            using (JSObject obiekt = lists.Invoke("item", 0))
                obiekt.InvokeAsync("click");
        }
    }

I know i've found this object, when i get atributes it was ok, but click dont work for it.

I shows methods for this object and there are no mothod like click or onclick. Methods:

insertAdjacentHTML
insertAdjacentText
insertAdjacentElement
getAttribute
setAttribute
removeAttribute
getAttributeNode
getElementsByTagName
getAttributeNS
setAttributeNS
removeAttributeNS
getElementsByTagNameNS
getAttributeNodeNS
hasAttribute
hasAttributeNS
focus
blur
scrollIntoView
scrollIntoViewIfNeeded
scrollByLines
scrollByPages
getElementsByClassName
querySelector
querySelectorAll
webkitMatchesSelector
getClientRects
getBoundingClientRect
setAttributeNode
removeAttributeNode
setAttributeNodeNS
webkitRequestFullScreen
insertBefore
replaceChild
removeChild
appendChild
hasChildNodes
cloneNode
normalize
isSupported
hasAttributes
lookupPrefix
isDefaultNamespace
lookupNamespaceURI
addEventListener
removeEventListener
isSameNode
isEqualNode
compareDocumentPosition
contains
dispatchEvent

Can you help me?

@Edit I found this for javascript: Trigger a button click from a non-button element But i can't use it in my app.

Community
  • 1
  • 1
Finchsize
  • 935
  • 2
  • 17
  • 34

1 Answers1

0

Somewhere in the web page's accompanying Javascript there will be a function bound to that <a> element's click event - find what it is, then call it directly. If the function in question references the self object, you need to get a reference to the function and call the call method on it, passing the anchor element as the first parameter.

The alternative - what you're trying to do - is probably more complicated. The anchor element doesn't actually have a clicked() function, instead you would need to manually create an event.

Community
  • 1
  • 1
cpf
  • 409
  • 4
  • 10