Search code examples
pythontwitter-bootstrapseleniumselenium-webdriverbootstrap-datetimepicker

can not click the element which from[display:none] to [display:block] (bootstrap datatimepicker)


I have a page which has a bootstrap DateTime picker like this:

enter image description here

I can click the calendar icon to show the popup. Also, the popup becomes display: block; from display: none;

But when I click 今日 button,I got an error:

selenium.common.exceptions.ElementNotVisibleException: Message: element not visible

But as you see the element is actually visible now.

My element selector is right, because I can log the element use:

eml = browser.find_element_by_class_name('today')
print eml.get_attribute('innerHTML')

It shows 今日

How can I click this element?


Solution

  • Could you please try with action classes.

     Actions actions= new Actions(driver); // heare you state ActionBuider
    actions.moveToElement(eml); // Here you perform hover mouse over the needed elemnt to triger the visibility of the hidden
    actions.click().build().perform();
    

    I think this should work.Please let me know if it doesn't work