未找到 Web 元素,但在手动检查时出现

Web element not found but appears when inspected manually

我无法在 selenium 中访问此菜单 Web 元素在手动完成之前不会出现在检查器中

<a id="cke_3275" class="cke_menubutton cke_menubutton__table cke_menubutton_off cke_menubutton__table" href="javascript:void('Table Properties')" title="Table Properties" tabindex="-1" _cke_focus="1" hidefocus="true" role="menuitem" aria-haspopup="false" aria-disabled="false" onmouseover="CKEDITOR.tools.callFunction(666,5);" onmouseout="CKEDITOR.tools.callFunction(667,5);" onclick="CKEDITOR.tools.callFunction(668,5); return false;">
  <span class="cke_menubutton_inner">
    <span class="cke_menubutton_icon">
      <span class="cke_button_icon cke_button__table_icon" style="background-image:url(https://lms.testbook.com/vendor/ckeditor/plugins/icons.png?t=E6FD);background-position:0 -1896px;background-size:auto;">
      </span>
    </span>
  <span class="cke_menubutton_label">
    Table Properties
  </span>
  </span>
</a>

我尝试访问父级,点击 actions.perform() 似乎没有任何效果。

当我将鼠标悬停在菜单内容上时,我看到 javascript:void('contentname'),我将其粘贴到检查器中并找到了网络元素。

iframe=WebDriverWait(driver,  10).until(EC.presence_of_element_located((By.XPATH, "/html/body/iframe")))

driver.switch_to.frame(iframe)
driver.find_element_by_tagname("a")

切换到 iframe,然后添加其余代码

driver.switch_to.default_content()  

您需要在使用完元素后切换到默认内容并希望与 iframe 之外的元素交互