硒python元素不可点击-WebDriverWait

时间:2020-05-02 14:44:46

标签: python selenium-webdriver web-crawler webdriverwait

使用python中的Selenium在HTML页面上打开弹出窗口后尝试单击按钮。这是我的代码:

driver.find_element_by_id("location").click()
element = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,"//button[@id='sortbydistbtn']")))
element.click()

以下是HTML代码的代码:

<div class="b-modal __b-popup1__" style="background-color: rgb(0, 0, 0); position: fixed; inset: 0px; opacity: 0.8; z-index: 9998; cursor: pointer;"></div>
<section class="jpop dn" id="jsbd" style="left: 371px; position: absolute; top: 105.625px; z-index: 9999; opacity: 1; display: block;"> 
    <section class="jpbg">
        <span class="jcl">X</span>
        <span class="ptxt">Sort By Location</span>
        <p>Where in Delhi</p>
        <span class="jinp">
            <input class="" type="text" name="sortbydist" id="sortbydist" value="110001" autocomplete="off">
            <input type="hidden" name="locarea" id="locarea" value="">
            <span id="sbd" class="jauto dn"></span>
        </span>
        <!--<button class="jbtn" type="button" onClick="return sortBydist('10364355');">Go</button>-->
        <button class="jbtn" id="sortbydistbtn" type="button" data-catid="10364355">Go</button>
    </section>
</section>

在python的第一行中单击 location 时,HTML代码将作为弹出窗口打开。弹出窗口会在自动Chrome窗口中打开,但此后没有任何反应。我必须单击按钮。

0 个答案:

没有答案