检查元素是否包含特定文本 - Python Selenium

时间:2021-06-29 20:19:43

标签: python selenium

enter image description here

我需要检查这个字符串(组 ID 元素)是否包含除数字以外的任何内容,如果包含,请执行其他操作。我知道 jquery 有 :contains,但是 Selenium 使用什么?此元素的 CSS 选择器是 #app > div.v-application--wrap > main > div > div > div.container > div:nth-child(4) > div > div > div.row.no-gutters.align-start.justify-start.align-content-start > div:nth-child(2) > div > div > div.v-slide-group__wrapper > div > div:nth-child(4)

1 个答案:

答案 0 :(得分:0)

您可以在 div 文本上使用 isnumeric()

if div.text.isnumeric():
    # Do something
相关问题