如何点击 span class 中的动态元素? Selenium WebDriver

How to click a dynamic element in span class? Selenium WebDriver

大家好,我在这种情况下遇到了问题。请就如何操作给出建议。

尝试使用此 xpath(不工作):

.//*[@id='76']/div/div[3]/span[1]/span

请帮帮我。

注意:'Show Details'link是可点击的,它们的ID不同,黄色标记的是不能点击的。

感谢所有愿意就此分享想法的人 谢谢!

尝试基于 xpath 文本的搜索

//span[contains(text(),'Show Details')]

它可以让你在不关心空格的情况下找到跨度

也可以使用class name

// driver is the selenium driver object. Need to make sure, compound names are not allowed
IWebElement span = driver.FindElement(By.ClassName("message-action-menu-text")); 

请尝试这样的操作:

//*[@id='76']//span[@class='message-action-menu-text']

您可以尝试如下:

xpath=(//span[text(), 'Show Details'])[76]

正如您所说 'Show Details' 的 ID 一直在变化,那么您必须将当前 ID 替换为 76。

希望此 xpath 对您有用。