${get_t}= Get Text //h6[@class='MuiTypography-root MuiTypography-subtitle2']
Log ${get_t}
${get_t1}= Get Element Count xpath://h6[@class='MuiTypography-root MuiTypography-subtitle2']
Log ${get_t1}
${get_t3}= Get WebElements xpath://h6[@class='MuiTypography-root MuiTypography-subtitle2']
Log ${get_t3}
当我得到 Count 时,它会显示计数,但当我使用 Get WebElements 打印它时,它不会打印文本。如果我给出 Get Text,它会单独打印第一个文本。
最佳答案
您想实现什么 - 获取/打印每个元素的文本?因为 Get Webelements
的作用正如它的名字所说 - 返回一个匹配元素列表 - selenium 元素对象。
这样,如果您想打印每个成员的文本,只需遍历列表并在每个成员上调用 Get Text
:
FOR ${el} IN @{get_t3}
${txt}= Get Text ${el}
Log ${txt}
END
关于python - 如何在 Robot Framework- SeleniumLibrary 中获取多个元素并打印?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60016277/