2014-02-19 1 views
0

C#에서 awesomium의 요소에 대한 설정 속성 값과 :웹 브라우저에서</p> <p>내가이 코드에서 사용 .... 특성 등을 얻을 후 얻을 내가 ID로 요소를 얻으려면

   HtmlElement element = wb.Document.Body.Document.GetElementById("dnn_ctr730_ViewTMUrbanFileStatusFromWebService_fb_Captcha_CaptchaImageUP"); 
       if (element != null) 
       { 
        string link = element.GetAttribute("src"); 

하지만 awesomium에서 어떻게해야합니까?

또한이 코드에서 사용하는 웹 브라우저에서 요소에 값을 설정하려는 경우 :

wb.Document.GetElementById("txtFileNo").SetAttribute("Value", "12345"); 
wb.Document.GetElementById("BTN").InvokeMember("click"); 

하지만 난 awesomium에서이 작업을 수행 할 수 있습니다 방법을 모른다 ....

내가 설정 값이 코드 발견 :

 dynamic document = (JSObject)webctrl.ExecuteJavascriptWithResult("document"); 
     if (document == null) 
      return ""; 
     using (document) 
     { 
      dynamic elem = document.getElementById("txt1"); 

      if (elem == null) 
       return ""; 

      using (elem) 
       elem.value = "test"; 

을하지만 난 ... 클릭을 호출하는 방법을 모르고 방법도 속성 값을 얻을 수

아무도 나를 도울 수 .. ..?

종류 내가 jQuery's attr()jQuery's trigger()을 사용

답변

1

에 관하여 : 당신은 하나의 브라우저를 대상으로하고 있기 때문에, 당신은 크롬 DOM에 대해이를 위해 보통 오래된 자바 스크립트를 사용할 수

webctrl.ExecuteJavascript("$(#txtFileNo).attr('value', '12345');"); 
webctrl.ExecuteJavascript("$(#BTN).trigger('click');"); 

. 그러나 나는 jQuery's trigger()이 대안보다 훨씬 사용하기 쉽다고 생각합니다.

+0

정보를 제공해 주셔서 감사합니다. 모두 좋지만'$ (BTN) .trigger ('click') 코드 만 제출하십시오. 당신은 내게 더 많은 솔루션을 줄 수 있습니까? 친절한 대답 – Sam

+0

: 또한이 코드에서 사용 :'동적 요소 = (JSObject) webctrl.ExecuteJavascriptWithResult ("document.getElementById ('btn')"); if (element! = null) { element.Invoke ("click"); element.Invoke ("submit"); }'하지만 작동하지 않습니다 ...... – Sam

+0

아이디로 요소를 가져 오는 데'# '선택기를 사용하는 걸 잊었습니다. –