元素未单击[selenium]

2024-03-28 19:47:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用selenium2library(python)实现自动化。这是所使用的方法

def get_appointment_from_manage(self, date, appt_id):
    ref_date = "//*[@data-date=\"%s\"]" % date
    time.sleep(2)
    logging.info(date)
    logging.info(appt_id)
    while not self.is_element_present_by_xpath(ref_date) :
        self._current_browser().find_element_by_xpath("//*[@id=\"calendar1\"]/div[1]/div[3]/div/button[2]").click();
    time.sleep(2)
    element = self._current_browser().find_element_by_xpath("//*[@data-aid=\"%s\"]" % appt_id)
    logging.info(element)

    ActionChains(self._current_browser()).move_to_element(element).click().perform()

日志记录表明找到了元素,但它没有单击。 这是没有点击的部分。你知道吗

    element = self._current_browser().find_element_by_xpath("//*[@data-aid=\"%s\"]" % appt_id)
    logging.info(element)

    ActionChains(self._current_browser()).move_to_element(element).click().perform()

检查滤芯时,整个滤芯都被蓝色覆盖。所以我不知道我错过了什么。火狐版本是28。提前谢谢!你知道吗

编辑

这是html

<div class="fc-event-container">
    <div class="fc-event-box" style="position:relative;z-index:1"></div>
    <div data-aid="31" class="fc-event-data-container fc-status-2" style="position:absolute;top:0px;right:0;bottom:-62px;left:0;z-index:1">
        <div class="fc-event-data-box">
            <a class="fc-time-grid-event fc-event fc-start fc-end evnt-1419408000000" style="top: 0px; bottom: -62px; z-index: 1; left: 0%; right: 0%;">
                <div class="fc-content">
                    <div class="fc-time" data-start="8:00" data-full="8:00 AM - 8:30 AM" style="display:none;">
                        <span>8:00 - 8:30</span>
                    </div>
                    <div class="fc-title">Robot-FN</div>
                    <span class="fc-product">Home Loans</span>
                </div>
                <div class="fc-bg"></div>
            </a>
        </div>
    </div>
</div>

Tags: selfdivbrowserinfoeventiddatadate
1条回答
网友
1楼 · 发布于 2024-03-28 19:47:20

我不确定你在尝试什么,但是如果你想点击<a>标签(它是可点击的),那么,你需要保持那个元素,而不是包含它的<div>。你知道吗

尝试这样的事情:(我没有尝试这个xpath,所以把它作为一个总体想法)

element = self._current_browser().find_element_by_xpath("//*[@data-aid=\"%s\"]//a" % appt_id)

相关问题 更多 >