簡體   English   中英

python-selenium返回元素不可交互錯誤

[英]python-selenium returning element is not interactable error

我正在使用Selenium-python綁定。 嘗試選擇和操作元素時出現以下錯誤。 (使用Chromedriver)

Message: invalid element state: Element is not currently interactable and may not be manipulated

我認為該元素已使用以下語法成功選擇:但是我無法使用clear()或send_keys(“ some value”)進行操作。 我想填充文本區域,但是無法使其正常工作。 如果您遇到類似的問題,請分享您的想法。 謝謝。

更新:我注意到html隨我手動鍵入style =“ display:none”而改變,這可能是導致此錯誤的原因。 修改了下面的代碼。 您能指出任何解決方案嗎?

driver.find_element(by='xpath', value="//table[@class='input table']//input[@id='gwt-debug-url-suggest-box']")

要么

driver.find_element(by='xpath', value="//input[@id='gwt-debug-url-suggest-box']")

要么

driver.find_element_by_id("gwt-uid-47")

要么

driver.find_element(by='xpath', value="//div[contains(@class, 'sppb-b')][normalize-space()='www.example.com/page']")

這是html源代碼:

<div>
    <div class="spH-c" id="gwt-uid-64"> Your landing page </div>
    <div class="spH-f">
        <table class="input-table" width="100%">
            <tbody>
                <tr>
                    <td class="spA-e">
                        <div class="sppb-a" id="gwt-uid-47">
                            <div class="sppb-b spA-b" aria-hidden="true" style="display: none;">www.example.com/page</div>
                            <input type="text" class="spC-a sppb-c" id="gwt-debug-url-suggest-box" aria-labelledby="gwt-uid-64 gwt-uid-47" dir="">
                            </div>
                            <div class="error" style="display:none" id="gwt-debug-invalid-url-error-message" role="alert"> Please enter a valid URL. </div>
                        </td>
                        <td class="spB-b">
                            <div class="spB-a" aria-hidden="true" style="display: none;"></div>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>

您是否嘗試過選擇:

driver.find_element_by_id("gwt-debug-url-suggest-box")
driver.send_keys("Your input")

這樣,您可以直接選擇輸入。 無論如何,指向頁面的鏈接會有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM