slelnium python:单击没有 ID 或名称的动态 object/element

slelnium python : clicking a dynamic object/element which has no id or name

当执行右键单击时,会出现一个选项 popup/screen,它是一个动态的 content/element。

这是选项弹出窗口:

只要在屏幕上的其他地方点击鼠标,这个动态 content/element 就会消失,即使它点击了检查元素 window 动态 content/element 也会消失

弹出窗口中 select 的选项很少,但在 html 代码中没有这些选项的名称或 ID,所以我如何从 selenium access/select 它们使用 python ?

这是 HTML 的样子:

我打算 select 选项 HMH NC 通过使用 selenium 发送 Righ click 然后使 select 选项但是因为选项没有名称或 ID 我可以弄清楚如何去做

您必须通过文本搜索。我会做这样的事情(未经测试的代码):

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

item_labels = WebDriverWait(my_driver,5).until(
    EC.visibility_of_element_located((By.CSS_SELECTOR, "div.item span.label")),
    message="failed to find any menu items")

target = None
for item in item_labels:
    if item.get_attribute("text") == target_value:
        target = item
        break
target.click()