lessandroaraujo
28-06-2020 22:59:54
Olá pessoal do fórum, estou automatizando uma atividade da empresa, e um intranet interno tem uma caixa de listagem onde devo selecionar dados, porém não estou conseguindo fazê-lo com o código que tenho, conseguem me dar uma ajuda? segue a inspeção do elemento dessa listagem:
<select class="clsSelectControl" id="PRMT_COUNTRY_NS" aria-invalid="true"
aria-multiselectable="true" aria-required="true" style='width: 125px; height: 100px;
font-family: "Calibri"; font-size: 12pt; max-height: none;' size="11" multiple="">
<option value="EUA" dv="EUA">EUA</option>
<option value="CAN" dv="CAN">CAN</option>
<option value="BRA" dv="BRA">BRA</option>
</select>
Estou usando o vba abaixo para seleconar a opção BRA no listbox:
Declare Function apiShowWindow Lib "user32" Alias "ShowWindow" _
(ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Global Const SW_MAXIMIZE = 3
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2
Sub SITE()
Dim ie As InternetExplorer
Set ie = CreateObject("InternetExplorer.application")
ie.Visible = True
apiShowWindow ie.hwnd, SW_MAXIMIZE
ie.Navigate "https:intranetdaempresa.com"
While ie.Busy Or ie.ReadyState <> READYSTATE_COMPLETE: DoEvents: Wend
ie.Document.getElementById("PRMT_COUNTRY_NS").Focus
ie.Document.getElementById("PRMT_COUNTRY_NS").selectedIndex = 2
ie.Document.getElementById("PRMT_COUNTRY_NS").Click
ie.Quit
End Sub
Já usei o "get" para class, para id, document.all.item, mas todos mostram erro 424 "object required", as bibliotecas Microsoft Internet Controls, VB for Applications estão habilitadas também.
Não sei se ajuda, gravei com o Selenium IDE o passo a passo deste click para tentar pegar o nome de botão ou comando, mas não sei com traduzir para o VBA, pois o Selenium não tem opção de exportar para o VBA, segue o passo desta lista:
{
"id": "15f29f61-4af2-487e-872d-25d20f18299f",
"comment": "",
"command": "addSelection",
"target": "id=PRMT_COUNTRY_NS",
"targets": [
["id=PRMT_COUNTRY_NS", "id"],
["css=#PRMT_COUNTRY_NS", "css:finder"],
["xpath=//select[@id='PRMT_COUNTRY_NS']", "xpath:attributes"],
["xpath=//div[@id='PRMT_COUNTRY_NS']/select", "xpath:idRelative"],
["xpath=//select", "xpath:position"]
],
"value": "label=BRA"
}
Desde já obrigado
<select class="clsSelectControl" id="PRMT_COUNTRY_NS" aria-invalid="true"
aria-multiselectable="true" aria-required="true" style='width: 125px; height: 100px;
font-family: "Calibri"; font-size: 12pt; max-height: none;' size="11" multiple="">
<option value="EUA" dv="EUA">EUA</option>
<option value="CAN" dv="CAN">CAN</option>
<option value="BRA" dv="BRA">BRA</option>
</select>
Estou usando o vba abaixo para seleconar a opção BRA no listbox:
Declare Function apiShowWindow Lib "user32" Alias "ShowWindow" _
(ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Global Const SW_MAXIMIZE = 3
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2
Sub SITE()
Dim ie As InternetExplorer
Set ie = CreateObject("InternetExplorer.application")
ie.Visible = True
apiShowWindow ie.hwnd, SW_MAXIMIZE
ie.Navigate "https:intranetdaempresa.com"
While ie.Busy Or ie.ReadyState <> READYSTATE_COMPLETE: DoEvents: Wend
ie.Document.getElementById("PRMT_COUNTRY_NS").Focus
ie.Document.getElementById("PRMT_COUNTRY_NS").selectedIndex = 2
ie.Document.getElementById("PRMT_COUNTRY_NS").Click
ie.Quit
End Sub
Já usei o "get" para class, para id, document.all.item, mas todos mostram erro 424 "object required", as bibliotecas Microsoft Internet Controls, VB for Applications estão habilitadas também.
Não sei se ajuda, gravei com o Selenium IDE o passo a passo deste click para tentar pegar o nome de botão ou comando, mas não sei com traduzir para o VBA, pois o Selenium não tem opção de exportar para o VBA, segue o passo desta lista:
{
"id": "15f29f61-4af2-487e-872d-25d20f18299f",
"comment": "",
"command": "addSelection",
"target": "id=PRMT_COUNTRY_NS",
"targets": [
["id=PRMT_COUNTRY_NS", "id"],
["css=#PRMT_COUNTRY_NS", "css:finder"],
["xpath=//select[@id='PRMT_COUNTRY_NS']", "xpath:attributes"],
["xpath=//div[@id='PRMT_COUNTRY_NS']/select", "xpath:idRelative"],
["xpath=//select", "xpath:position"]
],
"value": "label=BRA"
}
Desde já obrigado