Ajuda com Conexão web
Enviado: Seg Dez 10, 2018 2:25 pm
Boa tarde pessoal, todos bem?
Estou fazendo um código para logar em um site da intranet daqui onde trabalho. Mas está dando uns erros
Alguém para dar uma ajuda?
Segue um scprit que peguei da pagina com os valores dos camppos e segue o codigo de login
Sub Login()
Dim oHTML_Element As IHTMLElement
Dim sURL As String
On Error GoTo Err_Clear
sURL = ""
Set oBrowser = New InternetExplorer
oBrowser.Silent = True
oBrowser.timeout = 60
oBrowser.Navigate sURL
oBrowser.Visible = True
Do
Loop Until oBrowser.ReadyState = READYSTATE_COMPLETE
Set HTMLDoc = oBrowser.Document
HTMLDoc.all.Ecom_User_ID.Value = ""
HTMLDoc.all.Ecom_Password.Value = ""
For Each oHTML_Element In HTMLDoc.getElementsByTagName("input")
If oHTML_Element.Type = "IDPLogin" Then oHTML_Element.Click: Exit For
Next
Err_Clear:
Resume Next
End Sub
'---------------------------------------------------------------------------------------------------
script da intranet
<script>
function safeSetGlobalMessage(strMessage)
{
var proofOfEndUserEnvironment= document.getElementById('runningInEndUserLoginEnvironment');
if (proofOfEndUserEnvironment)
{
setGlobalMessage(strMessage);
}
}
function submitForm()
{
var userNameEditBox = document.getElementById('Ecom_User_ID');
var passwordEditBox = document.getElementById('Ecom_Password');
if ((null != userNameEditBox) && (null != passwordEditBox))
{
if ((0 == userNameEditBox.value.length) || (0 == passwordEditBox.value.length))
{
safeSetGlobalMessage("Digite os valores para o nome de usuário e senha.");
userNameEditBox.focus();
return;
}
//if recaptcha is enabled just let the recaptcha code submit the document after verification
// Get some values from elements on the page:
var form = document.getElementById('IDPLogin');
var url = form.action;
safeSetGlobalMessage("Validando Credenciais...");
var proofOfEndUserEnvironment= document.getElementById('runningInEndUserLoginEnvironment');
if (proofOfEndUserEnvironment)
{
url = updateQueryString("uiDestination", "contentDiv", url);
// Send the data using post
var posting = $.post( url, $("#IDPLogin" ).serialize());
// Put the results in a div
posting.done(function( data )
{
safeSetGlobalMessage("");
$('#theNidpContent').html(data);
});
posting.fail(function()
{
safeSetGlobalMessage("Erro ao se comunicar com o servidor de identidade");
});
}
else
{
document.IDPLogin.submit();
}
}
}
function submitForm2() {
// Get some values from elements on the page:
var form = document.getElementById('IDPLogin');
var url = form.action;
safeSetGlobalMessage("Validando Credenciais...");
var proofOfEndUserEnvironment= document.getElementById('runningInEndUserLoginEnvironment');
if (proofOfEndUserEnvironment)
{
url = updateQueryString("uiDestination", "contentDiv", url);
// Send the data using post
var posting = $.post( url, $("#IDPLogin" ).serialize());
// Put the results in a div
posting.done(function( data )
{
safeSetGlobalMessage("");
$('#theNidpContent').html(data);
});
posting.fail(function()
{
safeSetGlobalMessage("Erro ao se comunicar com o servidor de identidade");
});
}
else
{
document.IDPLogin.submit();
}
}
function onLoadFocus()
{
if (document.IDPLogin.Ecom_User_ID.value)
{
document.IDPLogin.Ecom_Password.focus();
}
else
{
document.IDPLogin.Ecom_User_ID.focus();
}
}
$(document).ready(function(){
onLoadFocus();
$( "#loginButton2" ).click(function()
{
submitForm();
});
$( "#loginButton2" ).keyup(function(event)
{
if (isEnterKey(event) || isSpaceKey(event))
{
submitForm();
}
});
$("#Ecom_User_ID").keyup(function(event)
{
if (isEnterKey(event))
{
if (document.IDPLogin.Ecom_User_ID.value)
{
$("#loginButton2").click();
return false;
}
}
return true;
});
$("#Ecom_Password").keyup(function(event)
{
if (isEnterKey(event))
{
if (document.IDPLogin.Ecom_User_ID.value)
{
$("#loginButton2").click();
return false;
}
}
return true;
});
});
</script>
jose7br
Membro
Membro
Mensagens: 68
Registrado em: Seg Jan 09, 2017 1:11 pm
Agradeceu : 3 vezes
Foi agradecido: 0 time
Voltar ao topo
Estou fazendo um código para logar em um site da intranet daqui onde trabalho. Mas está dando uns erros
Alguém para dar uma ajuda?
Segue um scprit que peguei da pagina com os valores dos camppos e segue o codigo de login
Sub Login()
Dim oHTML_Element As IHTMLElement
Dim sURL As String
On Error GoTo Err_Clear
sURL = ""
Set oBrowser = New InternetExplorer
oBrowser.Silent = True
oBrowser.timeout = 60
oBrowser.Navigate sURL
oBrowser.Visible = True
Do
Loop Until oBrowser.ReadyState = READYSTATE_COMPLETE
Set HTMLDoc = oBrowser.Document
HTMLDoc.all.Ecom_User_ID.Value = ""
HTMLDoc.all.Ecom_Password.Value = ""
For Each oHTML_Element In HTMLDoc.getElementsByTagName("input")
If oHTML_Element.Type = "IDPLogin" Then oHTML_Element.Click: Exit For
Next
Err_Clear:
Resume Next
End Sub
'---------------------------------------------------------------------------------------------------
script da intranet
<script>
function safeSetGlobalMessage(strMessage)
{
var proofOfEndUserEnvironment= document.getElementById('runningInEndUserLoginEnvironment');
if (proofOfEndUserEnvironment)
{
setGlobalMessage(strMessage);
}
}
function submitForm()
{
var userNameEditBox = document.getElementById('Ecom_User_ID');
var passwordEditBox = document.getElementById('Ecom_Password');
if ((null != userNameEditBox) && (null != passwordEditBox))
{
if ((0 == userNameEditBox.value.length) || (0 == passwordEditBox.value.length))
{
safeSetGlobalMessage("Digite os valores para o nome de usuário e senha.");
userNameEditBox.focus();
return;
}
//if recaptcha is enabled just let the recaptcha code submit the document after verification
// Get some values from elements on the page:
var form = document.getElementById('IDPLogin');
var url = form.action;
safeSetGlobalMessage("Validando Credenciais...");
var proofOfEndUserEnvironment= document.getElementById('runningInEndUserLoginEnvironment');
if (proofOfEndUserEnvironment)
{
url = updateQueryString("uiDestination", "contentDiv", url);
// Send the data using post
var posting = $.post( url, $("#IDPLogin" ).serialize());
// Put the results in a div
posting.done(function( data )
{
safeSetGlobalMessage("");
$('#theNidpContent').html(data);
});
posting.fail(function()
{
safeSetGlobalMessage("Erro ao se comunicar com o servidor de identidade");
});
}
else
{
document.IDPLogin.submit();
}
}
}
function submitForm2() {
// Get some values from elements on the page:
var form = document.getElementById('IDPLogin');
var url = form.action;
safeSetGlobalMessage("Validando Credenciais...");
var proofOfEndUserEnvironment= document.getElementById('runningInEndUserLoginEnvironment');
if (proofOfEndUserEnvironment)
{
url = updateQueryString("uiDestination", "contentDiv", url);
// Send the data using post
var posting = $.post( url, $("#IDPLogin" ).serialize());
// Put the results in a div
posting.done(function( data )
{
safeSetGlobalMessage("");
$('#theNidpContent').html(data);
});
posting.fail(function()
{
safeSetGlobalMessage("Erro ao se comunicar com o servidor de identidade");
});
}
else
{
document.IDPLogin.submit();
}
}
function onLoadFocus()
{
if (document.IDPLogin.Ecom_User_ID.value)
{
document.IDPLogin.Ecom_Password.focus();
}
else
{
document.IDPLogin.Ecom_User_ID.focus();
}
}
$(document).ready(function(){
onLoadFocus();
$( "#loginButton2" ).click(function()
{
submitForm();
});
$( "#loginButton2" ).keyup(function(event)
{
if (isEnterKey(event) || isSpaceKey(event))
{
submitForm();
}
});
$("#Ecom_User_ID").keyup(function(event)
{
if (isEnterKey(event))
{
if (document.IDPLogin.Ecom_User_ID.value)
{
$("#loginButton2").click();
return false;
}
}
return true;
});
$("#Ecom_Password").keyup(function(event)
{
if (isEnterKey(event))
{
if (document.IDPLogin.Ecom_User_ID.value)
{
$("#loginButton2").click();
return false;
}
}
return true;
});
});
</script>
jose7br
Membro
Membro
Mensagens: 68
Registrado em: Seg Jan 09, 2017 1:11 pm
Agradeceu : 3 vezes
Foi agradecido: 0 time
Voltar ao topo