0
geckofx 29를 사용하고 있습니다. 어떻게 자바 스크립트 이벤트에서 C# 함수를 호출 할 수 있습니까?geckofx, C# 이벤트 리스너 추가
내가 검색이 솔루션을 찾을 수 있지만 작동하지 않는 그 :
public void AddEventListener_JScriptFiresEvent_ListenerIsCalledWithMessage()
{
string payload = null;
browser.AddMessageEventListener("callMe", ((string p) => payload = p));
browser.LoadHtml(
@"<!DOCTYPE html>
<html><head>
<script type='text/javascript'>
window.onload= function() {
event = document.createEvent('MessageEvent');
var origin = window.location.protocol + '//' + window.location.host;
event.initMessageEvent ('callMe', true, true, 'some data', origin, 1234, window, null);
document.dispatchEvent (event);
}
</script>
</head><body></body></html>");
browser.NavigateFinishedNotifier.BlockUntilNavigationFinished();
Assert.AreEqual("some data", payload);
}
event.initMessageEvent 실행할 수 없습니다 ...
나에게
감사합니다. @MatheM –