简体   繁体   中英

Webbrowser: simulate mouse click on ul-li item in webpage

I'm automating process with one website using WebBrowser component C#/.Net The actual problem is that I do not know Javascript well to understand how things work under the mouse clicks on some elements.

For example, I have a page where ajax and jquery used (I guess so ;) and there is a list of elements (it is a tree with subtrees). So when I click on the root element, loading progress is shown and content is changing without complete reload of the page. And subtree is also expanded.

The question is how to do This mouse click on root tree element using WebBrowser control? I can get aprropriate <LI> element for this root elem in the tree and there is a <span> with text only. If I call InvokeMember("click") it does nothing...

please advise..

Thanks, Michael.

you can simulate a event on any element. both of these will work.

$(selector).click(); // triggers a click event on the selector (Selectors are CSS like selector passed)

EDIT:

I don't understand yet from where you are starting to look for that li

$("li:has(span)").trigger("click"); // triggers a click event on the `li`

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM