Python 3.x 尝试单击元素时出现“ElementNotVisibleException”和“InvalidSelectorException:无效选择器:不允许使用复合类名”

Python 3.x 尝试单击元素时出现“ElementNotVisibleException”和“InvalidSelectorException:无效选择器:不允许使用复合类名”,python-3.x,selenium,selenium-webdriver,xpath,css-selectors,Python 3.x,Selenium,Selenium Webdriver,Xpath,Css Selectors,我正在尝试从公司门户网站自动下载信息。我需要在代码的其他部分指定一个自定义日期范围 html页面的格式如下 <div id="datePickerIconWrap" class="float_lang_base_2 datePickerIconWrap"><span class="datePickerIcon">&nbsp;</span></div> 我收到以下的错误消息。按\u id查找\u元素\u ElementNotVisibleE

我正在尝试从公司门户网站自动下载信息。我需要在代码的其他部分指定一个自定义日期范围

html页面的格式如下

<div id="datePickerIconWrap" class="float_lang_base_2 datePickerIconWrap"><span class="datePickerIcon">&nbsp;</span></div>
我收到以下的错误消息。按\u id查找\u元素\u

ElementNotVisibleException: Message: element not visible
我得到下面的错误消息。按类查找元素

InvalidSelectorException: Message: invalid selector: Compound class names not permitted
(Session info: chrome=68.0.3440.106)
关于错误:

此错误消息ElementNotVisibleException:message:element not visible表示所需元素在中不可见。 此错误消息InvalidSelectorException:message:invalid selector:Compound class names not Allowed表示您调整的不是有效的。 解决方案 要调用,请单击所需元素,可以使用以下任一解决方案:

CSS_选择器:

XPATH:

注意:您必须添加以下导入:

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.float_lang_base_2.datePickerIconWrap>span.datePickerIcon"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='float_lang_base_2 datePickerIconWrap']/span[@class='datePickerIcon']"))).click()
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC