Selenium find_element unable to locate

Question:

I need to pass an int here:

1

This piece of code is the one that brings me error:

producto = driver.find_element(by=By.ID, value="ReportViewerControl_ctl04_ctl05_txtValue")
producto.send_keys(110017901)
ver_informe = driver.find_element(by=By.ID, value="ReportViewerControl_ctl04_ctl00").click()

The error

Traceback (most recent call last):
  File "C:UsersJuan M CabralDesktopPycharmPreciosseleniumstk_jeans_locales_barra.py", line 32, in <module>
    producto = driver.find_element(by=By.ID, value="ReportViewerControl_ctl04_ctl05_txtValue")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:UsersJuan M CabralPreciosLibsite-packagesseleniumwebdriverremotewebdriver.py", line 861, in find_element
    return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:UsersJuan M CabralPreciosLibsite-packagesseleniumwebdriverremotewebdriver.py", line 444, in execute
    self.error_handler.check_response(response)
  File "C:UsersJuan M CabralPreciosLibsite-packagesseleniumwebdriverremoteerrorhandler.py", line 249, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="ReportViewerControl_ctl04_ctl05_txtValue"]"}
  (Session info: chrome=108.0.5359.125)
Stacktrace:
Backtrace:
    (No symbol) [0x0029F243]
    (No symbol) [0x00227FD1]
    (No symbol) [0x0011D04D]
    (No symbol) [0x0014C0B0]
    (No symbol) [0x0014C22B]
    (No symbol) [0x0017E612]
    (No symbol) [0x001685D4]
    (No symbol) [0x0017C9EB]
    (No symbol) [0x00168386]
    (No symbol) [0x0014163C]
    (No symbol) [0x0014269D]
    GetHandleVerifier [0x00539A22+2655074]
    GetHandleVerifier [0x0052CA24+2601828]
    GetHandleVerifier [0x00348C0A+619850]
    GetHandleVerifier [0x00347830+614768]
    (No symbol) [0x002305FC]
    (No symbol) [0x00235968]
    (No symbol) [0x00235A55]
    (No symbol) [0x0024051B]
    BaseThreadInitThunk [0x763D00F9+25]
    RtlGetAppContainerNamedObjectPath [0x77947BBE+286]
    RtlGetAppContainerNamedObjectPath [0x77947B8E+238]
    (No symbol) [0x00000000]

Any ideas?

I’ve searched here:

selenium.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="button-submit"]"}

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: – drop down item ID,XPATH did not work

How to solve selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element:

I have tried yo change By.ID for another choice, like By.CLASSNAME or others. Also, tried:

wait = WebDriverWait(driver, timeout=30)
producto = wait.until(EC.element_to_be_clickable((By.ID, "ReportViewerControl_ctl04_ctl05_txtValue")))
producto.send_keys(110017901)

but without any luck. I am recieving this error:

    Traceback (most recent call last):
  File "C:UsersJuan M CabralDesktopPycharmPreciosseleniumstk_jeans_locales_barra.py", line 34, in <module>
    producto = wait.until(EC.element_to_be_clickable((By.ID, "ReportViewerControl_ctl04_ctl05_txtValue")))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:UsersJuan M CabralPreciosLibsite-packagesseleniumwebdriversupportwait.py", line 95, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: 
Stacktrace:
Backtrace:
    (No symbol) [0x00FCF243]
    (No symbol) [0x00F57FD1]
    (No symbol) [0x00E4D04D]
    (No symbol) [0x00E7C0B0]
    (No symbol) [0x00E7C22B]
    (No symbol) [0x00EAE612]
    (No symbol) [0x00E985D4]
    (No symbol) [0x00EAC9EB]
    (No symbol) [0x00E98386]
    (No symbol) [0x00E7163C]
    (No symbol) [0x00E7269D]
    GetHandleVerifier [0x01269A22+2655074]
    GetHandleVerifier [0x0125CA24+2601828]
    GetHandleVerifier [0x01078C0A+619850]
    GetHandleVerifier [0x01077830+614768]
    (No symbol) [0x00F605FC]
    (No symbol) [0x00F65968]
    (No symbol) [0x00F65A55]
    (No symbol) [0x00F7051B]
    BaseThreadInitThunk [0x763D00F9+25]
    RtlGetAppContainerNamedObjectPath [0x77947BBE+286]
    RtlGetAppContainerNamedObjectPath [0x77947B8E+238]


Process finished with exit code 1

<span id="ReportViewerControl_ReportViewer"><div id="ReportViewerControl" onclick="if ($get('ReportViewerControl_ctl04') != null &amp;&amp; $get('ReportViewerControl_ctl04').control != null) $get('ReportViewerControl_ctl04').control.HideActiveDropDown();" onactivate="if ($get('ReportViewerControl_ctl04') != null &amp;&amp; $get('ReportViewerControl_ctl04').control != null) $get('ReportViewerControl_ctl04').control.HideActiveDropDown();" style="height: 700px; width: 100%;">
    <div id="ReportViewerControl_HttpHandlerMissingErrorMessage" style="border-color:Red;border-width:2px;border-style:Solid;padding:10px;display:none;overflow:auto;font-size:.85em;">
        <h2>
            Error de configuración del visor de informes
        </h2><p>El controlador HTTP de controles web del visor de informes no está registrado en el archivo web.config de la aplicación. Agregue &lt;add verb="*" path="Reserved.ReportViewerWebControl.axd" type = "Microsoft.Reporting.WebForms.HttpHandler, ReportingServicesWebServer, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /&gt; a la sección system.web/httpHandlers del archivo web.config, o bien agregue &lt;add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, ReportingServicesWebServer, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" /&gt; a la sección system.webServer/handlers para Internet Information Services 7 o posterior.</p>
    </div><span id="ReportViewerControl_ctl03"><input type="hidden" name="ReportViewerControl$ctl03$ctl00" id="ReportViewerControl_ctl03_ctl00"><input type="hidden" name="ReportViewerControl$ctl03$ctl01" id="ReportViewerControl_ctl03_ctl01"></span><input type="hidden" name="ReportViewerControl$ctl11" id="ReportViewerControl_ctl11"><input type="hidden" name="ReportViewerControl$ctl12" id="ReportViewerControl_ctl12" value="quirks"><div id="ReportViewerControl_AsyncWait" style="background-color: white; opacity: 0.7; position: absolute; display: none; z-index: 1000;">

    </div><div id="ReportViewerControl_AsyncWait_Wait" class="WaitControlBackground" style="display: none; position: absolute; z-index: 1001;">
        <table height="100%">
            <tbody><tr>
                <td width="32px" height="32px"><img src="/ReportServer_REPORTES/Reserved.ReportViewerWebControl.axd?OpType=Resource&amp;Version=10.50.1600.1&amp;Name=Microsoft.Reporting.WebForms.Icons.SpinningWheel.gif" style="height:32px;width:32px;border-width:0px;"></td><td class="WaitInfoCell"><span class="WaitText">Cargando...</span><div class="CancelLinkDiv">
                    <a class="CancelLinkText" href="javascript:$get('ReportViewerControl_AsyncWait').control._cancelCurrentPostback();">Cancelar</a>
                </div></td>
            </tr>
        </tbody></table>
    </div><input type="hidden" name="ReportViewerControl$AsyncWait$HiddenCancelField" id="ReportViewerControl_AsyncWait_HiddenCancelField" value="False"><table cellpadding="0" cellspacing="0" id="ReportViewerControl_fixedTable" style="table-layout:fixed;width:100%;height:100%;">
        <tbody><tr class="MenuBarBkGnd">
            <td style="display:none;width:25%;"></td><td style="display:none;width:6px;"></td><td style="width:100%;"></td>
        </tr><tr id="ParametersRowReportViewerControl">
            <td colspan="3"><div id="ReportViewerControl_ctl04" style="width:100%;overflow-x:auto;overflow-y:hidden;">
                <div onclick="if ($get('ReportViewerControl_ctl04') != null &amp;&amp; $get('ReportViewerControl_ctl04').control != null) $get('ReportViewerControl_ctl04').control.HideActiveDropDown();" onactivate="if ($get('ReportViewerControl_ctl04') != null &amp;&amp; $get('ReportViewerControl_ctl04').control != null) $get('ReportViewerControl_ctl04').control.HideActiveDropDown();">
                    <table cellpadding="0" cellspacing="0" width="100%" id="ParameterTable_ReportViewerControl_ctl04" name="ParameterTable_ReportViewerControl_ctl04" class="ParametersFrame ParamsGrid MenuBarBkGnd">
                        <tbody><tr>
                            <td width="100%" height="100%"><table id="ParametersGridReportViewerControl_ctl04">
                                <tbody><tr isparameterrow="true">
                                    <td class="ParamLabelCell"><span>Empresa</span></td><td class="ParamEntryCell" style="padding-right:0px;"><div id="ReportViewerControl_ctl04_ctl03">
                                        <select name="ReportViewerControl$ctl04$ctl03$ddValue" id="ReportViewerControl_ctl04_ctl03_ddValue" style="width: 168px;">
                                            
                                            <option selected="selected" value="1">CONBRA&nbsp;S.A.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
                                            <option value="2">HUNGRY&nbsp;S.A.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>

                                        </select>
                                    </div></td><td class="InterParamPadding"></td><td class="ParamLabelCell"><span>Producto</span></td><td class="ParamEntryCell" style="padding-right:0px;"><div id="ReportViewerControl_ctl04_ctl05">
                                        <input name="ReportViewerControl$ctl04$ctl05$txtValue" type="text" size="30" id="ReportViewerControl_ctl04_ctl05_txtValue" class="null">
                                    </div></td>
                                </tr><tr isparameterrow="true">
                                    <td class="ParamLabelCell"><span>Talle</span></td><td class="ParamEntryCell" style="padding-right:0px;"><div id="ReportViewerControl_ctl04_ctl07">
                                        <input name="ReportViewerControl$ctl04$ctl07$txtValue" type="text" size="30" id="ReportViewerControl_ctl04_ctl07_txtValue" class="null">
                                    </div></td><td class="InterParamPadding"></td><td class="ParamLabelCell"><span>Color</span></td><td class="ParamEntryCell" style="padding-right:0px;"><div id="ReportViewerControl_ctl04_ctl09">
                                        <input name="ReportViewerControl$ctl04$ctl09$txtValue" type="text" size="30" id="ReportViewerControl_ctl04_ctl09_txtValue" class="null">
                                    </div></td>
                                </tr>
                            </tbody></table></td><td width="6px"></td><td class="SubmitButtonCell"><table>
                                <tbody><tr>
                                    <td><input type="submit" name="ReportViewerControl$ctl04$ctl00" value="Ver informe" id="ReportViewerControl_ctl04_ctl00"></td>
                                </tr>
                            </tbody></table></td>
                        </tr>
                    </tbody></table>
                </div>
            </div></td>
        </tr><tr style="height:6px;font-size:2pt;">
            <td colspan="3" class="SplitterNormal" style="padding: 0px; margin: 0px; text-align: center; cursor: default;"><div id="ReportViewerControl_ToggleParam">
                <input type="image" name="ReportViewerControl$ToggleParam$img" id="ReportViewerControl_ToggleParam_img" title="Mostrar u ocultar parámetros" src="/ReportServer_REPORTES/Reserved.ReportViewerWebControl.axd?OpType=Resource&amp;Version=10.50.1600.1&amp;Name=Microsoft.Reporting.WebForms.Icons.SplitterHorizCollapse.png" alt="Mostrar u ocultar parámetros" align="middle" onclick="void(0);" style="border-width:0px;cursor:pointer;"><input type="hidden" name="ReportViewerControl$ToggleParam$store" id="ReportViewerControl_ToggleParam_store"><input type="hidden" name="ReportViewerControl$ToggleParam$collapse" id="ReportViewerControl_ToggleParam_collapse" value="false">
            </div></td>
        </tr><tr style="display:none;">

        </tr><tr>
            <td style="vertical-align: top; width: 25%; height: 596px; display: none;"><div style="width:100%;height:100%;">
                <span id="ReportViewerControl_DocMap"><div id="ReportViewerControl_ctl09" style="display:none;">
                    <input type="hidden" name="ReportViewerControl$ctl09$ClientClickedId" id="ReportViewerControl_ctl09_ClientClickedId">
                </div></span>
            </div></td><td class="SplitterNormal" style="display: none; width: 4px; padding: 0px; margin: 0px; height: 596px; vertical-align: middle;"><div id="ReportViewerControl_ctl08">
                <input type="image" name="ReportViewerControl$ctl08$img" id="ReportViewerControl_ctl08_img" title="Mostrar u ocultar mapa de documento" src="/ReportServer_REPORTES/Reserved.ReportViewerWebControl.axd?OpType=Resource&amp;Version=10.50.1600.1&amp;Name=Microsoft.Reporting.WebForms.Icons.SplitterVertCollapse.png" alt="Mostrar u ocultar mapa de documento" align="top" onclick="void(0);" style="border-width:0px;cursor:pointer;"><input type="hidden" name="ReportViewerControl$ctl08$store" id="ReportViewerControl_ctl08_store"><input type="hidden" name="ReportViewerControl$ctl08$collapse" id="ReportViewerControl_ctl08_collapse" value="false">
            </div></td><td style="height: 596px; vertical-align: top;"><div id="ReportViewerControl_ctl10" style="height:100%;width:100%;overflow:auto;position:relative;">
                <div id="VisibleReportContentReportViewerControl_ctl10" style="height:100%;display:none;"></div><div id="ReportViewerControl_ctl10_ReportArea">
                    <div newcontenttype="Microsoft.Reporting.WebFormsClient.ReportAreaContent.None" fornonreportcontentarea="false" id="ReportViewerControl_ctl10_VisibilityState" style="visibility:none;">
                        <input type="hidden" name="ReportViewerControl$ctl10$VisibilityState$ctl00" value="None">
                    </div><input type="hidden" name="ReportViewerControl$ctl10$ScrollPosition" id="ReportViewerControl_ctl10_ScrollPosition"><span id="ReportViewerControl_ctl10_Reserved_AsyncLoadTarget"></span><div id="ReportViewerControl_ctl10_ReportControl" style="display:none;">
                        <span></span><input type="hidden" name="ReportViewerControl$ctl10$ReportControl$ctl02"><input type="hidden" name="ReportViewerControl$ctl10$ReportControl$ctl03"><input type="hidden" name="ReportViewerControl$ctl10$ReportControl$ctl04" id="ReportViewerControl_ctl10_ReportControl_ctl04" value="100">
                    </div><div id="ReportViewerControl_ctl10_NonReportContent" style="height: 100%; width: 100%; display: none;">

                    </div>
                </div>
            </div></td>
        </tr>
    </tbody></table>
