为 SAP EPM 浏览器应用程序获取 "element not visible" 使用 selenium python

Getting "element not visible" using selenium python for SAP EPM browser application

我正在尝试使用 Selenium Python 自动化 SAP EPM 应用程序。这是一个基于浏览器的应用程序。我能够打开主页,之后我必须单击一个磁贴。但我无法点击它。它说 "element not visible".

我尝试使用 xpath、id 但没有成功。

平铺 HTML:

<div class="tile tile-webdyn draggable tileBGColor ui-draggable ui-draggable-handle 
                 ui-droppable border-norm" id="PLANCHGWO" style="position: relative;">
  <div class="tileName">
    <center>Change PM Order</center>
  </div>
  <div class="tileImage">
    <center>
      <img width="50px" height="50px" src="EDWO.png">
    </center>
  </div>
</div>

您可以尝试调用 wait,然后使用 Javascript 单击所需的 WebElement 以解决您看到的 not visible 错误。

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC



# wait for element to exist, then store it in tile variable
tile = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//center[text()='Change PM Order']")))

# click the element with Javascript
driver.execute_script("arguments[0].click();", tile)

如果这不起作用,我们可能需要查看完整页面 HTML 以了解您尝试单击的元素。它可能隐藏在 iframe 中或被页面上的其他元素遮挡。