As铆 funciona bien. Pru茅balo por favor:
#include "FiveWin.ch"
static oWebView
function Main()
聽 聽local oWndMain, oWnd, cResult
聽 聽TEXT INTO cResult
聽 聽 聽 [ document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:primerNombre' ).innerHTML,
聽 聽 聽 聽 document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:otrosNombres' ).innerHTML,
聽 聽 聽 聽 document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:primerApellido' ).innerHTML,
聽 聽 聽 聽 document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:segundoApellido' ).innerHTML,
聽 聽 聽 聽 document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:estado' ).innerHTML,
聽 聽 聽 聽 document.getElementById( 'vistaConsultaEstadoRUT:formConsultaEstadoRUT:dv' ).innerHTML ]
聽 聽ENDTEXT 聽 聽
聽 聽DEFINE WINDOW oWndMain TITLE "Usando DIAN desde un webview" SIZE 1050, 700 MDI
聽 聽DEFINE WINDOW oWnd MDICHILD OF oWndMain
聽 聽oWebView = TWebView2():New( oWnd )
聽 聽oWebView:bOnNavigationCompleted = { | cUrl, hWebView | If( "sessionid" $ cUrl, oWebView:Eval( cResult ),) }
聽 聽oWebView:Navigate( "https://muisca.dian.gov.co/WebRutMuisca/DefConsultaEstadoRUT.faces" )
聽 聽oWebView:InjectJavascript( JavaScript() )
聽 聽// oWebView:OpenDevToolsWindow()
聽 聽oWebView:bOnEval = { | cJson, hWebView | If( cJson != "null" .and. cJson != "{}", ( MsgInfo( cJson ), oWnd:End() ),) }
聽 聽oWebView:Eval( "consultaDIAN( '79760202' )" )
聽 聽ACTIVATE WINDOW oWndMain CENTER ;
聽 聽 聽 ON RESIZE oWebView:SetSize( nWidth, nHeight )
聽 聽oWebView:End()
return nil
function Javascript()
聽 聽local cCode
聽 聽TEXT INTO cCode
聽 聽 聽 function consultaDIAN( numeroIdentificacion )
聽 聽 聽 {
聽 聽 聽 聽 聽var inputNIT = document.getElementById('vistaConsultaEstadoRUT:formConsultaEstadoRUT:numNit');
聽 聽 聽 聽 聽if (inputNIT) {
聽 聽 聽 聽 聽 聽 inputNIT.value = numeroIdentificacion;
聽 聽 聽 聽 聽} else {
聽 聽 聽 聽 聽 聽 console.error('No se encontr贸 el campo de entrada para el NIT');
聽 聽 聽 聽 聽 聽 return;
聽 聽 聽 聽 聽} 聽 聽
聽 聽 聽 聽 聽
聽 聽 聽 聽 聽var botonBuscar = document.getElementById('vistaConsultaEstadoRUT:formConsultaEstadoRUT:btnBuscar');
聽 聽 聽 聽 聽if (botonBuscar) {
聽 聽 聽 聽 聽 聽 botonBuscar.click();
聽 聽 聽 聽 聽} else {
聽 聽 聽 聽 聽 聽 console.error('No se encontr贸 el bot贸n de b煤squeda');
聽 聽 聽 聽 聽 聽 return;
聽 聽 聽 聽 聽}
聽 聽 聽 }
聽 聽ENDTEXT
return cCode