</div></span>

im sharing a bigger block of html, if it helps.

the code i have to use, is this:

<td class="ParamEntryCell" style="padding-right:0px;"><div id="ReportViewerControl_ctl04_ctl05">
                                        <input name="ReportViewerControl$ctl04$ctl05$txtValue" type="text" size="30" id="ReportViewerControl_ctl04_ctl05_txtValue" class="null">
                                    </div></td>

Answers:

Does this work for you?

wait = WebDriverWait(driver, timeout=30)
producto = wait.until(ec.element_to_be_clickable((By.ID, "ReportViewerControl_ctl04_ctl05_txtValue")))
Answered By: Marcel Wilson

Marcel Wilson gave me the key to my problem, but I did not realize unitl now. The problem was an iframe.

<iframe src="http://192.168.0.98/ReportServer_REPORTES/Pages/ReportViewer.aspx?%2fGaciReps%2fStock+Producto+en+Locales" name="EMBPAGE1" title="" style="width:100%;height:700px;overflow-x:auto;overflow-y:auto;display:block;margin:0 auto;border:none;"></iframe>

My code now must be like this:

driver.switch_to.frame("EMBPAGE1")

wait = WebDriverWait(driver, timeout=5)
producto = wait.until(EC.presence_of_element_located((By.ID, "ReportViewerControl_ctl04_ctl05_txtValue")))
producto.send_keys(110017901)
ver_informe = driver.find_element(by=By.ID, value='ReportViewerControl_ctl04_ctl00')
ver_informe.click()
descarga = driver.find_element(by=By.ID,value='ReportViewerControl_ctl06_ctl04_ctl00_ButtonImgDown')
descarga.click()

Thanks