使用selenium python for SAP EPM browser应用程序获取“元素不可见”

2024-10-06 12:35:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用seleniumpython自动化sapepm应用程序。它是一个基于浏览器的应用程序。我可以打开主页,然后我必须点击一个瓷砖。但我无法点击它。上面写着“元素不可见”。你知道吗

我尝试使用xpath,但是没有成功。你知道吗

Tile "Change PM Order"

平铺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>

Tags: div应用程序元素ui浏览器主页xpathclass
1条回答
网友
1楼 · 发布于 2024-10-06 12:35:21

您可以尝试调用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中或被页面上的其他元素遮挡。你知道吗

相关问题 更多 >