0

I would like to click on this button without using selenium. Any suggestions?


HTML CODE

<div id="frame">

<!-- START HEADER -->
    <div id="header">

        <div id="logo"><a href="#"><img src="control?view=view/images/ft_logo.gif" alt="logo" border="0" width="245" height="89"></a></div>


        <div id="nav"><a href="control?view=view/filetransfer/thin/fileList.jsp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('transfers','','control?view=view/images/es/nav_ft_transfers-over.gif',1)"><img src="control?view=view/images/es/nav_ft_transfers.gif" alt="Transferencias" name="transfers" border="0"></a>

                        <a href="control?view=view/filetransfer/thin/auditList.jsp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('history','','control?view=view/images/es/nav_ft_history-over.gif',1)"><img src="control?view=view/images/es/nav_ft_history.gif" alt="Historia" name="history" border="0"></a>


                   <a href="control?view=view/filetransfer/thin/changePasswordForm.jsp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('password','','control?view=view/images/es/nav_ft_password-over.gif',1)"><img src="control?view=view/images/es/nav_ft_password.gif" alt="Cambiar contraseña" name="password" border="0"></a>


                    <a href="control?view=servlet/keys" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('pgpkey','','control?view=view/images/es/nav_keys-over.gif',1)"><img src="control?view=view/images/es/nav_keys.gif" alt="Llave PGP" name="pgpkey" border="0"></a>

                  <a href="javascript:openPopUpSIFTHelp()" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('help','','control?view=view/images/es/nav_ft_help-over.gif',1)"><img src="control?view=view/images/es/nav_ft_help.gif" alt="Ayuda" name="help" border="0"></a></div>


        <div id="version">Bienvenido, ccal001 | miércoles 15 de enero de 2020 7:58:03</div> 

        <div id="logout">
            <img src="control?view=view/images/icon_logout.gif" alt="Terminar Sesion"><a href="javascript:CloseWindow('login/logout?logouttoken=-2263819166038691904');">Terminar Sesion</a>
        </div>
<!-- END HEADER -->

    <!-- START CONTENT -->
    <div id="content" style="display: none;">              

        <div class="refresh"><a href="control?view=view/filetransfer/thin/fileList.jsp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('refresh','','control?view=view/images/es/btn_refresh-roll.gif',1)"><img src="control?view=view/images/es/btn_refresh.gif" alt="Refresh" name="refresh" width="70" height="17" border="0"></a></div>
        <h2>Transferencias</h2>

    <p><img src="control?view=view/images/red_folder.gif">&nbsp;-&nbsp;Es necesario seleccionar los archivos/directorios antes de que la transferencia pueda ser ejecutada.</p>
    <p><img src="control?view=view/images/green_folder.gif">&nbsp;-&nbsp;Por defecto todos los archivos serán descargados.</p>

    <div id="tc_table">  

        <table>
              <tbody><tr class="header">
                <td class="hidecolumn">Descripción</td>
                <td width="375">Nombre del archivo Local</td>
                <td width="98">&nbsp;</td>
              </tr>


              <tr class="row0">


                  <form name="file0"></form>

                  <td class="hidecolumn">Archivos de Captura</td>
                  <td nowrap="">

                                **<button type="button" onclick="javascript:multiFileBrowse("FileBrowseApplet0";, &quot;375&quot;, &quot;25&quot;, &quot;clsid:8AD9C840-044E-11D1-B3E9-00805F499D93&quot;, &quot;, &quot;control?view=view/filetransfer/thin/FileBrowseApplet_0.0.0.1.jar,control?view=view/filetransfer/thin/mlproperties.jar&quot;, &quot;application/x-java-applet;version=1.6.0&quot;, &quot;RECEIVE&quot;, &quot;c%3A%5C*&quot;, &quot;passed By filelistArray&quot;, &quot;Archivos+de+Captura&quot;);">
                                <img src="view/images/green_folder.gif"> Examinar
                                </button>**

-->


my code and the tests I did

$ie = new-object -com "InternetExplorer.Application" $ie.visible = $true maxIE $ie

$username="xxxxxxx"

$password=Get-Content -Path D:\pass\PasswordPosnet.txt

$ie.Navigate("siteweb") $HomePage = $ie.document

While ($ie.Busy -eq $true) {Start-Sleep -Seconds 2;}

$usernamefield = $ie.document.getElementByID('userid') $usernamefield.value = "$username"

$passwordfield = $ie.document.getElementByID('password') $passwordfield.value = "$password"

$Link = $ie.document.getElementByID('button') $Link.click()

Start-Sleep -seconds 2

Test 1

$link = @($ie.Document.getElementsByTagName('a')) | Where-Object {$_.innerText -eq 'Examinar'} $link.click()

Test 2

$ie.document.IHTMLDocument3_getElementsByTagName("button") | ForEach-Object { $_.Click() }

Test 3

$link=$ie.Document.getElementsByTagName("button") | where-object {$_.type -eq "submit"} $link.click()

Test 4

$link =$ie.Document.getElementsByTagName("input") | Where-Object{$.type -eq 'button' -and $.value -eq 'FileBrowseApplet0'} $link.Click()


The way to differentiate this button is this: "FileBrowseApplet0"

4
  • Have you tried anything yet? Please take the tour and also read How to Ask. Stack Overflow is not a free script writing service. Your own research and code attempts are expected. Edit the question to include your code in a Minimal, Complete, and Verifiable example. Commented Jan 14, 2020 at 11:31
  • It looks like your button has inner text 'Examiner'. You can try to make a test with the code in this link. textuploader.com/16d4j Let us know about your testing result. Commented Jan 15, 2020 at 3:31
  • Hi, thanks for your response. Try what you told me but it didn't work. The problem is that the page contains 3 EXAMINE buttons and I have to use all 3 individually. I leave all the HTML code. Commented Jan 15, 2020 at 10:56
  • I suggest you loop through all the buttons on the web page and check it's innerHTML. If it gets matched then try to click that button. In this way, you can click all 3 buttons individually. Ref: textuploader.com/161k6 Commented Jan 17, 2020 at 6:29

1 Answer 1

0

This should lead you to the right way (PowerShell):

$oIE         = new-object -com internetexplorer.application
$oIE.visible = $true

[void]$oIE.navigate2("https://<yourUrl>")
Do {
    sleep -seconds 1
} while ($oIE.busy)


$control = $oIE.document.IHTMLDocument3_getElementsByTagName('BUTTON') | ? { $_.IHTMLElement_innerHTML -like <patternToFind> }

[void]$control.click()

while ($oIE.busy) {
    sleep -seconds 1
}
Sign up to request clarification or add additional context in comments.

2 Comments

Hello, thanks for answering. Your suggestion did not work. I just updated the HTML code.
The script is working here. So you have to debug what the problem is on your side. I would check first, what is the return value of $oIE.document.IHTMLDocument3_getElementsByTagName('BUTTON') and see, what properties are available. It's relatively simple to check.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.