c# - Why element.click() not working in Cefsharp? -
i try execute below script in cefsharp click on div element, , not working.
private static string clickunreads = @"(function() { let chatsel = document.queryselectorall('.infinite-list-item'); (let x = 0; x < chatsel.length; x++) { let unread = chatsel[x].getelementsbyclassname('unread'); if (unread.length > 0) { chatsel[x].click(); } } })();"; public void clickunreads() { webbrowser.executescriptasync(clickunreads); }
i found similar threads here have problem similar mine, none of it's answer working.
i wanna use selenium based solution, did in java, need browser embedded inside app, , can't use headless browser, because site i'm trying automate requires qr code authentication.
is possible use chromium web driver control cefsharp? if possible, can shed light me? (show me link of it).
below code in java, using chrome web driver, , works charm
while (true) { list<webelement> chatitems = chatslist.findelements(by.classname("infinite-list-item")); (webelement el : chatitems) { webelement unread = el.findelement(by.classname("unread")); if (unread != null) { unread.click(); } } thread.sleep(10000); }
i checked link too, find out if there embeddable browser, haven't got time test them (any recommendation appreciated).
thanks
okay,
i managed solved this, of thread. changed js script this
@"(function(x) { let chatsel = document.queryselectorall('.infinite-list-item'); (let x = 0; x < chatsel.length; x++) { let unread = chatsel[x].getelementsbyclassname('unread'); if (unread.length > 0) { let hoverevent = document.createevent ('mouseevents'); hoverevent.initevent ('mouseover', true, true); unread[0].dispatchevent (hoverevent); let downevent = document.createevent ('mouseevents'); downevent.initevent ('mousedown', true, true); unread[0].dispatchevent (downevent); let clickevent = document.createevent ('mouseevents'); clickevent.initevent ('click', true, true); unread[0].dispatchevent (clickevent); } } })();";
and managed click on unread messages.
wiki
Comments
Post a Comment