Html Selenium中的自动下拉菜单,无需选择

Html Selenium中的自动下拉菜单,无需选择,html,css,python-3.x,selenium,Html,Css,Python 3.x,Selenium,我正在尝试使用Selenium从下拉列表中选择一个元素。我已经能够选择下拉列表,但我不知道如何从下拉列表中选择特定元素,因为网站不使用select,因此我无法使用内置的select类。作为参考,这是下拉列表中一个元素的HTML 喋喋不休 这是整个下拉列表的HTML <div role="listbox" aria-expanded="false" class="Ej BtzVgc" jscontroller="YwHGTd" jsaction="click:cOuCgd(LgbsSe)

我正在尝试使用Selenium从下拉列表中选择一个元素。我已经能够选择下拉列表,但我不知道如何从下拉列表中选择特定元素,因为网站不使用select,因此我无法使用内置的select类。作为参考,这是下拉列表中一个元素的HTML


喋喋不休

这是整个下拉列表的HTML

<div role="listbox" aria-expanded="false" class="Ej BtzVgc" jscontroller="YwHGTd" jsaction="click:cOuCgd(LgbsSe); keydown:I481le; keypress:Kr2w4b; mousedown:UX7yZ(LgbsSe),npT2md(preventDefault=true); mouseup:lbsD7e(LgbsSe); mouseleave:JywGue; touchstart:p6p2H(LgbsSe); touchmove:FwuNnf; touchend:yfqBxc(LgbsSe|preventMouseEvents=true|preventDefault=true); touchcancel:JMtRjd(LgbsSe); focus:AHmuwe; blur:O22p3e;b5SvAb:TvD9Pc;" jsshadow="" data-max-rows="10"><div jsname="LgbsSe" role="presentation">
  <div class="EI" jsname="d9BH4c" role="presentation">
    <div class="Di ljb1sb hIqB1e LMgvRb bf" jsname="wQNmvb" jsaction="" data-value="118237948356370773614" aria-selected="true" tabindex="0" role="option">
       <div class="qm he" jsname="ksKsZd" style="top: 27px; left: 92px; width: 197px; height: 197px;"></div>
       <content class="u5 jh">BlainSupply</content>
    </div>
    <div class="Di ljb1sb hIqB1e LMgvRb" jsname="wQNmvb" jsaction="" data-value="118324169618367399437" aria-selected="false" tabindex="-1" role="option">
        <div class="qm he" jsname="ksKsZd"></div>
        <content class="u5 jh">GPlusPages02</content>
    </div>
    <div class="Di ljb1sb hIqB1e LMgvRb" jsname="wQNmvb" jsaction="" data-value="101010111938653639529" aria-selected="false" tabindex="-1" role="option">
        <div class="qm he" jsname="ksKsZd"></div>
        <content class="u5 jh">GSitemap2</content>
    </div>
  </div>
  <div class="v5 VtTjbf eU809d" role="presentation"></div></div>

喋喋不休
GPlusPages02
GSitemap2
任何帮助都将不胜感激

您可以尝试以下方法:

from selenium.webdriver.support import expected_conditions as EC

element = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//content[contains(., 'BlainSupply')]")))
element.click()
作为替代方案,您可以尝试以下
xPath

//content[contains(., 'BlainSupply')]/parent::div

因为我不确定
内容
标记是否可单击

这可以获得正确的元素,但由于某些原因,它不允许我单击它。控制台给我一个selenium.common.exceptions.ElementNotVisibleException:Message:element不可见错误。您知道为什么会这样吗?请尝试在浏览器的devtools中检查我的xpath,如果它找到了一个元素,并且找到了正确的元素,请检查您的页面是否有
iframe
,如果是,请检查元素是否在
iframe